Bug 46008 - XMLHttpRequest: open() does not throw a SYNTAX_ERR exception if method is empty or url cannot be resolved
Summary: XMLHttpRequest: open() does not throw a SYNTAX_ERR exception if method is emp...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
: 189426 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-17 15:46 PDT by Jian Li
Modified: 2018-09-12 16:20 PDT (History)
11 users (show)

See Also:


Attachments
This patch checks if a url is invalid and throw syntax error if that's the case (830 bytes, patch)
2011-12-08 03:47 PST, Deqing Huang
ap: review-
Details | Formatted Diff | Diff
Patch (4.53 KB, patch)
2018-09-07 12:32 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jian Li 2010-09-17 15:46:31 PDT
open() does not throw a SYNTAX_ERR exception if method is empty. It does throw if method contains invalid string.

The XHR spec says:
   open(method, url, async, user, password)
   Sets the request method, request URL, asynchronous flag, request username, and request password.
   Throws a SYNTAX_ERR exception if one of the following is true:
         method is not a valid HTTP method.

TEST: http://tc.labs.opera.com/apis/XMLHttpRequest/open-method-bogus.htm
Comment 1 Jian Li 2010-09-17 17:05:39 PDT
Per the XHR spec, we should also throw a SYNTAX_ERR exception if url cannot be resolved.

http://tc.labs.opera.com/apis/XMLHttpRequest/open-url-bogus.htm
Comment 2 Deqing Huang 2011-12-08 03:47:18 PST
Created attachment 118359 [details]
This patch checks if a url is invalid and throw syntax error if that's the case
Comment 3 Alexey Proskuryakov 2011-12-08 08:44:23 PST
Comment on attachment 118359 [details]
This patch checks if a url is invalid and throw syntax error if that's the case

A fix like this needs to come with regression tests. A good place to add one is fast/xmlhttprequest.
Comment 4 Rob Buis 2018-09-07 12:32:36 PDT
Created attachment 349179 [details]
Patch
Comment 5 Frédéric Wang (:fredw) 2018-09-07 12:40:25 PDT
*** Bug 189426 has been marked as a duplicate of this bug. ***
Comment 6 Chris Dumez 2018-09-07 14:18:12 PDT
Comment on attachment 349179 [details]
Patch

r=me
Comment 7 WebKit Commit Bot 2018-09-07 14:43:42 PDT
Comment on attachment 349179 [details]
Patch

Clearing flags on attachment: 349179

Committed r235808: <https://trac.webkit.org/changeset/235808>
Comment 8 WebKit Commit Bot 2018-09-07 14:43:44 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-09-07 14:44:25 PDT
<rdar://problem/44239386>
Comment 10 Alicia Boya García 2018-09-12 16:14:31 PDT
This patch has regressed the following test in all platforms:

imported/w3c/web-platform-tests/url/failure.html

https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#tests=imported%2Fw3c%2Fweb-platform-tests%2Furl%2Ffailure.html&revision=235825

e.g:

FAIL XHR: http://user@/www.example.com should throw assert_throws: function "() => client.open("GET", test.input)" did not throw
Comment 11 Chris Dumez 2018-09-12 16:17:35 PDT
New passes. The test merely needs rebaselining.
Comment 12 Chris Dumez 2018-09-12 16:20:17 PDT
(In reply to Chris Dumez from comment #11)
> New passes. The test merely needs rebaselining.

Done in <https://trac.webkit.org/changeset/235958>.