Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

"<>=&" is compiled to "\x3c\x3e\x3d\x26" #79

Closed
leeoniya opened this issue Oct 25, 2017 · 6 comments
Closed

"<>=&" is compiled to "\x3c\x3e\x3d\x26" #79

leeoniya opened this issue Oct 25, 2017 · 6 comments

Comments

@leeoniya
Copy link

probably missing some other entities here, too. this does not happen in the Java version.

test code:

const closure = require('google-closure-compiler-js').compile;

var test = 'var x = "<>=&";';

const flags = {
  jsCode: [{src: test}],
  languageIn: 'ECMASCRIPT5_STRICT',
  languageOut: 'ECMASCRIPT5',
  compilationLevel: 'SIMPLE',
};

var compiled = closure(flags).compiledCode;

console.log(compiled);       // var x="\x3c\x3e\x3d\x26";
@MatrixFrog
Copy link
Contributor

IIRC this is the "trustedStrings" option. https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/CompilerOptions.java#L988

We can probably turn it on by default for the JS version.

@leeoniya
Copy link
Author

leeoniya commented Oct 31, 2017

hmm, thanks. i'll try that...unless it's not available in the js version?

FWIW the java version did also encode angle brackets but only if they were part of an html comment in a string: "<!-- foo -->" -> "\x3c!-- foo --\x3e". i dont believe this is technically necessary either. (unlike escaping / in "</script>".

@ChadKillingsworth
Copy link
Collaborator

The trusted strings option is now set. Deployment has moved to https://github.com/google/closure-compiler-npm

@leeoniya
Copy link
Author

awesome, thanks!

any idea when this will trickle down to https://www.npmjs.com/package/google-closure-compiler-js ?

@ChadKillingsworth
Copy link
Collaborator

It won't. All development has moved to the main package.

@leeoniya
Copy link
Author

sorry, misunderstood. thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants