Repository navigation
fix: give a custom To header its 3.0.0 behaviour back - #8
Merged
Merged
Conversation
The previous change made setHeader('To') case-insensitive, kept it when the
library wrote no To, and so turned it into a new recipient on sendmail. To is
no longer special-cased on any transport: the library's own To line replaces a
custom header named exactly To and sits beside other spellings, as in 3.0.0,
including in BCC batches. Cc and Bcc keep losing to the library's own header.
A matrix test compares To/Cc/Bcc x six name spellings x mail()/sendmail/SMTP x
single message/BCC batches against output recorded from the 3.0.0 tag. Header
names may again have spaces around them, as in 3.0.0. The new public helpers on
EmailValidator and HeaderRenderer are marked @internal.
A display name with a CR, LF or NUL was refused although 3.0.0 wrote it safely (an ASCII name is quoted with control characters backslash-escaped, a non-ASCII name is Q-encoded with the line breaks removed). Address no longer rejects the name or the raw input, only the address part; QEncoder again encodes a NUL (=00) as 3.0.0 did. Tests pin 168 whole messages against the 3.0.0 output and check that the rendered header block gains no header from the name. Also: limit the "same as 3.0.0" claim for custom To to the spellings that are accepted (spaces around the name, not tabs), test a trailing LF and tabs in header names, document the leading space in isValidName(), and list the behaviour changes under Changed in the changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setHeader('To', ...)is no longer special-cased. Onmail(), sendmail and SMTP, and in BCC batches, its output equals the 3.0.0 tag's for every spelling of the name (exact, lower, upper, mixed case, a space before or after). The previous change kept a customTowhen the library wrote none, which made it a new recipient onsendmail -t.Cc/Bcckeep the earlier decision: a custom one loses to the library's own header (case and spacing ignored), and is kept when the library does not write it.EmailValidator::hasLineBreakOrNul(),hasUnsafeAddressChar(),assertSafeAddresses(),HeaderRenderer::names(),without(),isValidName(),assertSafe()) are marked@internal.CHANGELOG.md(Unreleased) updated.Test plan
vendor/bin/phpunit(611 tests)vendor/bin/phpstan analyse,vendor/bin/php-cs-fixer fix --dry-run --diff,composer validate --strict,wiki-sync.sh --check docs