Jelajahi Sumber

resolve script URLs

Gildas 7 tahun lalu
induk
melakukan
53d3415ebe
1 mengubah file dengan 7 tambahan dan 1 penghapusan
  1. 7 1
      lib/single-file/single-file-core.js

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

@@ -883,7 +883,13 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 		async processScripts() {
 			await Promise.all(Array.from(this.doc.querySelectorAll("script[src]")).map(async scriptElement => {
-				if (scriptElement.src) {
+				let resourceURL;
+				try {
+					resourceURL = DocUtil.resolveURL(scriptElement.src, this.baseURI);
+				} catch (error) {
+					// ignored
+				}
+				if (Util.testValidURL(resourceURL, this.baseURI, this.options.url)) {
 					this.stats.add("processed", "scripts", 1);
 					const content = await DocUtil.getContent(scriptElement.src, { asDataURI: false, maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled });
 					let scriptContent = content.data.replace(/<\//gi, "<\\/");