Kaynağa Gözat

ignore invalid text

Gildas 7 yıl önce
ebeveyn
işleme
4d0fe3494e
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      lib/single-file/single-file-browser.js

+ 4 - 0
lib/single-file/single-file-browser.js

@@ -24,6 +24,7 @@ this.SingleFile = this.SingleFile || (() => {
 
 	const ONE_MB = 1024 * 1024;
 	const DEBUG = false;
+	const PREFIX_DATA_URI_TEXT = "data:text/";
 
 	// --------
 	// Download
@@ -102,6 +103,9 @@ this.SingleFile = this.SingleFile || (() => {
 					return "data:base64,";
 				}
 			} else {
+				if (!contentType.startsWith(PREFIX_DATA_URI_TEXT)) {
+					return "";
+				}
 				if (!charSet) {
 					const matchCharset = contentType && contentType.match(/\s*;\s*charset\s*=\s*"?([^";]*)"?(;|$)/i);
 					if (matchCharset && matchCharset[1] || options.charSet) {