Changeset 109840 in webkit
- Timestamp:
- Mar 5, 2012 8:20:47 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109836 r109840 1 2012-03-05 Kenichi Ishibashi <bashi@chromium.org> 2 3 [WebSocket] Should raise SYNTAX_ERR when message contains unpaired surrogates 4 https://bugs.webkit.org/show_bug.cgi?id=80103 5 6 Reviewed by Kent Tamura. 7 8 Added tests for unpaired surrogates check for WebSocket message and close reason. 9 Updated two expectations for close() tests because further error message is added. 10 11 * http/tests/websocket/tests/hybi/close-expected.txt: Updated. 12 * http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason-expected.txt: Added. 13 * http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason.html: Added. 14 * http/tests/websocket/tests/hybi/unpaired-surrogates-in-message-expected.txt: Added. 15 * http/tests/websocket/tests/hybi/unpaired-surrogates-in-message.html: Added. 16 * http/tests/websocket/tests/hybi/workers/close-expected.txt: Updated. 17 1 18 2012-03-05 Yoshifumi Inoue <yosin@chromium.org> 2 19 -
trunk/LayoutTests/http/tests/websocket/tests/hybi/close-expected.txt
r104803 r109840 1 1 CONSOLE MESSAGE: WebSocket is closed before the connection is established. 2 CONSOLE MESSAGE: WebSocket close message is too long. 3 CONSOLE MESSAGE: WebSocket close message is too long. 2 4 CONSOLE MESSAGE: WebSocket is closed before the connection is established. 3 5 Verify WebSocket::close behaviors. -
trunk/LayoutTests/http/tests/websocket/tests/hybi/workers/close-expected.txt
r104803 r109840 1 1 CONSOLE MESSAGE: WebSocket is closed before the connection is established. 2 CONSOLE MESSAGE: WebSocket close message is too long. 3 CONSOLE MESSAGE: WebSocket close message is too long. 2 4 CONSOLE MESSAGE: WebSocket is closed before the connection is established. 3 5 Verify WebSocket::close behaviors in Worker. -
trunk/Source/WebCore/ChangeLog
r109839 r109840 1 2012-03-05 Kenichi Ishibashi <bashi@chromium.org> 2 3 [WebSocket] Should raise SYNTAX_ERR when message contains unpaired surrogates 4 https://bugs.webkit.org/show_bug.cgi?id=80103 5 6 Reviewed by Kent Tamura. 7 8 Add UTF8 validation checks for WebSocket message and close reason. 9 10 Tests: http/tests/websocket/tests/hybi/unpaired-surrogates-in-close-reason.html 11 http/tests/websocket/tests/hybi/unpaired-surrogates-in-message.html 12 13 * Modules/websockets/WebSocket.cpp: 14 (WebCore::WebSocket::send): Raise SYNTAX_ERR if the message is invalid. 15 (WebCore::WebSocket::close):Raise SYNTAX_ERR if the reason is invalid. 16 * Modules/websockets/WebSocketChannel.cpp: 17 (WebCore::WebSocketChannel::send): Check whether message is a valid UTF8 string. 18 1 19 2012-03-05 Kenneth Russell <kbr@google.com> 2 20 -
trunk/Source/WebCore/Modules/websockets/WebSocket.cpp
r109832 r109840 289 289 return false; 290 290 } 291 // FIXME: check message is valid utf8.292 291 ASSERT(m_channel); 293 return m_channel->send(message) == ThreadableWebSocketChannel::SendSuccess; 292 ThreadableWebSocketChannel::SendResult result = m_channel->send(message); 293 if (result == ThreadableWebSocketChannel::InvalidMessage) { 294 scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Websocket message contains invalid character(s)."); 295 ec = SYNTAX_ERR; 296 return false; 297 } 298 return result == ThreadableWebSocketChannel::SendSuccess; 294 299 } 295 300 … … 344 349 return; 345 350 } 346 // FIXME: if reason contains any unpaired surrogates, raise SYNTAX_ERR. 347 if (reason.utf8().length() > maxReasonSizeInBytes) { 351 CString utf8 = reason.utf8(true); 352 if (utf8.length() > maxReasonSizeInBytes) { 353 scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "WebSocket close message is too long."); 354 ec = SYNTAX_ERR; 355 return; 356 } 357 // Checks whether reason is valid utf8. 358 if (utf8.isNull() && reason.length()) { 359 scriptExecutionContext()->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "WebSocket close message contains invalid character(s)."); 348 360 ec = SYNTAX_ERR; 349 361 return; -
trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp
r109832 r109840 161 161 { 162 162 LOG(Network, "WebSocketChannel %p send %s", this, message.utf8().data()); 163 CString utf8 = message.utf8(); 163 CString utf8 = message.utf8(true); 164 if (utf8.isNull() && message.length()) 165 return InvalidMessage; 164 166 if (m_useHixie76Protocol) { 165 167 return sendFrameHixie76(utf8.data(), utf8.length()) ? ThreadableWebSocketChannel::SendSuccess : ThreadableWebSocketChannel::SendFail;
Note: See TracChangeset
for help on using the changeset viewer.