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

git-svn-id: http://svn.automattic.com/wordpress/trunk@907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
michelvaldrighi 2004-02-22 00:31:25 +00:00
parent 8091c63bff
commit a6165937b1
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; 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)) { if (preg_match('/Subject: /', $line)) {
$subject = trim($line); $subject = trim($line);
$subject = substr($subject, 9, strlen($subject)-9); $subject = substr($subject, 9, strlen($subject)-9);
if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $subject)) {
$subject = wp_iso_descrambler($subject);
}
if ($use_phoneemail) { if ($use_phoneemail) {
$subject = explode($phoneemail_separator, $subject); $subject = explode($phoneemail_separator, $subject);
$subject = trim($subject[0]); $subject = trim($subject[0]);