Преглед изворни кода

fixed charset issue when embedding scripts

Former-commit-id: 6b8c8150707234378a398e20279100abe13768aa
Gildas пре 5 година
родитељ
комит
6c5e1a704d
2 измењених фајлова са 2 додато и 1 уклоњено
  1. 1 0
      lib/single-file/single-file-core.js
  2. 1 1
      lib/single-file/single-file-util.js

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

@@ -1172,6 +1172,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					this.stats.add("processed", "scripts", 1);
 					const content = await util.getContent(resourceURL, {
 						asBinary: true,
+						charset: this.charset != "utf-8" && this.charset,
 						maxResourceSize: this.options.maxResourceSize,
 						maxResourceSizeEnabled: this.options.maxResourceSizeEnabled,
 						frameId: this.options.windowId

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

@@ -261,7 +261,7 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
 							return { data: "data:null;base64,", resourceURL };
 						} else {
 							const reader = new FileReader();
-							reader.readAsDataURL(new Blob([buffer], { type: contentType }));
+							reader.readAsDataURL(new Blob([buffer], { type: contentType + (options.charset ? ";charset=" + options.charset : "") }));
 							const dataUri = await new Promise((resolve, reject) => {
 								reader.addEventListener("load", () => resolve(reader.result), false);
 								reader.addEventListener("error", reject, false);