Changeset 230052 in webkit


Ignore:
Timestamp:
Mar 28, 2018 2:27:44 PM (6 years ago)
Author:
dbates@webkit.org
Message:

WebSocket cookie incorrectly stored
https://bugs.webkit.org/show_bug.cgi?id=184100
<rdar://problem/37928715>

Reviewed by Brent Fulgham.

Source/WebCore:

A cookie received in a WebSocket response should be stored with respect to the
origin of the WebSocket server in order for it to be sent in a subsequent request.

Also removed a FIXME about implementing support for the long since
deprecated Set-Cookie2 header.

Test: http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior.html

  • Modules/websockets/WebSocketChannel.cpp:

(WebCore::WebSocketChannel::processBuffer):

  • Modules/websockets/WebSocketHandshake.h:

LayoutTests:

  • http/tests/websocket/tests/hybi/cookie_wsh.py: Added. Downloaded from

<https://github.com/w3c/pywebsocket/blob/b2e1d11086fdf00b33a0d30c504f227e7d4fa86b/src/example/cookie_wsh.py>.
(_add_set_cookie):
(web_socket_do_extra_handshake):
(web_socket_transfer_data):

  • http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior-expected.txt: Added.
  • http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior.html: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r230046 r230052  
     12018-03-28  Daniel Bates  <dabates@apple.com>
     2
     3        WebSocket cookie incorrectly stored
     4        https://bugs.webkit.org/show_bug.cgi?id=184100
     5        <rdar://problem/37928715>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * http/tests/websocket/tests/hybi/cookie_wsh.py: Added. Downloaded from
     10        <https://github.com/w3c/pywebsocket/blob/b2e1d11086fdf00b33a0d30c504f227e7d4fa86b/src/example/cookie_wsh.py>.
     11        (_add_set_cookie):
     12        (web_socket_do_extra_handshake):
     13        (web_socket_transfer_data):
     14        * http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior-expected.txt: Added.
     15        * http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior.html: Added.
     16
    1172018-03-28  Matt Lewis  <jlewis3@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r230051 r230052  
     12018-03-28  Daniel Bates  <dabates@apple.com>
     2
     3        WebSocket cookie incorrectly stored
     4        https://bugs.webkit.org/show_bug.cgi?id=184100
     5        <rdar://problem/37928715>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        A cookie received in a WebSocket response should be stored with respect to the
     10        origin of the WebSocket server in order for it to be sent in a subsequent request.
     11
     12        Also removed a FIXME about implementing support for the long since
     13        deprecated Set-Cookie2 header.
     14
     15        Test: http/tests/websocket/tests/hybi/websocket-cookie-overwrite-behavior.html
     16
     17        * Modules/websockets/WebSocketChannel.cpp:
     18        (WebCore::WebSocketChannel::processBuffer):
     19        * Modules/websockets/WebSocketHandshake.h:
     20
    1212018-03-28  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp

    r228218 r230052  
    444444            if (m_identifier)
    445445                InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(m_document, m_identifier, m_handshake->serverHandshakeResponse());
    446             if (!m_handshake->serverSetCookie().isEmpty()) {
    447                 if (m_document && cookiesEnabled(*m_document)) {
    448                     // Exception (for sandboxed documents) ignored.
    449                     m_document->setCookie(m_handshake->serverSetCookie());
    450                 }
     446            String serverSetCookie = m_handshake->serverSetCookie();
     447            if (!serverSetCookie.isEmpty()) {
     448                if (m_document && cookiesEnabled(*m_document))
     449                    setCookies(*m_document, m_handshake->httpURLForAuthenticationAndCookies(), serverSetCookie);
    451450            }
    452             // FIXME: handle set-cookie2.
    453451            LOG(Network, "WebSocketChannel %p Connected", this);
    454452            skipBuffer(headerLength);
  • trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.h

    r221275 r230052  
    5353    const URL& url() const;
    5454    void setURL(const URL&);
     55    URL httpURLForAuthenticationAndCookies() const;
    5556    const String host() const;
    5657
     
    8788
    8889private:
    89     URL httpURLForAuthenticationAndCookies() const;
    9090
    9191    int readStatusLine(const char* header, size_t headerLength, int& statusCode, String& statusText);
Note: See TracChangeset for help on using the changeset viewer.