[WebSocket] Should raise SYNTAX_ERR when message contains unpaired surrogates
authorbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2012 09:39:56 +0000 (09:39 +0000)
committerbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2012 09:39:56 +0000 (09:39 +0000)
commitd9513d91f7105628a428a283c06c7a547648155d
tree75ee3b286dc43504929a62efad74a97673cf12b0
parent0d97dc7bb088097b027bda3c6017b737a1759024
[WebSocket] Should raise SYNTAX_ERR when message contains unpaired surrogates
https://bugs.webkit.org/show_bug.cgi?id=80103

Reviewed by Kent Tamura.

Source/WebCore:

Add UTF8 validation checks for WebSocket message and close reason.

Tests: http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason.html
       http/tests/websocket/tests/hybi/unpaired-surrogates-in-message.html

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::send): Raise SYNTAX_ERR if the message is invalid.
(WebCore::WebSocket::close):Raise SYNTAX_ERR if the reason is invalid.
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::send): Check whether message is a valid UTF8 string.

LayoutTests:

Added tests for unpaired surrogates check for WebSocket message and close reason.
Updated two expectations for close() tests because further error message is added.

* http/tests/websocket/tests/hybi/close-expected.txt: Updated.
* http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason-expected.txt: Added.
* http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason.html: Added.
* http/tests/websocket/tests/hybi/unpaired-surrogates-in-message-expected.txt: Added.
* http/tests/websocket/tests/hybi/unpaired-surrogates-in-message.html: Added.
* http/tests/websocket/tests/hybi/workers/close-expected.txt: Updated.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110037 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/websocket/tests/hybi/close-expected.txt
LayoutTests/http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/unpaired-surrogates-in-message-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/unpaired-surrogates-in-message.html [new file with mode: 0644]
LayoutTests/http/tests/websocket/tests/hybi/workers/close-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocketChannel.cpp