Skip to content

Commit 42a1358

Browse files
committed
Replace functionality with more-robust decoder.
1 parent 60a5eaf commit 42a1358

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

src/wp-includes/formatting.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,31 +3804,13 @@ function is_email( $email, $deprecated = false ) {
38043804
* Converts to ASCII from email subjects.
38053805
*
38063806
* @since 1.2.0
3807+
* @deprecated {WP_VERSION} Use {@see rfc2047_decode()}.
38073808
*
38083809
* @param string $subject Subject line.
38093810
* @return string Converted string to ASCII.
38103811
*/
38113812
function wp_iso_descrambler( $subject ) {
3812-
/* this may only work with iso-8859-1, I'm afraid */
3813-
if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $subject, $matches ) ) {
3814-
return $subject;
3815-
}
3816-
3817-
$subject = str_replace( '_', ' ', $matches[2] );
3818-
return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
3819-
}
3820-
3821-
/**
3822-
* Helper function to convert hex encoded chars to ASCII.
3823-
*
3824-
* @since 3.1.0
3825-
* @access private
3826-
*
3827-
* @param array $matches The preg_replace_callback matches array.
3828-
* @return string Converted chars.
3829-
*/
3830-
function _wp_iso_convert( $matches ) {
3831-
return chr( hexdec( strtolower( $matches[1] ) ) );
3813+
return rfc2047_decode( $subject );
38323814
}
38333815

38343816
/**

src/wp-mail.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@
124124
$subject = trim( $line );
125125
$subject = substr( $subject, 9, strlen( $subject ) - 9 );
126126
// Captures any text in the subject before $phone_delim as the subject.
127-
if ( function_exists( 'iconv_mime_decode' ) ) {
128-
$subject = iconv_mime_decode( $subject, 2, get_option( 'blog_charset' ) );
129-
} else {
130-
$subject = wp_iso_descrambler( $subject );
131-
}
127+
$subject = rfc2047_decode( $subject );
132128
$subject = explode( $phone_delim, $subject );
133129
$subject = $subject[0];
134130
}

0 commit comments

Comments
 (0)