-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A valid JS code is considered as HTML comment #1837
Comments
This is the bundled code, which clearly strips the space between {
moduleFormat: 'getExport',
source: "function getExport() { 'use strict'; let exports = {}; const module = { exports }; 'use strict';\n" +
'\n' +
"Object.defineProperty(exports,'__esModule',{value:true});\n" +
'\n' +
'const _0n$6=0;\n' +
'\n' +
'function pow2(x,power,modulo){\n' +
'let res=x;\n' +
'while(power-->_0n$6){\n' +
'res*=res;\n' +
'res%=modulo;\n' +
'}\n' +
'return res;\n' +
'}\n' +
'\n' +
'exports.pow2=pow2;\n' +
'\n' +
'return module.exports;\n' +
'}\n' +
'//# sourceURL=/bundled-source/.../html_comment_code.js\n',
sourceMap: '//# sourceURL=/bundled-source/.../html_comment_code.js\n'
} |
The SES censor is working as expected. SES can’t parse JavaScript to distinguish HTML comments from the so-called “down-to operator” ( However, we’ve largely been able to compensate for the censor using an “evasive transform” in The
|
Notably, the evasive transform does not yet inject a space between The evasive transform also does not yet break up strings with |
I’ve reproduced this bug locally. Thank you for reporting! Steps to reproduce: (In
// html_comment_code.js
// That code is extracted from the big bundled package, so sorry for the variables names.
const _0n$6 = 0;
export function pow2(x, power, modulo) {
let res = x;
while (power-- > _0n$6) {
res *= res;
res %= modulo;
}
return res;
}
({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, importMeta: $h____meta, }) => (function () { $h_imports([]);Object.defineProperty(pow2, 'name', {value: "pow2"});$h_once.pow2(pow2); /* html_comment_code.js*/
/* That code is extracted from the big bundled package, so sorry for the variables names. */
const _0n$6=0;
function pow2(x,power,modulo){
let res=x;
while(power-->_0n$6){
res*=res;
res%=modulo;
}
return res;
}
})() |
A really satisfying solution to this problem would be to convince Babel to preserve the whitespace between But, an adequate mitigation for this specific case might be to augment |
That's not equivalent because the completion value of |
I like it! |
I do not understand. My understanding of the comma operator is that the completion value is the completion value of the final expression. What am I missing? [edit]: Confirmed difference in behavior. I seem to be oblivious of a JavaScript complication to how expressions are traced and when values are captured from identifiers. [edit]: Nope. I’d simply forgotten what @erights states below. |
I think the term "completion value" may be causing confusion. In |
closes: #XXXX refs: endojs/endo#1837 7accc02 #9112 https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md ## Description A patch introduced in at 7accc02 in #9112 patched https://www.npmjs.com/package/bn.js/v/5.1.2 to work around the bug explained at endojs/endo#1837 . However, the fix followed the advice at endojs/endo#1837 (comment) , which is wrong for the reasons explained at endojs/endo#1837 (comment) . - wrong: rewrite `x-- > y` as `(x--, x > y)` This PR fixes that mistake by instead using the technique @gibson042 suggests at endojs/endo#1837 (comment) - correct: rewrite `x-- > y` as `[x--][0] > y` ### Security Considerations fixes an integrity bug. I have no idea how significant this bug was. ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations none ### Upgrade Considerations Well, it is a change. But I have no idea what the patched library was used for, so cannot evaluate.
closes: #XXXX refs: endojs/endo#1837 7accc02 #9112 https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md ## Description A patch introduced in at 7accc02 in #9112 patched https://www.npmjs.com/package/bn.js/v/5.1.2 to work around the bug explained at endojs/endo#1837 . However, the fix followed the advice at endojs/endo#1837 (comment) , which is wrong for the reasons explained at endojs/endo#1837 (comment) . - wrong: rewrite `x-- > y` as `(x--, x > y)` This PR fixes that mistake by instead using the technique @gibson042 suggests at endojs/endo#1837 (comment) - correct: rewrite `x-- > y` as `[x--][0] > y` ### Security Considerations fixes an integrity bug. I have no idea how significant this bug was. ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations none ### Upgrade Considerations Well, it is a change. But I have no idea what the patched library was used for, so cannot evaluate.
Describe the bug
I am trying out a big bundled JS code in SES and faced with following error:
The file contains valid JS code, apparently it seems that SES is considering a specific JS expression as HTML comment.
Steps to reproduce
Here is the code which I am trying to execute above in SES:
Expected behavior
This code is simple JS expression and should work well in SES.
Platform environment
Additional context
Screenshots
The text was updated successfully, but these errors were encountered: