Ticket #848 (closed defect: fixed)
JSON should not be sent as text/html
| Reported by: | gsnedders | Owned by: | gsnedders |
|---|---|---|---|
| Priority: | major | Milestone: | 0.6 |
| Component: | Habari Core Software | Version: | SVN |
| Keywords: | has_patch | Cc: |
Description
Currently we serve everything by text/html;charset=utf-8 by default — including JSON. We should instead use application/json;charset=utf-8.
Attachments
Change History
comment:2 Changed 3 years ago by michaeltwofish
I claim no expertise about this, but this article seems germane, http://simonwillison.net/2009/Feb/6/json/. Basically, many browsers don't handle application/json, and a more reliable solution seems to be to send application/javascript where appropriate.
comment:3 Changed 3 years ago by michaeltwofish
However, Anne van Kesteren, who has some knowledge in the area, says in the comments,0
"Browsers ignore the Content-Type when loading through <script> ... so whether you use application/json, application/javascript, application/x-javascript, text/plain, text/html, or nothing at all does not really matter."
So this isn't worth the effort ?
comment:4 Changed 3 years ago by gsnedders
Yeah, Anne wrote the spec (he's annevk on Freenode, FWIW), and spent way too much time reverse-engineering stuff, so he does have some knowledge. :)
Basically the point is when using window.XMLHttpRequest (or XHR as an ActiveX object) the Content-Type is ignored, so it is true that this bug causes no issues, even if it is against spec. (the only effect of using text/html is that the browser tries to get the character encoding as if it were HTML, though in our case that means it just uses the charset parameter on the Content-Type header). It also means that fixing it causes no issues.
comment:5 Changed 3 years ago by gsnedders
- Keywords has_patch added
- Owner set to gsnedders
- Status changed from new to assigned
- Milestone changed from Undetermined to 0.6
comment:6 Changed 3 years ago by moeffju
- Status changed from assigned to closed
- Resolution set to fixed
In [3346], thanks.
comment:7 Changed 3 years ago by sean
- Status changed from closed to reopened
- Resolution fixed deleted
Reopened by [3412]
comment:8 Changed 3 years ago by sean
- Status changed from reopened to closed
- Resolution set to wontfix
... and closing as won't fix.
comment:9 Changed 3 years ago by gsnedders
Is there really no way to fix this? Does even text/javascript cause issues anywhere?
comment:10 Changed 3 years ago by gsnedders
- Status changed from closed to reopened
- Resolution wontfix deleted
comment:11 Changed 3 years ago by gsnedders
- Status changed from reopened to closed
- Resolution set to fixed
And fixed in [3506].

