summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Component/Utility/Unicode.php
diff options
context:
space:
mode:
authorLee Rowlands2017-12-07 21:48:00 (GMT)
committerLee Rowlands2017-12-07 21:48:00 (GMT)
commit66fc18077a8338983f6aea1fe4ec6ddba7cfde70 (patch)
tree8527924bf02a4fd67546be87340850da48d374a9 /core/lib/Drupal/Component/Utility/Unicode.php
parent8203805823b71d1cbafbeef5f59f153efa6b12da (diff)
Issue #2717965 by Yogesh Pawar, pguillard, alexpott, Liam Morland, skylord, oxy86, cilefen, balagan, Anthony Fok: Site name is not UTF-8 encoded in email headers
Diffstat (limited to 'core/lib/Drupal/Component/Utility/Unicode.php')
-rw-r--r--core/lib/Drupal/Component/Utility/Unicode.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php
index b222f78..f8e026f 100644
--- a/core/lib/Drupal/Component/Utility/Unicode.php
+++ b/core/lib/Drupal/Component/Utility/Unicode.php
@@ -603,11 +603,13 @@ EOD;
*
* @param string $string
* The header to encode.
+ * @param bool $shorten
+ * If TRUE, only return the first chunk of a multi-chunk encoded string.
*
* @return string
* The mime-encoded header.
*/
- public static function mimeHeaderEncode($string) {
+ public static function mimeHeaderEncode($string, $shorten = FALSE) {
if (preg_match('/[^\x20-\x7E]/', $string)) {
// floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$chunk_size = 47;
@@ -616,6 +618,9 @@ EOD;
while ($len > 0) {
$chunk = static::truncateBytes($string, $chunk_size);
$output .= ' =?UTF-8?B?' . base64_encode($chunk) . "?=\n";
+ if ($shorten) {
+ break;
+ }
$c = strlen($chunk);
$string = substr($string, $c);
$len -= $c;