2009-12-07 Fumitoshi Ukai <ukai@chromium.org>
authorukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Dec 2009 04:19:59 +0000 (04:19 +0000)
committerukai@chromium.org <ukai@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Dec 2009 04:19:59 +0000 (04:19 +0000)
        Reviewed by Alexey Proskuryakov.

        Fragments now make WebSocket URL parsing fail.
        https://bugs.webkit.org/show_bug.cgi?id=32144

        * websocket/tests/script-tests/url-parsing.js:
        * websocket/tests/script-tests/url-with-fragment.js: Removed.
        * websocket/tests/url-parsing-expected.txt:
        * websocket/tests/url-with-fragment-expected.txt: Removed.
        * websocket/tests/url-with-fragment.html: Removed.
2009-12-07  Fumitoshi Ukai  <ukai@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Fragments now make WebSocket URL parsing fail.
        https://bugs.webkit.org/show_bug.cgi?id=32144

        * websockets/WebSocket.cpp:
        (WebCore::WebSocket::connect):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51830 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/websocket/tests/script-tests/url-parsing.js
LayoutTests/websocket/tests/script-tests/url-with-fragment.js [deleted file]
LayoutTests/websocket/tests/url-parsing-expected.txt
LayoutTests/websocket/tests/url-with-fragment-expected.txt [deleted file]
LayoutTests/websocket/tests/url-with-fragment.html [deleted file]
WebCore/ChangeLog
WebCore/websockets/WebSocket.cpp

index 9963f2a..cf033c5 100644 (file)
@@ -1,5 +1,18 @@
 2009-12-07  Fumitoshi Ukai  <ukai@chromium.org>
 
+        Reviewed by Alexey Proskuryakov.
+
+        Fragments now make WebSocket URL parsing fail.
+        https://bugs.webkit.org/show_bug.cgi?id=32144
+
+        * websocket/tests/script-tests/url-parsing.js:
+        * websocket/tests/script-tests/url-with-fragment.js: Removed.
+        * websocket/tests/url-parsing-expected.txt:
+        * websocket/tests/url-with-fragment-expected.txt: Removed.
+        * websocket/tests/url-with-fragment.html: Removed.
+
+2009-12-07  Fumitoshi Ukai  <ukai@chromium.org>
+
         Reviewed by Darin Adler.
 
         Fix wrong length parsing in WebSocket.
index 59f2a83..6fdb037 100644 (file)
@@ -7,8 +7,16 @@ shouldThrow('new WebSocket("/applet")');
 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).
-// The spec says that the string passed to WebScoket constructor should be returned unchanged.
 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"');
+
+// draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
+// component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
+// exception.
+shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
+shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
+
 var successfullyParsed = true;
 isSuccessfullyParsed();
diff --git a/LayoutTests/websocket/tests/script-tests/url-with-fragment.js b/LayoutTests/websocket/tests/script-tests/url-with-fragment.js
deleted file mode 100644 (file)
index 73e8a01..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-description("Make sure handshake with URL with fragment components success.");
-
-if (window.layoutTestController)
-    layoutTestController.waitUntilDone();
-
-var url = "ws://127.0.0.1:8880/websocket/tests/echo-location#fragment";
-var handshake_success = false;
-var ws_location;
-
-function endTest()
-{
-    clearTimeout(timeoutID);
-    shouldBeTrue("handshake_success");
-    shouldBe("ws_location", '"ws://127.0.0.1:8880/websocket/tests/echo-location"');
-    isSuccessfullyParsed();
-    if (window.layoutTestController)
-        layoutTestController.notifyDone();
-}
-
-debug("url=" + url);
-var ws = new WebSocket(url);
-ws.onopen = function () {
-    debug("WebSocket is open");
-    handshake_success = true;
-};
-ws.onmessage = function (evt) {
-    ws_location = evt.data;
-    debug("received:" + ws_location);
-    ws.close();
-};
-ws.onclose = function () {
-    debug("WebSocket is closed");
-    endTest();
-};
-var timeoutID = setTimeout("endTest()", 2000);
-
-var successfullyParsed = true;
index d43a689..80d7557 100644 (file)
@@ -5,6 +5,10 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS new WebSocket("/applet") 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/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
 
 TEST COMPLETE
diff --git a/LayoutTests/websocket/tests/url-with-fragment-expected.txt b/LayoutTests/websocket/tests/url-with-fragment-expected.txt
deleted file mode 100644 (file)
index 27c764f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Make sure handshake with URL with fragment components success.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-url=ws://127.0.0.1:8880/websocket/tests/echo-location#fragment
-WebSocket is open
-received:ws://127.0.0.1:8880/websocket/tests/echo-location
-WebSocket is closed
-PASS handshake_success is true
-PASS ws_location is "ws://127.0.0.1:8880/websocket/tests/echo-location"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/websocket/tests/url-with-fragment.html b/LayoutTests/websocket/tests/url-with-fragment.html
deleted file mode 100644 (file)
index 2b34770..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
-<script src="../../fast/js/resources/js-test-pre.js"></script>
-<script src="../../fast/js/resources/js-test-post-function.js"></script>
-</head>
-<body>
-<div id="description"></div>
-<div id="console"></div>
-<script src="script-tests/url-with-fragment.js"></script>
-</body>
-</html>
index b235deb..ef4e9c6 100644 (file)
@@ -1,5 +1,15 @@
 2009-12-07  Fumitoshi Ukai  <ukai@chromium.org>
 
+        Reviewed by Alexey Proskuryakov.
+
+        Fragments now make WebSocket URL parsing fail.
+        https://bugs.webkit.org/show_bug.cgi?id=32144
+
+        * websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+
+2009-12-07  Fumitoshi Ukai  <ukai@chromium.org>
+
         Reviewed by Darin Adler.
 
         Fix wrong length parsing in WebSocket.
index da60025..7d16493 100644 (file)
@@ -130,6 +130,12 @@ void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode&
         ec = SYNTAX_ERR;
         return;
     }
+    if (m_url.hasFragmentIdentifier()) {
+        LOG(Network, "URL has fragment component %s", url.string().utf8().data());
+        m_state = CLOSED;
+        ec = SYNTAX_ERR;
+        return;
+    }
     if (!isValidProtocolString(m_protocol)) {
         LOG(Network, "Wrong protocol for WebSocket %s", m_protocol.utf8().data());
         m_state = CLOSED;