Closed
Bug 1170932
Opened 9 years ago
Closed 9 years ago
GBK encoder silently omits unmapped characters
Categories
(Core :: Internationalization, defect)
Core
Internationalization
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox41 | --- | fixed |
People
(Reporter: smontagu, Assigned: smontagu)
References
Details
Attachments
(2 files)
15.69 KB,
patch
|
emk
:
review+
|
Details | Diff | Splinter Review |
3.14 KB,
patch
|
Details | Diff | Splinter Review |
Spun out from bug 1169248 comment 2 and 5 (testcase slightly changed so as not to depend on that bug) data:text/html;charset=big5,<script>a=document.createElement('a');a.href='https://example.com/?\u2764';document.write(a.href)</script> Results: https://example.com/?%E2%9D%A4 (because unmapped U+2764 causes an encoding error and the URL falls back to UTF-8). Same with any other charset where U+2764 is not mapped, except: data:text/html;charset=gbk,<script>a=document.createElement('a');a.href='https://example.com/?\u2764';document.write(a.href)</script> Results: https://example.com/?
Assignee | ||
Comment 1•9 years ago
|
||
There are two issues here. a) The constructor of the gbk encoder assumes (correctly) that the maximum number of gbk codepoints in the output is 2 * the number of utf-16 codepoints in the input. Then the ConvertNoBuff method, which is shared by gbk and gb18030, fails to convert the unmapped character with the 2-byte encoder, and before calling Try4BytesEncoder checks whether there are 4 bytes free in the output buffer and if not returns NS_OK_UENC_MORE_OUTPUT instead of NS_ERROR_UENC_NOMAPPING. This check is not needed for gbk, where Try4BytesEncode will always fail. Fixing that is sufficient for the testcase in comment 0, but didn't fix an xpcshell test I wrote, because b) ConvertNoBuff doesn't handle non-default values of mErrBehavior
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8614917 -
Flags: review?(VYV03354)
Assignee | ||
Comment 3•9 years ago
|
||
Updated•9 years ago
|
Attachment #8614917 -
Flags: review?(VYV03354) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/10dfb6455e4f https://hg.mozilla.org/integration/mozilla-inbound/rev/c5f6b5160c02
Comment 5•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/10dfb6455e4f https://hg.mozilla.org/mozilla-central/rev/c5f6b5160c02
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in
before you can comment on or make changes to this bug.
Description
•