Bugfix: MIME parser RegExp didn't escape boundary which caused issues

This commit is contained in:
the-djmaze 2024-02-26 17:36:55 +01:00
parent 50569e1854
commit 7bc302c665
2 changed files with 8 additions and 1 deletions

View file

@ -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;