Unterminated string constant error when pretty printing html source in Debugger
Categories
(DevTools :: Source Editor, defect, P2)
Tracking
(firefox145 fixed)
| Tracking | Status | |
|---|---|---|
| firefox145 | --- | fixed |
People
(Reporter: martins.mozeiko, Assigned: bomsy)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 external file, 6 obsolete files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0
Steps to reproduce:
I'm using Firefox v142 on Windows 11.
- Go to https://h4x0r.org/ website
- Open Web Developer Tools
- Select Debugger tab and choose "(index)" document
- Press "Pretty print source"
Actual results:
Firefox shows this:
Error loading this URI: Unterminated string constant (7:910)
Stack in the worker:requireAcorn/</pp$4.raise@resource://devtools/client/debugger/dist/pretty-print-worker.js:7206:21
requireAcorn/</pp.readString@resource://devtools/client/debugger/dist/pretty-print-worker.js:9042:55
requireAcorn/</pp.getTokenFromCode@resource://devtools/client/debugger/dist/pretty-print-worker.js:8837:25
requireAcorn/</pp.readToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8561:23
requireAcorn/</pp.nextToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8552:23
requireAcorn/</pp.next@resource://devtools/client/debugger/dist/pretty-print-worker.js:8513:16
requireAcorn/</pp.getToken@resource://devtools/client/debugger/dist/pretty-print-worker.js:8517:16
#getTokens@resource://devtools/client/debugger/dist/pretty-print-worker.js:9752:29
getPrettifiedCodeAndSourceMap@resource://devtools/client/debugger/dist/pretty-print-worker.js:9580:43
prettyFast@resource://devtools/client/debugger/dist/pretty-print-worker.js:9366:38
prettyPrintInlineScript@resource://devtools/client/debugger/dist/pretty-print-worker.js:10617:34
requireWorkerUtils/workerHandler/</<@resource://devtools/client/debugger/dist/pretty-print-worker.js:3691:58
requireWorkerUtils/workerHandler/<@resource://devtools/client/debugger/dist/pretty-print-worker.js:3689:19
Expected results:
I expected html pretty printed.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•1 year ago
|
Comment 2•1 year ago
|
||
Reproducible locally with the same HTML source, will simplify the test case. Thanks for the report.
Comment 3•1 year ago
|
||
Fails with
Error loading this URI: Unterminated template (1:15)
Comment 4•1 year ago
|
||
Fails with
Error loading this URI: Unterminated string constant (1:14)
Comment 5•1 year ago
|
||
I tried updating acorn to the latest, it fixed some intermediary issues, but the two uploaded above still fail. Maybe we should report them upstream?
Bomsy: do you know of similar issues with the pretty print worker?
Comment 6•1 year ago
|
||
Updated•1 year ago
|
Comment 7•1 year ago
|
||
Comment 8•1 year ago
|
||
Comment 9•1 year ago
|
||
Comment 10•1 year ago
|
||
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
| Assignee | ||
Comment 12•1 year ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #5)
I tried updating acorn to the latest, it fixed some intermediary issues, but the two uploaded above still fail. Maybe we should report them upstream?
Bomsy: do you know of similar issues with the pretty print worker?
It looks like there might also be some issues on our end. We might be passing invalid JavaScript to acorn which is causing it to throw.
With the reduced example test cases
- For test_case_2.html =>
t>console.log("is passed to acorn. - for test_case_1.html =>
t>console.log(%` is passed to acorn
Seems like the indexes used to strip the javascript from the html here https://searchfox.org/firefox-main/rev/3c23ce1368431d49bae08e8e211f7f2bf4e4829d/devtools/client/debugger/src/actions/sources/prettyPrint.js#194 might not be correct.
Comment 13•1 year ago
|
||
Thanks for the investigation! Very interesting, this is probably because the emojis show up as 1-length in JS strings but internally are represented by more bytes and therefore trigger offset issues?
| Assignee | ||
Comment 14•1 year ago
|
||
Updated•1 year ago
|
Updated•1 year ago
|
Comment 15•1 year ago
|
||
Comment 16•1 year ago
|
||
| bugherder | ||
Updated•1 year ago
|
Description
•