From 2ad1ca9b965dde32223bee28dc259c339cbaaa05 Mon Sep 17 00:00:00 2001 From: Yeting Li Date: Mon, 26 Apr 2021 14:26:52 +0800 Subject: [PATCH] Fix ReDoS in previous-map Fix Strategy: Replace `(.*)` with `(?:(?!sourceMappingURL=).)*` --- lib/previous-map.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/previous-map.js b/lib/previous-map.js index d9308ff26..4928e1c23 100644 --- a/lib/previous-map.js +++ b/lib/previous-map.js @@ -48,11 +48,11 @@ class PreviousMap { } getAnnotationURL(sourceMapString) { - return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\*\//)[1].trim() + return sourceMapString.match(/\/\*\s*# sourceMappingURL=((?:(?!sourceMappingURL=).)*)\*\//)[1].trim() } loadAnnotation(css) { - let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\*\//gm) + let annotations = css.match(/\/\*\s*# sourceMappingURL=(?:(?!sourceMappingURL=).)*\*\//gm) if (annotations && annotations.length > 0) { // Locate the last sourceMappingURL to avoid picking up