Fix an instance of "Polynomial regular expression used on uncontrolled data".

This commit is contained in:
David Anson 2022-01-20 19:54:12 -08:00
parent a4c4e198d6
commit b6121341b9
2 changed files with 2 additions and 2 deletions

View file

@ -2979,7 +2979,7 @@ module.exports = {
var trailingPunctuationRe = new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
forEachHeading(params, function (heading) {
var line = heading.line, lineNumber = heading.lineNumber;
var trimmedLine = line.replace(/[\s#]*$/, "");
var trimmedLine = line.replace(/([^\s#])[\s#]+$/, "$1");
var match = trailingPunctuationRe.exec(trimmedLine);
if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) {
var fullMatch = match[0];

View file

@ -20,7 +20,7 @@ module.exports = {
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
forEachHeading(params, (heading) => {
const { line, lineNumber } = heading;
const trimmedLine = line.replace(/[\s#]*$/, "");
const trimmedLine = line.replace(/([^\s#])[\s#]+$/, "$1");
const match = trailingPunctuationRe.exec(trimmedLine);
if (match && !endOfLineHtmlEntityRe.test(trimmedLine)) {
const fullMatch = match[0];