Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit cae0c94

Browse files
committed
Fix for inline scripts that contain non-latin characters.
1 parent 4b665d6 commit cae0c94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Parser.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,15 @@ function nodeIsImport(elt) {
213213
}
214214

215215
function generateScriptDataUrl(script) {
216-
var scriptContent = generateScriptContent(script);
217-
return 'data:text/javascript;base64,' + btoa(scriptContent);
216+
var scriptContent = generateScriptContent(script), b64;
217+
try {
218+
b64 = btoa(scriptContent);
219+
} catch(e) {
220+
b64 = btoa(unescape(encodeURIComponent(scriptContent)));
221+
console.warn('Script contained non-latin characters that were forced ' +
222+
'to latin. Some characters may be wrong.', script);
223+
}
224+
return 'data:text/javascript;base64,' + b64;
218225
}
219226

220227
function generateScriptContent(script) {

0 commit comments

Comments
 (0)