Make WordPress Core

Ticket #28473: 28473-2.diff

File 28473-2.diff, 2.6 KB (added by stephenharris, 9 years ago)
  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 8b64359..a726f6a 100644
    function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() 
    223223                        // Explode the headers out, so this function can take both
    224224                        // string headers and an array of headers.
    225225                        $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
     226
     227                        // Line which starts with space is a continuation of previous line, need to keep them as one
     228                        for ( $index = 0; $index < count( $tempheaders ); $index ++ ) {
     229                                if ( $index > 0 && $tempheaders[$index] && ' ' === $tempheaders[$index][0] ) {
     230                                        $tempheaders[ $index - 1 ] .= "\n" . $tempheaders[$index];
     231                                        array_splice( $tempheaders, $index, 1 );
     232                                        $index--;
     233                                }
     234                        }
    226235                } else {
    227236                        $tempheaders = $headers;
    228237                }
    function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() 
    258267                                                                $from_name = substr( $content, 0, $bracket_pos - 1 );
    259268                                                                $from_name = str_replace( '"', '', $from_name );
    260269                                                                $from_name = trim( $from_name );
     270                                                                if ( function_exists( 'mb_decode_mimeheader' ) ) {
     271                                                                        $from_name = mb_decode_mimeheader( $from_name );
     272                                                                }
    261273                                                        }
    262274
    263275                                                        $from_email = substr( $content, $bracket_pos + 1 );
    function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() 
    268280                                                } elseif ( '' !== trim( $content ) ) {
    269281                                                        $from_email = trim( $content );
    270282                                                }
     283
    271284                                                break;
    272285                                        case 'content-type':
    273286                                                if ( strpos( $content, ';' ) !== false ) {
    function wp_text_diff( $left_string, $right_string, $args = null ) { 
    24592472        return $r;
    24602473}
    24612474endif;
    2462 
  • tests/phpunit/tests/mail.php

    diff --git tests/phpunit/tests/mail.php tests/phpunit/tests/mail.php
    index 5142c72..f541e50 100644
    class Tests_Mail extends WP_UnitTestCase { 
    307307
    308308                $this->assertNotContains( 'quoted-printable', $GLOBALS['phpmailer']->mock_sent[0]['header'] );
    309309        }
     310
     311        /**
     312         *
     313         */
     314        function test_wp_mail_multiline_header() {
     315                $headers = 'From: =?UTF-8?B?0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg?=';
     316                $headers .= "\n =?UTF-8?B?0YLQtdGB0YIg0YLQtdGB0YI=?= <test@example.com>";
     317                wp_mail( 'test@test.com', 'subject', 'message', $headers );
     318
     319                $mailer = tests_retrieve_phpmailer_instance();
     320                $this->assertEquals( 'test@example.com', $mailer->From );
     321                $this->assertEquals(
     322                        'тест тест тест тест тест тест тест',
     323                        $mailer->FromName
     324                );
     325        }
    310326}