Closed Bug 1235118 Opened 4 years ago Closed 4 years ago

SyntaxError while loading URL with .json extension

Categories

(DevTools :: JSON Viewer, defect, major)

45 Branch
defect
Not set
major

Tracking

(firefox44 unaffected, firefox45+ fixed, firefox46+ fixed)

RESOLVED FIXED
Firefox 46
Tracking Status
firefox44 --- unaffected
firefox45 + fixed
firefox46 + fixed

People

(Reporter: dev.hibiki, Assigned: Honza)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20151224004003

Steps to reproduce:

I used Firefox Development Edition 45.0a2 (2015-12-24) to access an .json URL as below:
https://docs.npmjs.com/getting-started/using-a-package.json



Actual results:

Content-Type was text/html, and I caught "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" in JSON Viewer.




Expected results:

Maybe it should stop using JSON Viewer on .json URL when Content-Type was text/html. Only render as a html page.
Severity: normal → major
Status: UNCONFIRMED → NEW
Component: Untriaged → Developer Tools: JSON Viewer
Ever confirmed: true
I can confirm this happening on GitHub URLs as well: https://github.com/BYK/superset/blame/master/package.json broke quite horrendously and without clear error messages.

I had to turn off `devtools.jsonview.enabled` flag for now.
Duplicate of this bug: 1236297
Duplicate of this bug: 1236456
Duplicate of this bug: 1235725
[Tracking Requested - why for this release]:
Might siphon people away from Dev Edition if/when they hit this.
Honza, it seems like we should revert your recent changes to force .json to load in the viewer.
Flags: needinfo?(odvarko)
Assignee: nobody → odvarko
Flags: needinfo?(odvarko)
(In reply to J. Ryan Stinnett [:jryans] (use ni?) from comment #6)
> Honza, it seems like we should revert your recent changes to force .json to
> load in the viewer.
Yes, patch attached.

(I removed also getFileExtension() in the end, but let me know if you feel like this one should stay)

Honza
Attachment #8703691 - Flags: review?(jryans)
Comment on attachment 8703691 [details] [diff] [review]
bug1235118-1.patch

Review of attachment 8703691 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks!  We'll also need to request uplift to Dev. Ed once this lands in m-c.
Attachment #8703691 - Flags: review?(jryans) → review+
https://hg.mozilla.org/mozilla-central/rev/acbe4e7e6c00
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 46
Jan, could you fill the uplift request to aurora? Thanks
Flags: needinfo?(odvarko)
Comment on attachment 8703691 [details] [diff] [review]
bug1235118-1.patch

Approval Request Comment
[Feature/regressing bug #]: Backout patch from bug 1230544. The patch treats URLs with .json extension as application/json docs which is wrong.
[User impact if declined]: URLs with .json extensions are broken
[Describe test coverage new/current, TreeHerder]: n/a
[Risks and why]: n/a
[String/UUID change made/needed]: n/a
Flags: needinfo?(odvarko)
Attachment #8703691 - Flags: approval-mozilla-aurora?
Comment on attachment 8703691 [details] [diff] [review]
bug1235118-1.patch

Thanks!
Attachment #8703691 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Just adding that I experienced this too for JSON in Chromium's source, which is linked from MDN.

https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/runtime.json
Duplicate of this bug: 1239273
Duplicate of this bug: 1239277
[bugday-20160323]

Status: RESOLVED,FIXED -> UNVERIFIED

Comments:
JSON should not open as file extension is html


Component: 
Name			Firefox
Version			46.0b9
Build ID		20160322075646
Update Channel	        beta
User Agent		Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
OS			Windows 7 SP1 x86_64

Expected Results: 
json should rendering page.

Actual Results: 
.json directly opens with browser having HTML/CSS contents.
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.