@bobfrankston/iflow 1.0.44 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/imaplib/imap-protocol.js +17 -3
- package/package.json +1 -1
package/imaplib/imap-protocol.js
CHANGED
|
@@ -247,12 +247,26 @@ function decodeImapString(s) {
|
|
|
247
247
|
return "";
|
|
248
248
|
return s.replace(/=\?([^?]+)\?([BQ])\?([^?]+)\?=/gi, (_match, charset, encoding, text) => {
|
|
249
249
|
try {
|
|
250
|
+
const cs = charset.toLowerCase().replace(/^utf8$/, "utf-8");
|
|
250
251
|
if (encoding.toUpperCase() === "B") {
|
|
251
|
-
return Buffer.from(text, "base64").toString(
|
|
252
|
+
return Buffer.from(text, "base64").toString(cs);
|
|
252
253
|
}
|
|
253
254
|
else {
|
|
254
|
-
// Quoted-printable
|
|
255
|
-
|
|
255
|
+
// Quoted-printable: collect bytes then decode with charset
|
|
256
|
+
const decoded = text.replace(/_/g, " ");
|
|
257
|
+
const bytes = [];
|
|
258
|
+
let i = 0;
|
|
259
|
+
while (i < decoded.length) {
|
|
260
|
+
if (decoded[i] === "=" && i + 2 < decoded.length) {
|
|
261
|
+
bytes.push(parseInt(decoded.substring(i + 1, i + 3), 16));
|
|
262
|
+
i += 3;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
bytes.push(decoded.charCodeAt(i));
|
|
266
|
+
i++;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return Buffer.from(bytes).toString(cs);
|
|
256
270
|
}
|
|
257
271
|
}
|
|
258
272
|
catch {
|