Skip to content

Commit 8634bda

Browse files
committed
Rename and add test cases
1 parent d5011a6 commit 8634bda

File tree

4 files changed

+539
-19
lines changed

4 files changed

+539
-19
lines changed

src/wp-includes/formatting.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,13 +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()}.
3808-
*
38093807
* @param string $subject Subject line.
38103808
* @return string Converted string to ASCII.
3809+
*@deprecated {WP_VERSION} Use {@see wp_decode_rfc2047()}.
3810+
*
38113811
*/
38123812
function wp_iso_descrambler( $subject ) {
3813-
return rfc2047_decode( $subject );
3813+
return wp_decode_rfc2047( $subject );
38143814
}
38153815

38163816
/**

src/wp-includes/rfc2047-mime.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121
* Example:
2222
*
2323
* // Quoted forms have non-printable ASCII encoded as octets.
24-
* 'this is some text' === rfc2047_decode( '=?iso-8859-1?q?this=20is_some=20text?=' );
25-
* '👌' === rfc2047_decode( '=?utf-8?q?=F0=9F=91=8C?=' );
24+
* 'this is some text' === wp_decode_rfc2047( '=?iso-8859-1?q?this=20is_some=20text?=' );
25+
* '👌' === wp_decode_rfc2047( '=?utf-8?q?=F0=9F=91=8C?=' );
2626
*
2727
* // Binary forms are base64-encoded.
28-
* '👌' === rfc2047_decode( '=?utf-8?B??=8J+RjA==?=' );
29-
* 'םולש ןב ילטפנ' === rfc2047_decode( '=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=' );
28+
* '👌' === wp_decode_rfc2047( '=?utf-8?B??=8J+RjA==?=' );
29+
* 'םולש ןב ילטפנ' === wp_decode_rfc2047( '=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=' );
3030
*
3131
* // Character sets are re-encoded into UTF-8
32-
* '100¥' === rfc2047_decode( '=?iso-8859-1?Q?500=A5?=' );
33-
* '🏴󠁧󠁢󠁥󠁮󠁧󠁿' === rfc2047_decode( '=?GB-18030?Q?=949=C82=D36=A01=D36=9F6=D36=9F9=D36=A08=D36=A01=D36=A25?=' );
32+
* '100¥' === wp_decode_rfc2047( '=?iso-8859-1?Q?500=A5?=' );
33+
* '🏴󠁧󠁢󠁥󠁮󠁧󠁿' === wp_decode_rfc2047( '=?GB-18030?Q?=949=C82=D36=A01=D36=9F6=D36=9F9=D36=A08=D36=A01=D36=A25?=' );
3434
*
3535
* // Linear white-space is collapsed.
36-
* 'ab c d e' === rfc2047_decode( '=?ASCII?Q?a?= =?ASCII?Q?b?= c d=?ASCII?Q?=20?==?ASCII?Q?e?=' )
36+
* 'ab c d e' === wp_decode_rfc2047( '=?ASCII?Q?a?= =?ASCII?Q?b?= c d=?ASCII?Q?=20?==?ASCII?Q?e?=' )
3737
*
3838
* // Error-handling is up to the call site.
39-
* '=?UTF-8?Q?=6f?=' === rfc2047_decode( '=?UTF-8?Q?=6f?=' );
40-
* '=?UTF-8?Q?=6f?=' === rfc2047_decode( '=?UTF-8?Q?=6f?=', 'preserve-errors' );
41-
* '�' === rfc2047_decode( '=?UTF-8?Q?=6f?=', 'replace-errors' );
42-
* null === rfc2047_decode( '=?UTF-8?Q?=6f?=', 'bail-on-error' );
39+
* '=?UTF-8?Q?=6f?=' === wp_decode_rfc2047( '=?UTF-8?Q?=6f?=' );
40+
* '=?UTF-8?Q?=6f?=' === wp_decode_rfc2047( '=?UTF-8?Q?=6f?=', 'preserve-errors' );
41+
* '�' === wp_decode_rfc2047( '=?UTF-8?Q?=6f?=', 'replace-errors' );
42+
* null === wp_decode_rfc2047( '=?UTF-8?Q?=6f?=', 'bail-on-error' );
4343
*
4444
* // Invalid character encodings are errors.
45-
* null === rfc2047_decode( '=?UTF-8?Q?=C0?=', 'bail-on-error' );
45+
* null === wp_decode_rfc2047( '=?UTF-8?Q?=C0?=', 'bail-on-error' );
4646
*
4747
* @see https://www.rfc-editor.org/rfc/rfc2047
4848
*
@@ -53,10 +53,10 @@
5353
* Default is to preserve invalid encoded words as plaintext.
5454
* @return string Decoded string in UTF-8, if supported, else `null`.
5555
*/
56-
function rfc2047_decode( $encoded, $errors = 'preserve-errors' ) {
56+
function wp_decode_rfc2047( $encoded, $errors = 'preserve-errors' ) {
5757
/**
5858
* {@see iconv_mime_decode()} which does not give control over error-handling
59-
* at the granularity necessary for this decoder..
59+
* at the granularity necessary for this decoder.
6060
*/
6161

6262
$decoded = '';
@@ -237,7 +237,7 @@ function ( $matches ) use ( &$failed_decode ) {
237237
}
238238

239239
// Verify the encoding.
240-
if ( false === $decoded_chunk || ! seems_utf8( $decoded_chunk ) ) {
240+
if ( false === $decoded_chunk || ! wp_is_valid_utf8( $decoded_chunk ) ) {
241241
goto handle_invalid;
242242
}
243243

src/wp-mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +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-
$subject = rfc2047_decode( $subject );
127+
$subject = wp_decode_rfc2047( $subject );
128128
$subject = explode( $phone_delim, $subject );
129129
$subject = $subject[0];
130130
}

0 commit comments

Comments
 (0)