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.
This commit is contained in:
Tim van der Meij 2021-08-01 12:11:10 +02:00
parent 222c9e7e84
commit 0d84f57cfa
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -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) {