Keep the charset label for 7-bit ISO-2022 header values

encodeHeader() fell back to us-ascii for any header value without 8-bit
chars, which mislabelled ISO-2022-JP text. Values containing ESC escape
sequences now keep the message charset.

Fixes #2185
This commit is contained in:
dualfroz committed 2026-10-14 18:51:49 +02:00
1 parent 4ce8260f80
commit 5f8d078d57
2 files changed
+74 -1

No files matched your search

+2 -1
View File
@@ -3768,7 +3768,8 @@ class PHPMailer
break;
}
if ($this->has8bitChars($str)) {
//ISO-2022 charsets such as ISO-2022-JP are 7-bit, but text using their escape sequences isn't us-ascii
if ($this->has8bitChars($str) || strpos($str, "\x1B") !== false) {
$charset = $this->CharSet;
} else {
$charset = static::CHARSET_ASCII;