From 0d84f57cfad05cdb032404cb95177d843fa01026 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 1 Aug 2021 12:11:10 +0200 Subject: [PATCH] Fix inefficient regular expressions in `external/cmapscompress/parse.js` The only purpose, according to the README and existing files, is to parse an integer from those lines, so (\d+) is sufficient for that. This avoids potential exponential backtracking as flagged by CodeQL. I have compared the output of the script with and without these changes and the resulting files are the same. --- external/cmapscompress/parse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/cmapscompress/parse.js b/external/cmapscompress/parse.js index 7850f6946..5978d7f93 100644 --- a/external/cmapscompress/parse.js +++ b/external/cmapscompress/parse.js @@ -28,9 +28,9 @@ exports.parseAdobeCMap = function (content) { usecmap: null, body: [], }; - m = /\/CMapType\s+(\d+)+\s+def\b/.exec(body); + m = /\/CMapType\s+(\d+)\s+def\b/.exec(body); result.type = +m[1]; - m = /\/WMode\s+(\d+)+\s+def\b/.exec(body); + m = /\/WMode\s+(\d+)\s+def\b/.exec(body); result.wmode = +m[1]; m = /\/([\w-]+)\s+usecmap\b/.exec(body); if (m) {