[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

ukai at chromium.org ukai at chromium.org
Thu Apr 8 00:45:32 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 04de974ff9451e2f26dabbb8836e0dd49a5c543a
Author: ukai at chromium.org <ukai at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 22 04:47:46 2009 +0000

    2009-12-21  Fumitoshi Ukai  <ukai at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Invalid url should raise SYNTAX_ERR exception.
            https://bugs.webkit.org/show_bug.cgi?id=32700
    
            * websocket/tests/bad-sub-protocol-expected.txt: add CONSOLE MESSAGEs
            * websocket/tests/script-tests/url-parsing.js: add invalid url tests.
              Also changed url from ws://127.0.0.1/ to ws://127.0.0.1:8880/websocket/tests/simple to make it sure no errors on console message for these tests by not receiving unexpected response from 127.0.0.1:80
            * websocket/tests/url-parsing-expected.txt:
    2009-12-21  Fumitoshi Ukai  <ukai at chromium.org>
    
            Reviewed by Alexey Proskuryakov.
    
            Invalid url should raise SYNTAX_ERR exception.
            https://bugs.webkit.org/show_bug.cgi?id=32700
    
            Check url is valid in WebSocket::connect.
            Also log the detailed reason of websocket failures to console.
    
            * websockets/WebSocket.cpp:
            (WebCore::encodeProtocolString):
            (WebCore::WebSocket::connect):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52478 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f5d15e2..34895f9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-21  Fumitoshi Ukai  <ukai at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Invalid url should raise SYNTAX_ERR exception.
+        https://bugs.webkit.org/show_bug.cgi?id=32700
+
+        * websocket/tests/bad-sub-protocol-expected.txt: add CONSOLE MESSAGEs
+        * websocket/tests/script-tests/url-parsing.js: add invalid url tests.
+          Also changed url from ws://127.0.0.1/ to ws://127.0.0.1:8880/websocket/tests/simple to make it sure no errors on console message for these tests by not receiving unexpected response from 127.0.0.1:80
+        * websocket/tests/url-parsing-expected.txt:
+
 2009-12-21  Dirk Pranke  <dpranke at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/websocket/tests/bad-sub-protocol-expected.txt b/LayoutTests/websocket/tests/bad-sub-protocol-expected.txt
index 0c2fcde..fd88400 100644
--- a/LayoutTests/websocket/tests/bad-sub-protocol-expected.txt
+++ b/LayoutTests/websocket/tests/bad-sub-protocol-expected.txt
@@ -1,3 +1,14 @@
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket ''
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u0000'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u0009'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u001B'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u007F'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u0080'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\u3042'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\uFFFF'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket ''
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\uFFFE'
+CONSOLE MESSAGE: line 0: Wrong protocol for WebSocket '\uD840\uDC0B'
 Test WebSocket bad sub-protocol names.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
diff --git a/LayoutTests/websocket/tests/script-tests/url-parsing.js b/LayoutTests/websocket/tests/script-tests/url-parsing.js
index 6fdb037..c46d9e1 100644
--- a/LayoutTests/websocket/tests/script-tests/url-parsing.js
+++ b/LayoutTests/websocket/tests/script-tests/url-parsing.js
@@ -1,16 +1,22 @@
 description("Test WebSocket URL parsing.");
 
+// Invalid url will fail to be parsed.
+shouldThrow('new WebSocket("ws://javascript:a")');
+
 // Can't use relative URLs - because spec says so, and because the scheme is different anyway.
 shouldThrow('new WebSocket("/applet")');
 
+// Non ws URL is not allowed.
+shouldThrow('new WebSocket("javascript:a")');
+
 // UA is allowed to block access to some ports, which we do.
 shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
 
-// This is what we currently do, but not what the spec says (as of Editor's Draft 1 December 2009).
-shouldBe('(new WebSocket("ws://127.0.0.1/a/../")).URL', '"ws://127.0.0.1/"');
-
-shouldBe('(new WebSocket("ws://127.0.0.1/path?")).URL', '"ws://127.0.0.1/path?"');
-shouldBe('(new WebSocket("ws://127.0.0.1/path?k=v")).URL', '"ws://127.0.0.1/path?k=v"');
+// Resolve the url string using the resolve a Web address algorithm.
+// Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
+shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple"');
+shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?"');
+shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?k=v"');
 
 // draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
 // component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
diff --git a/LayoutTests/websocket/tests/url-parsing-expected.txt b/LayoutTests/websocket/tests/url-parsing-expected.txt
index 80d7557..cbf44c3 100644
--- a/LayoutTests/websocket/tests/url-parsing-expected.txt
+++ b/LayoutTests/websocket/tests/url-parsing-expected.txt
@@ -1,12 +1,20 @@
+CONSOLE MESSAGE: line 0: Invalid url for WebSocket ws://javascript:a
+CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket http://127.0.0.1:8880/applet
+CONSOLE MESSAGE: line 0: Wrong url scheme for WebSocket javascript:a
+CONSOLE MESSAGE: line 0: WebSocket port 25 blocked
+CONSOLE MESSAGE: line 0: URL has fragment component ws://127.0.0.1/path#
+CONSOLE MESSAGE: line 0: URL has fragment component ws://127.0.0.1/path#fragment
 Test WebSocket URL parsing.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
+PASS new WebSocket("ws://javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("/applet") threw exception Error: SYNTAX_ERR: DOM Exception 12.
+PASS new WebSocket("javascript:a") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1:25/") threw exception Error: SECURITY_ERR: DOM Exception 18.
-PASS (new WebSocket("ws://127.0.0.1/a/../")).URL is "ws://127.0.0.1/"
-PASS (new WebSocket("ws://127.0.0.1/path?")).URL is "ws://127.0.0.1/path?"
-PASS (new WebSocket("ws://127.0.0.1/path?k=v")).URL is "ws://127.0.0.1/path?k=v"
+PASS (new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/simple")).URL is "ws://127.0.0.1:8880/websocket/tests/simple"
+PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?")).URL is "ws://127.0.0.1:8880/websocket/tests/simple?"
+PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?k=v")).URL is "ws://127.0.0.1:8880/websocket/tests/simple?k=v"
 PASS new WebSocket("ws://127.0.0.1/path#") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS new WebSocket("ws://127.0.0.1/path#fragment") threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS successfullyParsed is true
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bf59b0a..af9f17b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-21  Fumitoshi Ukai  <ukai at chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Invalid url should raise SYNTAX_ERR exception.
+        https://bugs.webkit.org/show_bug.cgi?id=32700
+
+        Check url is valid in WebSocket::connect.
+        Also log the detailed reason of websocket failures to console.
+
+        * websockets/WebSocket.cpp:
+        (WebCore::encodeProtocolString):
+        (WebCore::WebSocket::connect):
+
 2009-12-21  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebCore/websockets/WebSocket.cpp b/WebCore/websockets/WebSocket.cpp
index ee78174..bd62cfa 100644
--- a/WebCore/websockets/WebSocket.cpp
+++ b/WebCore/websockets/WebSocket.cpp
@@ -43,12 +43,13 @@
 #include "Logging.h"
 #include "MessageEvent.h"
 #include "ScriptExecutionContext.h"
+#include "StringBuilder.h"
 #include "WebSocketChannel.h"
 #include <wtf/StdLibExtras.h>
 
 namespace WebCore {
 
-static bool isValidProtocolString(const WebCore::String& protocol)
+static bool isValidProtocolString(const String& protocol)
 {
     if (protocol.isNull())
         return true;
@@ -62,6 +63,20 @@ static bool isValidProtocolString(const WebCore::String& protocol)
     return true;
 }
 
+static String encodeProtocolString(const String& protocol)
+{
+    StringBuilder builder;
+    for (size_t i = 0; i < protocol.length(); i++) {
+        if (protocol[i] < 0x20 || protocol[i] > 0x7E)
+            builder.append(String::format("\\u%04X", protocol[i]));
+        else if (protocol[i] == 0x5c)
+            builder.append("\\\\");
+        else
+            builder.append(protocol[i]);
+    }
+    return builder.toString();
+}
+
 #if USE(V8)
 
 static bool webSocketsAvailable = false;
@@ -101,26 +116,33 @@ void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode&
     m_url = url;
     m_protocol = protocol;
 
+    if (!m_url.isValid()) {
+        scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
+        m_state = CLOSED;
+        ec = SYNTAX_ERR;
+        return;
+    }
+
     if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
-        LOG(Network, "Wrong url scheme for WebSocket %s", url.string().utf8().data());
+        scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (m_url.hasFragmentIdentifier()) {
-        LOG(Network, "URL has fragment component %s", url.string().utf8().data());
+        scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (!isValidProtocolString(m_protocol)) {
-        LOG(Network, "Wrong protocol for WebSocket %s", m_protocol.utf8().data());
+        scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (!portAllowed(url)) {
-        LOG(Network, "WebSocket port %d blocked", url.port());
+        scriptExecutionContext()->addMessage(ConsoleDestination, JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("WebSocket port %d blocked", url.port()), 0, scriptExecutionContext()->securityOrigin()->toString());
         m_state = CLOSED;
         ec = SECURITY_ERR;
         return;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list