\8 and \9 should be forbidden in strict mode strings and in template literals
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox88 | --- | fixed |
People
(Reporter: Waldo, Assigned: obsu)
References
(Blocks 1 open bug, )
Details
Attachments
(1 file, 1 obsolete file)
Specs used to be maybe ambiguous on this, or permissive if it was allowed, but that got changed recently.
Reporter | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
Hi, can I take this up?
I am a beginner and have come here after watching compiler compiler series.
I tried to understand the code and am guessing the following should be done for fix
- Create new error string - JSMSG_DEPRECATED_NON_OCTAL_DECIMAL - 'non octal decimal sequences are deprecated' (in ErrorNumbers.msg)
- Create new InvalidEscapeToken type NonOctalDecimal (https://searchfox.org/mozilla-central/source/js/src/frontend/TokenStream.h#528)
- Handle NonOctalDecimal case in reportInvalidEscapeError (https://searchfox.org/mozilla-central/source/js/src/frontend/TokenStream.h#2548)
- Handle it at getStringOrTemplateToken (https://searchfox.org/mozilla-central/source/js/src/frontend/TokenStream.cpp#3647)
- If template literal, setInvalidTemplateEscape to NonOctalDecimal
- call strictModeError with JSMSG_DEPRECATED_NON_OCTAL_DECIMAL and return false if in strict mode(i.e. strictModeError() returns 0)
- Remove skipped tests in jstests.list (https://searchfox.org/mozilla-central/source/js/src/tests/jstests.list#142)
If anyone can check and tell if the approach is correct, I would be happy to submit a patch. TIA
Comment 2•4 years ago
|
||
Just repeating what I mentioned in element chat. I am not the expert in this but the general approach looks good. Happy to review.
By the way, since our searchfox source directory points to the head of the tree, links that are not permalinks might get out of date. You can make sure links are always pointing where you intend by clicking on the "permalink" in the right menu in searchfox.
Thanks for taking this on!
Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
Thanks for your help.
I have submitted a patch and I was able to pass jit-test and jstests on my machine.
A couple of points
- Changed strings from NON_OCTAL_DECIMAL to LEGACY_OCTAL as test262 test case refers this case as 'invalid legacy octal'
- Whitespace changes in TokenStream.h & TokenStream.cpp got autoadded by "hg commit". Not sure what is the expected behaviour, so left it as it is.
- Tried adding r=yulia,waldo & r=yulia,Waldo, but got error saying "waldo is not a valid reviewer's name"
Reporter | ||
Comment 5•4 years ago
|
||
I'm pretty sure you'd want "jwalden" for reviewing, if you wanted to tag me.
I'm taking a look now because I've got a few (a few) minutes immediately. Not sure whether it'll blossom far enough to be a full review. (And my queue is backed up with Intl stuff, so it's a question of propriety just how much I ought let a short patch like this jump over other entries. :-) )
Reporter | ||
Comment 6•4 years ago
|
||
Looks like it did blossom into a full review. Thanks for the patch, it's 90% there and 90% good, just needs a slight bit more to push it across the finish line. :-)
Reporter | ||
Comment 7•4 years ago
|
||
Oh, for "Changed strings from NON_OCTAL_DECIMAL to LEGACY_OCTAL as test262 test case refers this case as 'invalid legacy octal'" -- "NonOctalDecimalEscapeSequence" is I suppose technically the bestest term for this, because it's what the spec uses for the relevant terminal. (The test262 case is likely some sort of copypasta, maybe misleading. Or it could be a generated testcase that as consequence just happens to have skew comments in it in some cases.) But I think the spec language is probably less readable than literally just saying the two possible characters, here, from the point of view of the developer reading this code. (And certainly for any web developer who inadvertently invokes this.)
Updated•4 years ago
|
Assignee | ||
Comment 8•4 years ago
|
||
I have raised issue at test262 - (link) for the preceding strict case. I have made the changes requested and have submitted again. Thanks for taking time out to review despite a busy schedule :)
Assignee | ||
Comment 9•3 years ago
|
||
Updated•3 years ago
|
Comment 10•3 years ago
|
||
Hey! This patch failed to land, because it didn't apply cleanly. Would you mind rebasing?
Updated•3 years ago
|
Comment 12•3 years ago
|
||
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/2b7df5f4ad70 Forbid \8 and \9 in strict mode strings and template literals. r=jwalden
Comment 13•3 years ago
|
||
Backed out for bustage on TokenStream.h
backout: https://hg.mozilla.org/integration/autoland/rev/6ef0888cb89aa1daf428ceb1d0e5c4a088482339
failure log: https://treeherder.mozilla.org/logviewer?job_id=331115208&repo=autoland&lineNumber=1232
[task 2021-02-25T00:08:12.049Z] In file included from /builds/worker/checkouts/gecko/js/src/frontend/SyntaxParseHandler.h:19:0,
[task 2021-02-25T00:08:12.049Z] from /builds/worker/checkouts/gecko/js/src/frontend/Parser.h:190,
[task 2021-02-25T00:08:12.049Z] from /builds/worker/checkouts/gecko/js/src/debugger/Debugger.cpp:44,
[task 2021-02-25T00:08:12.049Z] from Unified_cpp_js_src_debugger0.cpp:11:
[task 2021-02-25T00:08:12.049Z] /builds/worker/checkouts/gecko/js/src/frontend/TokenStream.h:271:44: error: 'js::frontend::TokenStreamFlags::sawDeprecatedContent' is too small to hold all values of 'enum class js::frontend::DeprecatedContent' [-Werror]
[task 2021-02-25T00:08:12.049Z] DeprecatedContent sawDeprecatedContent : 2;
[task 2021-02-25T00:08:12.049Z] ^
Comment 14•3 years ago
|
||
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b200811e596b Forbid \8 and \9 in strict mode strings and template literals. r=jwalden
Assignee | ||
Comment 15•3 years ago
|
||
Hi evilpie, I got to see your comment too late. Apologies and thanks for landing it!
Comment 16•3 years ago
|
||
bugherder |
Comment 17•3 years ago
|
||
No problems, thanks for providing a patch!
Description
•