Bug 101569 - [WebSocket] send() and close() should not throw an exception for an unpaired surrogate but use the replacement character
Summary: [WebSocket] send() and close() should not throw an exception for an unpaired...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kenichi Ishibashi
URL:
Keywords:
Depends on: 101678
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-08 02:46 PST by Kenichi Ishibashi
Modified: 2012-11-13 17:53 PST (History)
3 users (show)

See Also:


Attachments
Patch (16.25 KB, patch)
2012-11-08 03:06 PST, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch (16.24 KB, patch)
2012-11-08 04:14 PST, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff
Patch (12.26 KB, patch)
2012-11-11 06:27 PST, Kenichi Ishibashi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenichi Ishibashi 2012-11-08 02:46:36 PST
Chromium bug entry: http://code.google.com/p/chromium/issues/detail?id=159568

The WebSocket API specification has changed. When a message of send() (or a reason of close()) has unpaired surrogates, they should be replaced with replacement character (U+FFFE), instead of throwing SYNTAX_ERR.

Specification diff:
http://html5.org/tools/web-apps-tracker?from=7083&to=7084

How to use replacement character:
http://dev.w3.org/2006/webapi/WebIDL/#dfn-obtain-unicode

The current WebKit throws SYNTAX_ERR. Following w3c-test is failing because of this behavior:
http://www.w3c-test.org/webapps/WebSockets/tests/submissions/Microsoft/Send-Unpaired-Surrogates.htm
Comment 1 Kenichi Ishibashi 2012-11-08 03:06:59 PST
Created attachment 172980 [details]
Patch
Comment 2 Build Bot 2012-11-08 04:06:07 PST
Comment on attachment 172980 [details]
Patch

Attachment 172980 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14759745
Comment 3 Kenichi Ishibashi 2012-11-08 04:14:02 PST
Created attachment 173006 [details]
Patch
Comment 4 Alexey Proskuryakov 2012-11-08 10:34:07 PST
Comment on attachment 173006 [details]
Patch

This is generic UTF-8 manipulation code, it should be in WTF, not in WebSocket files.

Also, I'm not sure why we need two passes now.
Comment 5 Kenichi Ishibashi 2012-11-08 18:01:18 PST
(In reply to comment #4)
> (From update of attachment 173006 [details])
> This is generic UTF-8 manipulation code, it should be in WTF, not in WebSocket files.

I see. The code would be able to merge with String::utf8(). I'll create a separate bug entry for it.

> Also, I'm not sure why we need two passes now.

m_channel can be null in WebSocketChannel::close() so we need to check the length of reason in utf-8 at WebSocket::close().
Comment 6 Kenichi Ishibashi 2012-11-11 06:27:40 PST
Created attachment 173505 [details]
Patch
Comment 7 Kenichi Ishibashi 2012-11-13 16:30:28 PST
Hi Alexey,

Could you take another look?
Comment 8 Kenichi Ishibashi 2012-11-13 17:30:26 PST
Comment on attachment 173505 [details]
Patch

Thanks!
Comment 9 WebKit Review Bot 2012-11-13 17:53:07 PST
Comment on attachment 173505 [details]
Patch

Clearing flags on attachment: 173505

Committed r134515: <http://trac.webkit.org/changeset/134515>
Comment 10 WebKit Review Bot 2012-11-13 17:53:10 PST
All reviewed patches have been landed.  Closing bug.