Closed
Bug 568503
Opened 15 years ago
Closed 13 years ago
charset is not set for application/* types (XML, JSON, Atom, RDF, Javascript...)
Categories
(Bugzilla :: Bugzilla-General, defect)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.2
People
(Reporter: gerv, Assigned: reed)
Details
Even when Bugzilla is using UTF-8, config.cgi does not set a charset in the Content-Type header. This means that data will be by default interpreted by clients as ISO-8859-1, which is bad (dataloss).
We should make config.cgi send "charset=utf-8" in the Content-Type header if Bugzilla is using UTF-8.
[ However, note that it's only legal to set a charset in a Content-Type header if you have already set a content type. Therefore, if $format->{'ctype'} is "", i.e. Bugzilla does not know about the ctype being used, adding the charset parameter to the header won't work, and clients will still default to ISO-8859-1. Another reason why Bugzilla should know about all common ctypes. ]
Gerv
| Reporter | ||
Comment 1•15 years ago
|
||
Hmm. I originally wrote a config.cgi-specific patch for this for 3.4 (and the bit in square brackets above makes sense for the 3.4 code). However, 3.6 now uses Bugzilla->cgi->header(). And our CGI.pm sets the charset to UTF-8 whenever the utf8 parameter is turned on. So why doesn't it work?
It turns out Perl's CGI.pm only puts its internal charset into the header for text types :-( Or at least, it doesn't do it for application/json or application/xml. That rather sucks.
I'm not sure what the correct fix is here. We already have a bit of "CGI.pm doesn't add the charset; add it ourselves" code in multipart_start(). So we could do that for all application/ types too... I don't really want to special-case XML and JSON in our CGI code!
Max?
Gerv
Summary: config.cgi does not set a charset in Content-Type → charset is not set for application/* types (XML, JSON, Atom, RDF, Javascript...)
Comment 2•15 years ago
|
||
Hmm. I'd suggest filing a bug against CGI.pm and see what the maintainer says. They've been very responsive lately.
| Reporter | ||
Comment 3•15 years ago
|
||
Bug filed: https://rt.cpan.org/Public/Bug/Display.html?id=57945
I've noticed that specifying the charset explicitly on the header() call does work, so we could work around this by hacking Bugzilla::CGI->header().
Gerv
| Reporter | ||
Comment 4•15 years ago
|
||
Max: doesn't look like the CGI.pm team are going to fix this... what do we do now?
Gerv
Comment 5•15 years ago
|
||
Okay, that's annoying. Sounds like we should monkeypatch header() (which we already do anyway) to add the charset always--at least for certain types?
| Reporter | ||
Comment 6•15 years ago
|
||
Sounds like a plan to me.
Gerv
| Assignee | ||
Comment 7•15 years ago
|
||
CGI.pm 3.51 fixes this.
Comment 8•13 years ago
|
||
Trunk requires CGI 3.51, so is this fixed?
Comment 9•13 years ago
|
||
(In reply to Matt Selsky [:selsky] from comment #8)
> Trunk requires CGI 3.51, so is this fixed?
CGI 3.51 is required since Bugzilla 3.2.10, see bug 591165, so yes, this problem is now fixed.
Assignee: general → reed
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Bugzilla 3.2
You need to log in
before you can comment on or make changes to this bug.
Description
•