Ticket #28039: 28039.2.diff
File 28039.2.diff, 2.9 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-phpmailer.php
1667 1667 public function getMailMIME() 1668 1668 { 1669 1669 $result = ''; 1670 $ismultipart = true; 1670 1671 switch ($this->message_type) { 1671 1672 case 'inline': 1672 1673 $result .= $this->headerLine('Content-Type', 'multipart/related;'); … … 1687 1688 default: 1688 1689 // Catches case 'plain': and case '': 1689 1690 $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); 1691 $ismultipart = false; 1690 1692 break; 1691 1693 } 1692 1694 //RFC1341 part 5 says 7bit is assumed if not specified 1693 1695 if ($this->Encoding != '7bit') { 1694 $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); 1696 //RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE 1697 if ($ismultipart) { 1698 if ($this->Encoding == '8bit') { 1699 $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); 1700 } 1701 //The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible 1702 } else { 1703 $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); 1704 } 1695 1705 } 1696 1706 1697 1707 if ($this->Mailer != 'mail') { -
tests/phpunit/tests/mail.php
190 190 // Fatal errors 191 191 $this->assertFalse( wp_mail( 'invalid.address', 'subject', 'body', '', array() ) ); 192 192 } 193 194 function wp_mail_quoted_printable( $mailer ) { 195 $mailer->Encoding = 'quoted-printable'; 196 } 197 198 function wp_mail_set_text_message( $mailer ) { 199 $mailer->AltBody = 'Wörld'; 200 } 201 202 /** 203 * > If an entity is of type "multipart" the Content-Transfer-Encoding is 204 * > not permitted to have any value other than "7bit", "8bit" or 205 * > "binary". 206 * http://tools.ietf.org/html/rfc2045#section-6.4 207 * 208 * > "Content-Transfer-Encoding: 7BIT" is assumed if the 209 * > Content-Transfer-Encoding header field is not present. 210 * http://tools.ietf.org/html/rfc2045#section-6.1 211 * 212 * @ticket 28039 213 */ 214 function test_wp_mail_content_transfer_encoding_in_quoted_printable_multipart() { 215 add_action( 'phpmailer_init', array( $this, 'wp_mail_quoted_printable' ) ); 216 add_action( 'phpmailer_init', array( $this, 'wp_mail_set_text_message' ) ); 217 218 wp_mail( 219 'user@example.com', 220 'Hello', 221 '<p><strong>Wörld</strong></p>', 222 'Content-Type: text/html' 223 ); 224 225 $this->assertNotContains( 'quoted-printable', $GLOBALS['phpmailer']->mock_sent[0]['header'] ); 226 } 193 227 }