From ae70ec0d28ec2d267a29f3466dda6aa7da5f5748 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Wed, 15 Oct 2014 16:29:11 -0400 Subject: [PATCH 1/2] Three-way merge with web-platform-tests https://github.com/w3c/web-platform-tests/blob/master/url/urltestdata.txt --- src/tests.rs | 7 +++++-- src/urltestdata.txt | 27 ++++++++++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index a0fbfdf96..20bdb8e75 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -77,7 +77,10 @@ fn url_parsing() { assert_eq!(password, expected_password); let host = host.serialize(); assert_eq!(host, expected_host) - assert_eq!(port, expected_port); + match port { + None => assert_eq!(None, expected_port), + Some(port) => assert_eq!(Some(port.to_string()), expected_port) + } assert_eq!(Some(format!("/{}", path.connect("/"))), expected_path); }, NonRelativeSchemeData(scheme_data) => { @@ -105,7 +108,7 @@ struct Test { username: String, password: Option, host: String, - port: Option, + port: Option, path: Option, query: Option, fragment: Option, diff --git a/src/urltestdata.txt b/src/urltestdata.txt index ce704df97..ec60a78b0 100644 --- a/src/urltestdata.txt +++ b/src/urltestdata.txt @@ -20,7 +20,7 @@ http://f:b/c http://f:\s/c http://f:\n/c s:http h:f p:/c http://f:fifty-two/c -http://f:9999/c s:http h:f port:9999 p:/c +XFAIL http://f:99999/c s:http h:f port:99999 p:/c http://f:\s21\s/\sb\s?\sd\s#\se\s s:http h:example.org p:/foo/bar \s\s\t s:http h:example.org p:/foo/bar @@ -99,9 +99,17 @@ mailto:example.com/ s:mailto p:example.com/ data:text/html,test#test s:data p:text/html,test f:#test # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/file.html + +# Basic canonicalization, uppercase should be converted to lowercase file:c:\\foo\\bar.html file:///tmp/mock/path s:file p:/c:/foo/bar.html + +# Spaces should fail \s\sFile:c|////foo\\bar.html s:file p:/c:////foo/bar.html + +# This should fail C|/foo/bar s:file p:/C:/foo/bar + +# This should fail /C|\\foo\\bar s:file p:/C:/foo/bar //C|/foo/bar s:file p:/C:/foo/bar //server/file s:file h:server p:/file @@ -252,6 +260,7 @@ test.txt s:http h:www.example.com p:/test.txt ../../test.txt s:http h:www.example.com p:/test.txt \u4E2D/test.txt s:http h:www.example.com p:/%E4%B8%AD/test.txt http://www.example2.com s:http h:www.example2.com p:/ +//www.example2.com s:http h:www.example2.com p:/ # Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/host.html @@ -264,21 +273,24 @@ http://example\sexample.com # This should fail http://Goo%20\sgoo%7C|.com -# This should fail +# U+3000 is mapped to U+0020 (space) which is disallowed http://GOO\u00a0\u3000goo.com # Other types of space (no-break, zero-width, zero-width-no-break) are # name-prepped away to nothing. +# U+200B, U+2060, and U+FEFF, are ignored XFAIL http://GOO\u200b\u2060\ufeffgoo.com s:http p:/ h:googoo.com # Ideographic full stop (full-width period for Chinese, etc.) should be # treated as a dot. +# U+3002 is mapped to U+002E (dot) XFAIL http://www.foo\u3002bar.com s:http p:/ h:www.foo.bar.com # Invalid unicode characters should fail... +# U+FDD0 is disallowed; %ef%b7%90 is U+FDD0 http://\ufdd0zyx.com -# ...This is the same as previous but with with escaped. +# ...This is the same as previous but escaped. http://%ef%b7%90zyx.com # Test name prepping, fullwidth input should be converted to ASCII and NOT @@ -306,8 +318,10 @@ http://%25 http://hello%00 # Escaped numbers should be treated like IP addresses if they are. +# No special handling for IPv4 or IPv4-like URLs XFAIL http://%30%78%63%30%2e%30%32%35%30.01 s:http p:/ h:127.0.0.1 -XFAIL http://%30%78%63%30%2e%30%32%35%30.01%2e +http://%30%78%63%30%2e%30%32%35%30.01%2e s:http p:/ h:0xc0.0250.01. +http://192.168.0.257 s:http p:/ h:192.168.0.257 # Invalid escaping should trigger the regular host error handling. http://%3g%78%63%30%2e%30%32%35%30%2E.01 @@ -318,8 +332,7 @@ http://192.168.0.1\shello # Fullwidth and escaped UTF-8 fullwidth should still be treated as IP. # These are "0Xc0.0250.01" in fullwidth. -XFAIL http://\uff10\uff38\uff43\uff10\uff0e\uff10\uff12\uff15\uff10\uff0e\uff10\uff11 s:http p:/ h:192.168.0.1 +XFAIL http://\uff10\uff38\uff43\uff10\uff0e\uff10\uff12\uff15\uff10\uff0e\uff10\uff11 s:http p:/ h:0xc0.0250.01 -# Broken IP addresses. -XFAIL http://192.168.0.257 +# Broken IPv6 http://[google.com] From 84f534040ab3bbbf15cf4e052ff3557c61d5a604 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 16 Oct 2014 08:58:11 -0400 Subject: [PATCH 2/2] actually, web-platform-tests has one more nine --- src/urltestdata.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/urltestdata.txt b/src/urltestdata.txt index ec60a78b0..ea16b42f6 100644 --- a/src/urltestdata.txt +++ b/src/urltestdata.txt @@ -20,7 +20,7 @@ http://f:b/c http://f:\s/c http://f:\n/c s:http h:f p:/c http://f:fifty-two/c -XFAIL http://f:99999/c s:http h:f port:99999 p:/c +XFAIL http://f:999999/c s:http h:f port:999999 p:/c http://f:\s21\s/\sb\s?\sd\s#\se\s s:http h:example.org p:/foo/bar \s\s\t s:http h:example.org p:/foo/bar