Changeset 85939 in webkit
- Timestamp:
- May 6, 2011 1:58:44 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r85937 r85939 1 2011-05-06 Joe Mason <jmason@rim.com> 2 3 Reviewed by Adam Barth. 4 5 WebSocket urls should always be encoded as UTF-8. Relative urls should not be expanded. 6 https://bugs.webkit.org/show_bug.cgi?id=57138 7 8 * http/tests/websocket/tests/url-with-nonascii-query-expected.txt: Added. 9 * http/tests/websocket/tests/url-with-nonascii-query.html: Added. 10 * http/tests/websocket/tests/url-parsing-expected.txt: Failure message for relative url has changed since it is no longer expanded. 11 1 12 2011-05-06 MORITA Hajime <morrita@google.com> 2 13 -
trunk/LayoutTests/http/tests/websocket/tests/url-parsing-expected.txt
r68914 r85939 1 1 CONSOLE MESSAGE: line 0: Invalid url for WebSocket ws://javascript:a 2 CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket http://127.0.0.1:8000/applet2 CONSOLE MESSAGE: line 0: Invalid url for WebSocket /applet 3 3 CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket javascript:a 4 4 CONSOLE MESSAGE: line 0: WebSocket port 25 blocked -
trunk/Source/WebCore/ChangeLog
r85938 r85939 1 2011-05-06 Joe Mason <jmason@rim.com> 2 3 Reviewed by Adam Barth. 4 5 WebSocket urls should always be encoded as UTF-8. 6 https://bugs.webkit.org/show_bug.cgi?id=57138 7 8 Change WebSocket::connect to take the raw URL string and parse it 9 internally using the simple KURL constructor, which expects an absolute 10 UTF-8 encoded URL. This ensures that all code that creates a WebSocket 11 goes through this method instead of completeURL. 12 13 Test: http/tests/websocket/tests/url-with-nonascii-query.html 14 15 * bindings/js/JSWebSocketCustom.cpp: 16 (WebCore::JSWebSocketConstructor::constructJSWebSocket): Pass String instead of KURL to WebSocket::connect(). 17 * websockets/WebSocket.cpp: 18 (WebCore::WebSocket::connect): Now takes a String instead of a KURL and parses it using UTF-8. 19 * websockets/WebSocket.h: 20 1 21 2011-05-06 Luke Macpherson <macpherson@chromium.org> 2 22 -
trunk/Source/WebCore/bindings/js/JSWebSocketCustom.cpp
r84812 r85939 58 58 if (exec->hadException()) 59 59 return throwVMError(exec, createSyntaxError(exec, "wrong URL")); 60 KURL url = context->completeURL(urlString);61 60 RefPtr<WebSocket> webSocket = WebSocket::create(context); 62 61 ExceptionCode ec = 0; 63 62 if (exec->argumentCount() < 2) 64 webSocket->connect(url , ec);63 webSocket->connect(urlString, ec); 65 64 else { 66 65 String protocol = ustringToString(exec->argument(1).toString(exec)); 67 66 if (exec->hadException()) 68 67 return JSValue::encode(JSValue()); 69 webSocket->connect(url , protocol, ec);68 webSocket->connect(urlString, protocol, ec); 70 69 } 71 70 setDOMException(exec, ec); -
trunk/Source/WebCore/websockets/WebSocket.cpp
r85484 r85939 107 107 } 108 108 109 void WebSocket::connect(const KURL& url, ExceptionCode& ec)109 void WebSocket::connect(const String& url, ExceptionCode& ec) 110 110 { 111 111 connect(url, String(), ec); 112 112 } 113 113 114 void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode& ec)115 { 116 LOG(Network, "WebSocket %p connect to %s protocol=%s", this, url. string().utf8().data(), protocol.utf8().data());117 m_url = url;114 void WebSocket::connect(const String& url, const String& protocol, ExceptionCode& ec) 115 { 116 LOG(Network, "WebSocket %p connect to %s protocol=%s", this, url.utf8().data(), protocol.utf8().data()); 117 m_url = KURL(KURL(), url); 118 118 m_protocol = protocol; 119 119 120 120 if (!m_url.isValid()) { 121 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);121 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); 122 122 m_state = CLOSED; 123 123 ec = SYNTAX_ERR; … … 126 126 127 127 if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) { 128 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);128 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + m_url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); 129 129 m_state = CLOSED; 130 130 ec = SYNTAX_ERR; … … 132 132 } 133 133 if (m_url.hasFragmentIdentifier()) { 134 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);134 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + m_url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); 135 135 m_state = CLOSED; 136 136 ec = SYNTAX_ERR; … … 143 143 return; 144 144 } 145 if (!portAllowed( url)) {146 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number( url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);145 if (!portAllowed(m_url)) { 146 scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(m_url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString(), 0); 147 147 m_state = CLOSED; 148 148 ec = SECURITY_ERR; -
trunk/Source/WebCore/websockets/WebSocket.h
r67432 r85939 62 62 }; 63 63 64 void connect(const KURL&, ExceptionCode&);65 void connect(const KURL&, const String& protocol, ExceptionCode&);64 void connect(const String& url, ExceptionCode&); 65 void connect(const String& url, const String& protocol, ExceptionCode&); 66 66 67 67 bool send(const String& message, ExceptionCode&);
Note: See TracChangeset
for help on using the changeset viewer.