Skip to content

Stdlib: mail() additional_headers array|string + header ValueError (ext/standard/mail.c) #21432

Description

@PurHur

Category

stdlib | child of #3285 (mail transport depth)

Problem

After sendmail transport (#3285), mail() still only accepts a string for $additional_headers. Zend 8.x accepts array|string and validates via php_mail_build_headers() — rejecting embedded To/Subject, invalid field names, and CR/LF/NUL in values with ValueError / TypeError.

php-src reference

Repro (failure after #3285 transport lands)

<?php
try {
    mail('a@b.c', 'subj', 'body', ['To' => 'evil@x']);
    echo "NO_THROW\n";
} catch (ValueError $e) {
    echo "ValueError\n";
}
Engine Result
Zend 8.4 ValueError (additional headers cannot contain To)
VM today TypeError (string required) or wrong accept

Scope

Path Work
ext/standard/VmMail.php / mail.php array headers → RFC2822 lines; ValueError parity
Tests test/compliance/cases/stdlib/mail_headers_array.phpt

Done when (php-src-strict)

  • mail(..., ['From' => 'x@y']) builds header line and reaches transport
  • To / Subject keys → ValueError matching Zend message shape
  • Invalid CR/LF in header values → ValueError
  • Compliance .phpt green on VM

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions