Bug 42636 - WebSocket() constructor should throw SYNTAX_ERR if URL has zero or one slash after 'ws:' or 'wss:'
Summary: WebSocket() constructor should throw SYNTAX_ERR if URL has zero or one slash ...
Status: VERIFIED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-20 06:36 PDT by Simon Pieters (:zcorpan)
Modified: 2016-05-19 02:36 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pieters (:zcorpan) 2010-07-20 06:36:21 PDT
WebKit implies the slashes if they're missing in WebSocket URLs.

new WebSocket('ws:example.org/');
new WebSocket('ws:/example.org/');

Apparently no slashes means no authority (user/pass+host+port), which doesn't
make sense for websocket, and websocket requires an absolute URL. So I think
the above cases should throw SYNTAX_ERR.

Also see https://bugzilla.mozilla.org/show_bug.cgi?id=580234
Comment 1 Alexey Proskuryakov 2010-07-20 10:10:44 PDT
Mozilla folks seem to disagree that this is a bug, and I think they are right.
Comment 2 Alexey Proskuryakov 2010-11-30 21:41:03 PST
http://www.w3.org/Bugs/Public/show_bug.cgi?id=10213
Comment 3 Brent Fulgham 2016-05-18 21:26:46 PDT
Since Mozilla and Alexey think current behavior is correct, closing this.
Comment 4 Simon Pieters (:zcorpan) 2016-05-19 02:35:02 PDT
https://www.w3.org/Bugs/Public/show_bug.cgi?id=17772#c5

e.g. for ws:example.org/ (no base url)

https://url.spec.whatwg.org/#scheme-state
"Otherwise, if url is special, set state to special authority slashes state."
->
https://url.spec.whatwg.org/#special-authority-slashes-state
"Otherwise, syntax violation, set state to special authority ignore slashes state, and decrease pointer by one."
->
https://url.spec.whatwg.org/#special-authority-ignore-slashes-state
"If c is neither "/" nor "\", set state to authority state, and decrease pointer by one."
->
https://url.spec.whatwg.org/#authority-state
"Otherwise, append c to buffer."

...etc; it will parse successfully and up with the same URL record as for ws://example.org/
Comment 5 Simon Pieters (:zcorpan) 2016-05-19 02:36:22 PDT
w-p-t test at 
http://w3c-test.org/websockets/constructor/017.html