Closed
Bug 964103
Opened 11 years ago
Closed 11 years ago
[prettify] Need to escape single quotes inside strings
Categories
(DevTools :: Debugger, defect)
DevTools
Debugger
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 956567
People
(Reporter: PatrickWesterhoff, Unassigned)
Details
I was just looking at some prettyfied source when I noticed that the prettyfier actually introduced a syntax error into it.
The original, minified code had something like this in it:
debugMessage("there's no active socket: " + …
Now, this is what the prettyfier made from that part:
debugMessage('there's no active socket: ' + …
For some reason, the prettifier changes double quotation marks into single quotation marks. While doing that, it does not escape already existing single quotation marks that are part of the string. Obviously, this breaks the prettified code.
Updated•11 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated•11 years ago
|
Summary: Quotation marks change when prettifying source → [prettify] Need to escape single quotes inside strings
Reporter | ||
Comment 1•11 years ago
|
||
In response to the changed title: The alternative would be to keep the existing quotation marks the way they are. So when the minimized source uses double quotation marks, keep them as double quotation marks, instead of trying to force single quotation marks on everything.
Comment 2•11 years ago
|
||
(In reply to Patrick Westerhoff from comment #1)
> In response to the changed title: The alternative would be to keep the
> existing quotation marks the way they are. So when the minimized source uses
> double quotation marks, keep them as double quotation marks, instead of
> trying to force single quotation marks on everything.
Unfortunately, acorn's lexer doesn't tell us whether the string used single or double quotes, so we have to just pick one and use it.
Comment 3•11 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] from comment #2)
> (In reply to Patrick Westerhoff from comment #1)
> > In response to the changed title: The alternative would be to keep the
> > existing quotation marks the way they are. So when the minimized source uses
> > double quotation marks, keep them as double quotation marks, instead of
> > trying to force single quotation marks on everything.
>
> Unfortunately, acorn's lexer doesn't tell us whether the string used single
> or double quotes, so we have to just pick one and use it.
Then I suggest we use double quotes instead of single quotes. Single quotes are mote frequently used in strings and sentences in any language (as punctuation marks etc.) than double quotes.
Comment 4•11 years ago
|
||
IME, single quote is used more often than double quote in JS, but I'll r+ a patch that fixes the escaping issue and switches to double quotes instead of single quotes. Doesn't matter too much to me.
Comment 5•11 years ago
|
||
Looks like same as bug 956567.
Comment 6•11 years ago
|
||
Indeed, good catch.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
Reporter | ||
Comment 7•11 years ago
|
||
Is there a reason why this was closed in favor of the other one when this one contained more comments? Just wondering if there is some common practice for it.
Comment 8•11 years ago
|
||
It was older and had STR that showed pretty printing creating invalid JS.
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•