Closed
Bug 562915
Opened 14 years ago
Closed 12 years ago
escape characters in content-type charset param not parsed properly
Categories
(Core :: Networking: HTTP, defect)
Core
Networking: HTTP
Tracking
()
RESOLVED
FIXED
mozilla11
People
(Reporter: julian.reschke, Assigned: julian.reschke)
Details
Attachments
(1 file, 1 obsolete file)
2.75 KB,
patch
|
jduell.mcbugs
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 According to RFC 2616, Section 3.7, the following headers are equivalent: Content-Type: text/plain; charset="U\TF-8" Content-Type: text/plain; charset="UTF-8" However, Mozilla seems no to un-escape the string value, and thus doesn't see the charset value of UTF-8. Yes, this is an edge case. It's a bug nevertheless. Reproducible: Always
Assignee | ||
Updated•13 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 1•13 years ago
|
||
See test case at http://greenbytes.de/tech/tc/httpcontenttype/#textplainutf8qsescaped (currently Konqueror and Safari passing). See also http://trac.tools.ietf.org/wg/httpbis/trac/ticket/270
Assignee | ||
Updated•12 years ago
|
OS: Windows 7 → All
Hardware: x86 → All
Assignee | ||
Comment 2•12 years ago
|
||
The problem is caused by net_ParseContentType returning the unescaped charset; however this is non-trivial to change because it just returns pointers into the raw header field, and that header field is const. The right approach seems to be to change the method signature to return a new string, however this means touching multiple other places.
Assignee | ||
Comment 3•12 years ago
|
||
(In reply to Julian Reschke from comment #2) > The problem is caused by > > net_ParseContentType > > returning the unescaped charset; however this is non-trivial to change > because it just returns pointers into the raw header field, and that header > field is const. > ... Turns out I was too pessimistic, please ignore above comment.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → julian.reschke
Assignee | ||
Comment 4•12 years ago
|
||
Applies on top of patch for bug 700589
Attachment #573312 -
Flags: review?(jduell.mcbugs)
Comment 5•12 years ago
|
||
Comment on attachment 573312 [details] [diff] [review] Proposed patch, incl test case Review of attachment 573312 [details] [diff] [review]: ----------------------------------------------------------------- ::: netwerk/base/src/nsURLHelper.cpp @@ +888,4 @@ > } while (curParamStart < flatStr.Length()); > } > > + bool charsetNeedsUnquote = false; From my understanding of the code, this variable isn't actually controlling whether we need to find a matching " at the end of the string, but rather just whether we need to ignore any backslashes in the charset. Correct? If so, maybe rename to 'charsetRemoveBackslashes'? @@ +926,4 @@ > > if ((!eq && *aHadCharset) || typeHasCharset) { > *aHadCharset = true; > + if (charsetNeedsUnquote) { Maybe add comment here: // RFC 2616, Section 3.7 says we must ignore XYZ Actually, looking at section 3.7, I don't see how it says that we need to be ignoring the backslashes. But that probably just means I haven't chased enough RFC definitions far enough (is the behavior implied by 'parameter'? I only see it saying the match needs to be case-insensitive).
Assignee | ||
Comment 6•12 years ago
|
||
Addresses review comments (made name of flag more precise, add comment why we're unescaping here)
Attachment #573312 -
Attachment is obsolete: true
Attachment #577587 -
Flags: review?(jduell.mcbugs)
Attachment #573312 -
Flags: review?(jduell.mcbugs)
Comment 7•12 years ago
|
||
Comment on attachment 577587 [details] [diff] [review] Proposed patch, incl test case Review of attachment 577587 [details] [diff] [review]: ----------------------------------------------------------------- Thanks Julian!
Attachment #577587 -
Flags: review?(jduell.mcbugs) → review+
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 8•12 years ago
|
||
Try results: https://tbpl.mozilla.org/?tree=Try&rev=74b71078993b
Comment 10•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/abe0e4c2c403
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•