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

Commit

Permalink
Fix for inline scripts that contain non-latin characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Feb 24, 2014
1 parent 4b665d6 commit cae0c94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,15 @@ function nodeIsImport(elt) {
}

function generateScriptDataUrl(script) {
var scriptContent = generateScriptContent(script);
return 'data:text/javascript;base64,' + btoa(scriptContent);
var scriptContent = generateScriptContent(script), b64;
try {
b64 = btoa(scriptContent);
} catch(e) {
b64 = btoa(unescape(encodeURIComponent(scriptContent)));
console.warn('Script contained non-latin characters that were forced ' +
'to latin. Some characters may be wrong.', script);
}
return 'data:text/javascript;base64,' + b64;
}

function generateScriptContent(script) {
Expand Down

0 comments on commit cae0c94

Please sign in to comment.