Bug 153830

Summary: Web Inspector: JSON prettifier does not correctly handle negative numbers
Product: WebKit Reporter: Antoine Quint <graouts>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: CLOSED DUPLICATE    
Severity: Normal CC: bburg, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 9   
Hardware: All   
OS: All   
Attachments:
Description Flags
Screenshot
none
Testcase
none
Supporting resource for test case none

Description Antoine Quint 2016-02-03 05:02:13 PST
Created attachment 270572 [details]
Screenshot

The following JSON:

{"someNegativeNumbers":[-8,-6,-3]}

is prettified as:

{
    "someNegativeNumbers": [ - 8, - 6, - 3]
}

Note the space between the "-" and the actual number value. This prettified JSON is invalid.
Comment 1 Antoine Quint 2016-02-03 05:02:48 PST
Created attachment 270573 [details]
Testcase
Comment 2 Antoine Quint 2016-02-03 05:03:09 PST
Created attachment 270574 [details]
Supporting resource for test case
Comment 3 Radar WebKit Bug Importer 2016-02-03 05:04:21 PST
<rdar://problem/24480111>
Comment 4 Radar WebKit Bug Importer 2016-02-03 05:04:22 PST
<rdar://problem/24480103>
Comment 5 Joseph Pecoraro 2016-02-03 15:59:45 PST
Yep, this was a known issue with the JavaScript pretty printer. CodeMirror used to tokenize -/+ as part of the number and then stopped.

One pro is that it now sees this as an operator that we can reason about, on the minus side we weren't reasoning about it very carefully. Basically always treating +/- as binary operators.

I have a hack that makes an effort to better handle unary numbers. I saw no performance regression.
Comment 6 Joseph Pecoraro 2016-02-03 16:04:22 PST

*** This bug has been marked as a duplicate of bug 134007 ***