node_modules: update (#349)

Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
Dawid Dziurlaanddawidd6 authored and GitHub committed 2026-10-18 15:39:30 +02:00
1 parent 9d0c26ec8b
commit 0a1f5db16c
36 files changed
+1934 -648

No files matched your search

+25 -13
View File
@@ -137,26 +137,38 @@ export function encodeWord(data, mimeWordEncoding, maxLength) {
*/
export function encodeWords(value, mimeWordEncoding, maxLength, encodeAll) {
maxLength = maxLength || 0;
// find first word with a non-printable ascii or special symbol in it
const firstMatch = value.match(/(?:^|\s)([^\s]*["\u0080-\uFFFF])/);
if (!firstMatch) {
// find the first and the last character that needs encoding, a quote or anything outside
// printable ascii. A scan rather than a regex: matching the last such word with a
// backtracking pattern took quadratic time on a long word of non-ascii characters
let firstSpecial = -1;
let lastSpecial = -1;
for (let i = 0; i < value.length; i++) {
const code = value.charCodeAt(i);
if (code === 0x22 || code >= 0x80) {
if (firstSpecial < 0) {
firstSpecial = i;
}
lastSpecial = i;
}
}
if (firstSpecial < 0) {
return value;
}
if (encodeAll) {
// if it is requested to encode everything or the string contains something that resebles encoded word, then encode everything
return encodeWord(value, mimeWordEncoding, maxLength);
}
// find the last word with a non-printable ascii in it
const lastMatch = value.match(/(["\u0080-\uFFFF][^\s]*)[^"\u0080-\uFFFF]*$/);
if (!lastMatch) {
// should not happen
return value;
// encode from the start of the word holding the first such character to the end of the
// word holding the last one, so the encoded words stay separated from the plain text by
// the whitespace that was already there
let startIndex = firstSpecial;
while (startIndex > 0 && !/\s/.test(value.charAt(startIndex - 1))) {
startIndex--;
}
let endIndex = lastSpecial + 1;
while (endIndex < value.length && !/\s/.test(value.charAt(endIndex))) {
endIndex++;
}
const startIndex = firstMatch.index +
(firstMatch[0].match(/[^\s]/) || {
index: 0
}).index;
const endIndex = lastMatch.index + (lastMatch[1] || '').length;
return ((startIndex ? value.substr(0, startIndex) : '') +
encodeWord(value.substring(startIndex, endIndex), mimeWordEncoding || 'Q', maxLength) +
(endIndex < value.length ? value.substr(endIndex) : ''));