Sfoglia il codice sorgente

fixed content type check

Gildas 7 anni fa
parent
commit
f3a5e47ab3

+ 1 - 1
lib/single-file/single-file-browser.js

@@ -103,7 +103,7 @@ this.SingleFile = this.SingleFile || (() => {
 					return "data:base64,";
 				}
 			} else {
-				if (!contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT)) {
+				if (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT)) {
 					return "";
 				}
 				if (!charSet) {

+ 1 - 1
lib/single-file/single-file-core.js

@@ -1006,7 +1006,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 					if (!DomUtil.testIgnoredPath(resourceURL) && DomUtil.testValidPath(resourceURL, baseURI, options.url)) {
 						resourceURL = new URL(match.resourceURL, baseURI).href;
 						if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
-							const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled };
+							const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true };
 							let importedStylesheetContent = await Download.getContent(resourceURL, downloadOptions);
 							importedStylesheetContent = DomUtil.wrapMediaQuery(importedStylesheetContent, match.media);
 							if (stylesheetContent.includes(cssImport)) {