Browse Source

abort operation if there are more than 1000 preserved tokens (perf issues)

Gildas 7 years ago
parent
commit
322e85be51
1 changed files with 4 additions and 0 deletions
  1. 4 0
      lib/single-file/vendor/css-minifier.js

+ 4 - 0
lib/single-file/vendor/css-minifier.js

@@ -737,6 +737,10 @@ this.cssMinifier = this.cssMinifier || (() => {
 		// trim the final string (for any leading or trailing white spaces)
 		content = content.replace(REGEXP_TRIM, "");
 
+		if (preservedTokens.length > 1000) {
+			return content;
+		}
+
 		// restore preserved tokens
 		for (let i = preservedTokens.length - 1; i >= 0; i--) {
 			content = content.replace(___PRESERVED_TOKEN_ + i + "___", preservedTokens[i], "g");