Ticket #1485151: tspecials.patch
| File tspecials.patch, 1.5 kB (added by arekm, 3 months ago) |
|---|
-
program/lib/Mail/mimePart.php
398 398 //is not any of the defaults, we need to encode the value. 399 399 $shouldEncode = 0; 400 400 $secondAsterisk = ''; 401 if (preg_match('#([ \x80-\xFF \*\'\\%\t(\)\<\>\@\,\;\:\\\"/\[\]\?\=]){1}#', $value)) {401 if (preg_match('#([\x80-\xFF]){1}#', $value)) { 402 402 $shouldEncode = 1; 403 403 } elseif ($charset && (strtolower($charset) != 'us-ascii')) { 404 404 $shouldEncode = 1; … … 406 406 $shouldEncode = 1; 407 407 } 408 408 if ($shouldEncode) { 409 $encValue = preg_replace('#([\x80-\xFF \*\'\%\t\(\)\<\>\@\,\;\:\\\"/\[\]\?\=])#e', '"%" . strtoupper(dechex(ord("\1")))', $value); 409 $search = array('%', ' ', "\t"); 410 $replace = array('%25', '%20', '%09'); 411 $encValue = str_replace($search, $replace, $value); 412 $encValue = preg_replace('#([\x80-\xFF])#e', '"%" . strtoupper(dechex(ord("\1")))', $encValue); 410 413 $value = "$charset'$language'$encValue"; 411 414 $secondAsterisk = '*'; 412 } 415 } else { 416 $value = preg_replace('#([\(\)\<\>\@\,\;\:\\\"\/\[\[\?\=])#', '\\\\\\1', $value); 417 } 413 418 $header = " {$name}{$secondAsterisk}=\"{$value}\"; "; 414 419 if (strlen($header) <= $maxLength) { 415 420 return $header;
