From 2d5b4160ad0417e9821e06e467281ca5674deef3 Mon Sep 17 00:00:00 2001 From: Balearica Date: Tue, 2 Jan 2024 03:00:22 -0800 Subject: [PATCH] Made regex quantifier lazy to resolve #381 (#1349) Co-authored-by: Your Name --- lib/image.js | 2 +- lib/mixins/attachments.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/image.js b/lib/image.js index e219db8c9..416664d29 100644 --- a/lib/image.js +++ b/lib/image.js @@ -16,7 +16,7 @@ class PDFImage { data = Buffer.from(new Uint8Array(src)); } else { let match; - if ((match = /^data:.+;base64,(.*)$/.exec(src))) { + if ((match = /^data:.+?;base64,(.*)$/.exec(src))) { data = Buffer.from(match[1], 'base64'); } else { data = fs.readFileSync(src); diff --git a/lib/mixins/attachments.js b/lib/mixins/attachments.js index ef245d3da..862fd9a85 100644 --- a/lib/mixins/attachments.js +++ b/lib/mixins/attachments.js @@ -32,7 +32,7 @@ export default { data = Buffer.from(new Uint8Array(src)); } else { let match; - if ((match = /^data:(.*);base64,(.*)$/.exec(src))) { + if ((match = /^data:(.*?);base64,(.*)$/.exec(src))) { if (match[1]) { refBody.Subtype = match[1].replace('/', '#2F'); }