more module updates
This commit is contained in:
@@ -1741,27 +1741,41 @@ class PHPMailer {
|
||||
*/
|
||||
public function EncodeQ($str, $position = 'text') {
|
||||
// There should not be any EOL in the string
|
||||
$encoded = preg_replace('/[\r\n]*/', '', $str);
|
||||
|
||||
$pattern = '';
|
||||
$encoded = str_replace(array("\r", "\n"), '', $str);
|
||||
switch (strtolower($position)) {
|
||||
case 'phrase':
|
||||
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
// RFC 2047 section 5.3
|
||||
$pattern = '^A-Za-z0-9!*+\/ -';
|
||||
break;
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'comment':
|
||||
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
// RFC 2047 section 5.2
|
||||
$pattern = '\(\)"';
|
||||
// intentional fall-through
|
||||
// for this reason we build the $pattern without including delimiters and []
|
||||
case 'text':
|
||||
default:
|
||||
// Replace every high ascii, control =, ? and _ characters
|
||||
//TODO using /e (equivalent to eval()) is probably not a good idea
|
||||
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
|
||||
"'='.sprintf('%02X', ord('\\1'))", $encoded);
|
||||
// RFC 2047 section 5.1
|
||||
// Replace every high ascii, control, =, ? and _ characters
|
||||
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
|
||||
break;
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
|
||||
// If the string contains an '=', make sure it's the first thing we replace
|
||||
// so as to avoid double-encoding
|
||||
$s = array_search('=', $matches[0]);
|
||||
if ($s !== false) {
|
||||
unset($matches[0][$s]);
|
||||
array_unshift($matches[0], '=');
|
||||
}
|
||||
foreach (array_unique($matches[0]) as $char) {
|
||||
$encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
|
||||
}
|
||||
}
|
||||
// Replace every spaces to _ (more readable than =20)
|
||||
$encoded = str_replace(' ', '_', $encoded);
|
||||
|
||||
return $encoded;
|
||||
return str_replace(' ', '_', $encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user