fixes to handle ISO-scrambled email subjects in wp-mail

git-svn-id: https://develop.svn.wordpress.org/trunk@907 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
michelvaldrighi 2004-02-22 00:31:25 +00:00
parent dff5381edd
commit 5c5ae0230a
2 changed files with 17 additions and 0 deletions

View File

@ -375,4 +375,18 @@ function strip_all_but_one_link($text, $mylink) {
return $text;
}
// used by wp-mail to handle charsets in email subjects
function wp_iso_descrambler($string) {
/* this may only work with iso-8859-1, I'm afraid */
if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
return $string;
} else {
$subject = str_replace('_', ' ', $matches[2]);
$subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
return $subject;
}
}
?>

View File

@ -73,6 +73,9 @@ for ($iCount=1; $iCount<=$Count; $iCount++) {
if (preg_match('/Subject: /', $line)) {
$subject = trim($line);
$subject = substr($subject, 9, strlen($subject)-9);
if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $subject)) {
$subject = wp_iso_descrambler($subject);
}
if ($use_phoneemail) {
$subject = explode($phoneemail_separator, $subject);
$subject = trim($subject[0]);