Gildas před 7 roky
rodič
revize
d6238f586f

+ 5 - 1
lib/single-file/css-fonts-minifier.js

@@ -268,7 +268,11 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 	function getPropertyValue(cssRule, propertyName) {
 		const property = cssRule.block.children.filter(node => node.property == propertyName).tail;
 		if (property) {
-			return cssTree.generate(property.data.value);
+			try {
+				return cssTree.generate(property.data.value);
+			} catch (error) {
+				// ignored
+			}
 		}
 	}
 

+ 13 - 2
lib/single-file/single-file-core.js

@@ -1181,7 +1181,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				} else if (cssRule.type == "Atrule" && cssRule.name == "font-face") {
 					await Promise.all(cssRule.block.children.toArray().map(async declaration => {
 						if (declaration.type == "Declaration") {
-							const declarationValue = cssTree.generate(declaration.value);
+							let declarationValue = "";
+							try {
+								declarationValue = cssTree.generate(declaration.value);
+							} catch (error) {
+								// ignored
+							}
 							const urlFunctions = DomUtil.getUrlFunctions(declarationValue); // TODO: use OM
 							await Promise.all(urlFunctions.map(async urlFunction => {
 								const originalResourceURL = DomUtil.matchURL(urlFunction);
@@ -1197,7 +1202,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 											content = EMPTY_DATA_URI;
 										}
 										declaration.value.children.forEach(token => {
-											if (token.type == "Url" && DOM.removeQuotes(cssTree.generate(token.value, "value")) == originalResourceURL) {
+											let tokenValue = "";
+											try {
+												tokenValue = cssTree.generate(token.value);
+											} catch (error) {
+												// ignored
+											}
+											if (token.type == "Url" && DOM.removeQuotes(tokenValue == originalResourceURL) {
 												token.value.value = content;
 											}
 										});