User tests: Successful: Unsuccessful:
Pull Request resolves #
MailHelper::cleanText() removes line breaks followed by a mail header name from multi line input and is used by Mail::setBody(). Two gaps exist in the current pattern:
CRLF sequence leaves its CR behind: "test\r\nto:me" becomes "test\rme" instead of "testme". The data provider of the existing unit test already contains commented rows for these cases, marked with @TODO Should this be included.content-type:, to:, cc: and bcc: are covered, while the sibling methods cleanBody() and cleanSubject() also filter From: and Subject:. A body line such as "test\r\nreply-to:me" passes through completely unfiltered.This PR makes the line break part repeatable so the full CRLF or repeated encoded breaks are consumed, and extends the header list with from:, subject: and reply-to:. The commented rows in the data provider are enabled and rows for the added header names and the mixed %0A%0D form are supplied. Fifteen provider rows fail against the previous implementation.
The scope is deliberately the same as before: only a line break directly followed by one of the known header names is removed from mail input.
Run the mail helper unit tests:
libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Mail/MailHelperTest.php
The complete mail test directory passes with the change:
libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Mail
MailHelper::cleanText("test\r\nto:me") returns "test\rme" and MailHelper::cleanText("test\r\nreply-to:me") returns the input unchanged.
Both inputs return "testme".
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries Unit Tests |