diff --git a/dev/Mime/Parser.js b/dev/Mime/Parser.js index 91e744add..2816d07a3 100644 --- a/dev/Mime/Parser.js +++ b/dev/Mime/Parser.js @@ -175,7 +175,7 @@ export function ParseMime(text) let boundary = headers['content-type']?.params.boundary; if (boundary) { part.boundary = boundary; - let regex = new RegExp('(?:^|\r?\n)--' + boundary + '(?:--)?(?:\r?\n|$)', 'g'), + let regex = new RegExp('(?:^|\r?\n)--' + RegExp.escape(boundary) + '(?:--)?(?:\r?\n|$)', 'g'), body = mimePart.slice(head.length), bodies = body.split(regex), pos = part.bodyStart; diff --git a/dev/prototype.js b/dev/prototype.js index 8e106d0a1..f8b74e92b 100644 --- a/dev/prototype.js +++ b/dev/prototype.js @@ -44,6 +44,13 @@ return template.content.firstChild; }; + /** + * https://github.com/tc39/proposal-regex-escaping + */ + if (!RegExp.escape){ + RegExp.escape = s => String(s).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); + } + /** * Every time the function is executed, * it will delay the execution with the given amount of milliseconds.