Changeset 112499 in webkit


Ignore:
Timestamp:
Mar 28, 2012 9:22:12 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[WebSocket]Browser must fail connection if Sec-WebSocket-Protocol mismatched.
https://bugs.webkit.org/show_bug.cgi?id=82307

Patch by Li Yin <li.yin@intel.com> on 2012-03-28
Reviewed by Kent Tamura.

Source/WebCore:

From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
If the WebSocket openhanding respond included the mismatched
Sec-WebSocket-Protocol header field, the client must fail the WebSocket Connection.

Test: http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html

  • Modules/websockets/WebSocketHandshake.cpp:

(WebCore::WebSocketHandshake::checkResponseHeaders):

LayoutTests:

From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
If the response includes a |Sec-WebSocket-Protocol| header field
and this header field indicates the use of a subprotocol that was
not present in the client's handshake (the server has indicated a
subprotocol not requested by the client), the client MUST _Fail
the WebSocket Connection_.

  • http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header-expected.txt: Added.
  • http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html: Added.
  • http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header_wsh.py: Added.

(web_socket_do_extra_handshake):
(web_socket_transfer_data):

Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112490 r112499  
     12012-03-28  Li Yin  <li.yin@intel.com>
     2
     3        [WebSocket]Browser must fail connection if Sec-WebSocket-Protocol mismatched.
     4        https://bugs.webkit.org/show_bug.cgi?id=82307
     5
     6        Reviewed by Kent Tamura.
     7
     8        From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
     9        If the response includes a |Sec-WebSocket-Protocol| header field
     10        and this header field indicates the use of a subprotocol that was
     11        not present in the client's handshake (the server has indicated a
     12        subprotocol not requested by the client), the client MUST _Fail
     13        the WebSocket Connection_.
     14
     15        * http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header-expected.txt: Added.
     16        * http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html: Added.
     17        * http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header_wsh.py: Added.
     18        (web_socket_do_extra_handshake):
     19        (web_socket_transfer_data):
     20
    1212012-03-28  David Grogan  <dgrogan@chromium.org>
    222
  • trunk/Source/WebCore/ChangeLog

    r112498 r112499  
     12012-03-28  Li Yin  <li.yin@intel.com>
     2
     3        [WebSocket]Browser must fail connection if Sec-WebSocket-Protocol mismatched.
     4        https://bugs.webkit.org/show_bug.cgi?id=82307
     5
     6        Reviewed by Kent Tamura.
     7
     8        From RFC6455: http://tools.ietf.org/html/rfc6455#section-4.1
     9        If the WebSocket openhanding respond included the mismatched
     10        Sec-WebSocket-Protocol header field, the client must fail the WebSocket Connection.
     11
     12        Test: http/tests/websocket/tests/hybi/handshake-fail-by-mismatch-protocol-header.html
     13
     14        * Modules/websockets/WebSocketHandshake.cpp:
     15        (WebCore::WebSocketHandshake::checkResponseHeaders):
     16
    1172012-03-28  Jessie Berlin  <jberlin@apple.com>
    218
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r110037 r112499  
    146146{
    147147    return webSocketsAvailable;
     148}
     149
     150const char* WebSocket::subProtocolSeperator()
     151{
     152    return ", ";
    148153}
    149154
     
    268273
    269274        if (!protocols.isEmpty())
    270             protocolString = joinStrings(protocols, ", ");
     275            protocolString = joinStrings(protocols, subProtocolSeperator());
    271276    }
    272277
  • trunk/Source/WebCore/Modules/websockets/WebSocket.h

    r107769 r112499  
    5454    static void setIsAvailable(bool);
    5555    static bool isAvailable();
     56    static const char* subProtocolSeperator();
    5657    static PassRefPtr<WebSocket> create(ScriptExecutionContext*);
    5758    virtual ~WebSocket();
  • trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp

    r112377 r112499  
    3535
    3636#include "WebSocketHandshake.h"
     37#include "WebSocket.h"
    3738
    3839#include "Base64.h"
     
    728729            return false;
    729730        }
     731        if (!serverWebSocketProtocol.isNull()) {
     732            if (m_clientProtocol.isEmpty()) {
     733                m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch";
     734                return false;
     735            }
     736            Vector<String> result;
     737            m_clientProtocol.split(String(WebSocket::subProtocolSeperator()), result);
     738            if (!result.contains(serverWebSocketProtocol)) {
     739                m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch";
     740                return false;
     741            }
     742        }
    730743    }
    731744    return true;
Note: See TracChangeset for help on using the changeset viewer.