View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010269 | mantisbt | public | 2009-03-27 12:17 | 2019-01-11 06:42 | |
Reporter | alexy | Assigned To | grangeway | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.0a3 | ||||
Fixed in Version | 1.2.0rc1 | ||||
Summary | 0010269: Incorrect email subjects | ||||
Description | Email subjects are generated incorrectly, up to 1.1.6 they were really wrong because you were splitting the resulting base64 line againts base64 rules, in 1.2.0a3 the situation is much better, you are apparently splitting the text before encoding it in base64 but you add an extra space for each encoded part even if there wasn't a space in the original text. For example for original text (the text is in russian): In version 1.2.0a3: Upto and including version 1.1.6: | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Below is a fix for the issue (for class.phpmailer.php in 1.2.0a3), there were a combination of several small bugs together: * class.phpmailer.php Thu Jan 15 10:05:00 2009 ! $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\1?=", $encoded); --- 1332,1339 ---- ! $encoded = preg_replace('/^(.*)$/m', "=?".$this->CharSet."?$encoding?\1?=", $encoded); ***** class PHPMailer { ! $encoded .= $chunk . $this->LE;
! $encoded = substr($encoded, 0, -strlen($this->LE)); --- 1383,1393 ---- ! $encoded .= $chunk . "\n";
! $encoded = substr($encoded, 0, -1); |
|
Sent the patch to PHPMailer as well |
|
Fix in git master. Thanks. |
|
Can you test this against phpmailer 5.0 |
|
Judging from 5.0 source code from here: The problem is still there. No change in code in that area. |
|
I've tested PHPMailer 5.0 against Mantis and I can confirm via Wireshark testing that the line termination of email header fields and line breaks within the message itself appear to be CRLF (correct according to RFC2822). I'm unsure why there is a configuration option in PHPMailer 5.0 specifying LE as just LF... without the CR. It must have some other usage I haven't read into enough. Basically all I'm saying is that every line within an email message (header and body) should be terminated with CRLF, not just LF. |
|
Well, yes it is strange that LE can be configured, but that is not the problem of this ticket. The issue in this ticket is that because of the following regexp $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\1?=", $encoded) would match the string until the LF, causing the CR to be part of the final encoded chunk and in addition it is better to place each encoded chunk on a separate line in the resulting subject header. |
|
So in terms of phpmailer 5.0: we need the I dont understand a couple of things: a) why did you need to change the 2nd part (surely strlen(LE) for \n is 1 so that's the same, if someone is using \r\n would you not require -2? b) why the addition of a space after the \n i.e. in the trim line i.e. doesn't that lead to extra whitespace? |
|
All the changes are need, a) First of all LE is \r\n. Second, the change in Base64EncodeWrapMB is in two lines: The reason to use "\n" here instead of $this->LE is that Base64EncodeWrapMB is only used internally in EncodeHeader and the output of Base64EncodeWrapMB is then processed using regexp - and those regexp (well at least on linux systems) don't work as meant if the output of Base64EncodeWrapMB contains \r\n. This what I show in my previous reply. b) The space is a must, as all those lines are part of the Subject: header. For several lines to belong to one header they must start with a space or a tab. This is the MIME standard. |
|