<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212279] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212279">212279</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2017-02-13 23:43:28 -0800 (Mon, 13 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>URLs with an invalid IPv4 address should be invalid
https://bugs.webkit.org/show_bug.cgi?id=168260
Reviewed by Tim Horton.
LayoutTests/imported/w3c:
* web-platform-tests/url/a-element-expected.txt:
* web-platform-tests/url/a-element-xhtml-expected.txt:
* web-platform-tests/url/url-constructor-expected.txt:
Source/WebCore:
All URL hosts are fed through the IPv4 parser. https://webkit.org/ doesn't
look enough like an IPv4 address to be considered an invalid IPv4 address, so
we continue to the String host processing. http://127.0.0.257 does, though, and
according to https://url.spec.whatwg.org/#concept-ipv4-parser parsing that URL
should fail.
Covered by newly passing web platform tests.
* platform/URLParser.cpp:
(WebCore::URLParser::parseIPv4Host):
(WebCore::URLParser::parseHostAndPort):
* platform/URLParser.h:
Source/WTF:
* wtf/Expected.h:
(WTF::Expected::value):
Added missing WTFMove for rvalue Expected::value().
Tools:
* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::TEST_F):
Update tests to reflect new correct behavior.
LayoutTests:
* fetch/fetch-url-serialization-expected.txt:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfetchfetchurlserializationexpectedtxt">trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsurlaelementexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsurlaelementxhtmlexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsurlurlconstructorexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfExpectedh">trunk/Source/WTF/wtf/Expected.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformURLParsercpp">trunk/Source/WebCore/platform/URLParser.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformURLParserh">trunk/Source/WebCore/platform/URLParser.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreURLParsercpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/ChangeLog        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-02-13 Alex Christensen <achristensen@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * fetch/fetch-url-serialization-expected.txt:
+
</ins><span class="cx"> 2017-02-13 Karim H <karim@karhm.com>
</span><span class="cx">
</span><span class="cx"> Added the BSTR roles tag test for Windows.
</span></span></pre></div>
<a id="trunkLayoutTestsfetchfetchurlserializationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/fetch/fetch-url-serialization-expected.txt        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -264,7 +264,7 @@
</span><span class="cx"> PASS Testing Request url 'http://hello%00' with base 'http://other.com/'
</span><span class="cx"> PASS Testing Request url 'http://%30%78%63%30%2e%30%32%35%30.01' with base 'http://other.com/'
</span><span class="cx"> PASS Testing Request url 'http://%30%78%63%30%2e%30%32%35%30.01%2e' with base 'http://other.com/'
</span><del>-FAIL Testing Request url 'http://192.168.0.257' with base 'http://other.com/' assert_throws: function "function () { new Request(url.input); }" did not throw
</del><ins>+PASS Testing Request url 'http://192.168.0.257' with base 'http://other.com/'
</ins><span class="cx"> PASS Testing Request url 'http://%3g%78%63%30%2e%30%32%35%30%2E.01' with base 'http://other.com/'
</span><span class="cx"> PASS Testing Request url 'http://192.168.0.1 hello' with base 'http://other.com/'
</span><span class="cx"> PASS Testing Request url 'http://0Xc0.0250.01' with base 'http://other.com/'
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2017-02-13 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><ins>+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * web-platform-tests/url/a-element-expected.txt:
+ * web-platform-tests/url/a-element-xhtml-expected.txt:
+ * web-platform-tests/url/url-constructor-expected.txt:
+
+2017-02-13 Alex Christensen <achristensen@webkit.org>
+
</ins><span class="cx"> Percent should be allowed in non-special URL hosts
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=168255
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsurlaelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-expected.txt        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -278,7 +278,7 @@
</span><span class="cx"> PASS Parsing: <http://hello%00> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
</span><del>-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
</span><span class="lines">@@ -372,13 +372,13 @@
</span><span class="cx"> PASS Parsing: <http://256.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999.com> against <http://other.com/>
</span><del>-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://10000000000> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://10000000000.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://4294967295> against <http://other.com/>
</span><del>-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://4294967296> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://0xffffffff> against <http://other.com/>
</span><del>-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <file:///C%3A/> against <about:blank>
</span><span class="cx"> PASS Parsing: <file:///C%7C/> against <about:blank>
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsurlaelementxhtmlexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml-expected.txt        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -278,7 +278,7 @@
</span><span class="cx"> PASS Parsing: <http://hello%00> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
</span><del>-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
</span><span class="lines">@@ -372,13 +372,13 @@
</span><span class="cx"> PASS Parsing: <http://256.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999.com> against <http://other.com/>
</span><del>-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://10000000000> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://10000000000.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://4294967295> against <http://other.com/>
</span><del>-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://4294967296> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://0xffffffff> against <http://other.com/>
</span><del>-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_unreached: Expected URL to fail parsing Reached unreachable code
</del><ins>+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <file:///C%3A/> against <about:blank>
</span><span class="cx"> PASS Parsing: <file:///C%7C/> against <about:blank>
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsurlurlconstructorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-constructor-expected.txt        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -284,9 +284,7 @@
</span><span class="cx"> PASS Parsing: <http://hello%00> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://%30%78%63%30%2e%30%32%35%30.01%2e> against <http://other.com/>
</span><del>-FAIL Parsing: <http://192.168.0.257> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
</del><ins>+PASS Parsing: <http://192.168.0.257> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://%3g%78%63%30%2e%30%32%35%30%2E.01> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://192.168.0.1 hello> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://0Xc0.0250.01> against <http://other.com/>
</span><span class="lines">@@ -382,21 +380,13 @@
</span><span class="cx"> PASS Parsing: <http://256.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://999999999.com> against <http://other.com/>
</span><del>-FAIL Parsing: <http://10000000000> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
</del><ins>+PASS Parsing: <http://10000000000> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://10000000000.com> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <http://4294967295> against <http://other.com/>
</span><del>-FAIL Parsing: <http://4294967296> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
</del><ins>+PASS Parsing: <http://4294967296> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://0xffffffff> against <http://other.com/>
</span><del>-FAIL Parsing: <http://0xffffffff1> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
-FAIL Parsing: <http://256.256.256.256> against <http://other.com/> assert_throws: function "function () {
- bURL(expected.input, expected.base)
- }" did not throw
</del><ins>+PASS Parsing: <http://0xffffffff1> against <http://other.com/>
+PASS Parsing: <http://256.256.256.256> against <http://other.com/>
</ins><span class="cx"> PASS Parsing: <http://256.256.256.256.256> against <http://other.com/>
</span><span class="cx"> PASS Parsing: <file:///C%3A/> against <about:blank>
</span><span class="cx"> PASS Parsing: <file:///C%7C/> against <about:blank>
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WTF/ChangeLog        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-13 Alex Christensen <achristensen@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * wtf/Expected.h:
+ (WTF::Expected::value):
+ Added missing WTFMove for rvalue Expected::value().
+
</ins><span class="cx"> 2017-02-13 Said Abou-Hallawa <sabouhallawa@apple.com>
</span><span class="cx">
</span><span class="cx"> The current frame of an image should not deleted if another frame is asynchronously being decoded
</span></span></pre></div>
<a id="trunkSourceWTFwtfExpectedh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Expected.h (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Expected.h        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WTF/wtf/Expected.h        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -315,7 +315,7 @@
</span><span class="cx"> constexpr const ValueType& value() const & { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
</span><span class="cx"> RELAXED_CONSTEXPR ValueType& value() & { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
</span><span class="cx"> constexpr const ValueType&& value() const && { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
</span><del>- RELAXED_CONSTEXPR ValueType&& value() && { return base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val); }
</del><ins>+ RELAXED_CONSTEXPR ValueType&& value() && { return WTFMove(base::has ? base::s.val : (ExpectedDetail::Throw(), base::s.val)); }
</ins><span class="cx"> constexpr const ErrorType& error() const & { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
</span><span class="cx"> ErrorType& error() & { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
</span><span class="cx"> RELAXED_CONSTEXPR ErrorType&& error() && { return !base::has ? base::s.err : (ExpectedDetail::Throw(), base::s.err); }
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/ChangeLog        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-02-13 Alex Christensen <achristensen@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ All URL hosts are fed through the IPv4 parser. https://webkit.org/ doesn't
+ look enough like an IPv4 address to be considered an invalid IPv4 address, so
+ we continue to the String host processing. http://127.0.0.257 does, though, and
+ according to https://url.spec.whatwg.org/#concept-ipv4-parser parsing that URL
+ should fail.
+
+ Covered by newly passing web platform tests.
+
+ * platform/URLParser.cpp:
+ (WebCore::URLParser::parseIPv4Host):
+ (WebCore::URLParser::parseHostAndPort):
+ * platform/URLParser.h:
+
</ins><span class="cx"> 2017-02-13 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> Reverted r212275. It still breaks some Apple-internal builds.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.cpp (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.cpp        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/platform/URLParser.cpp        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -2130,8 +2130,13 @@
</span><span class="cx"> appendToASCIIBuffer(']');
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+enum class URLParser::IPv4PieceParsingError {
+ Failure,
+ Overflow,
+};
+
</ins><span class="cx"> template<typename CharacterType>
</span><del>-std::optional<uint32_t> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
</del><ins>+Expected<uint32_t, URLParser::IPv4PieceParsingError> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
</ins><span class="cx"> {
</span><span class="cx"> enum class State : uint8_t {
</span><span class="cx"> UnknownBase,
</span><span class="lines">@@ -2143,7 +2148,7 @@
</span><span class="cx"> State state = State::UnknownBase;
</span><span class="cx"> Checked<uint32_t, RecordOverflow> value = 0;
</span><span class="cx"> if (!iterator.atEnd() && *iterator == '.')
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Failure);
</ins><span class="cx"> while (!iterator.atEnd()) {
</span><span class="cx"> if (isTabOrNewline(*iterator)) {
</span><span class="cx"> didSeeSyntaxViolation = true;
</span><span class="lines">@@ -2174,31 +2179,31 @@
</span><span class="cx"> break;
</span><span class="cx"> case State::Decimal:
</span><span class="cx"> if (!isASCIIDigit(*iterator))
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Failure);
</ins><span class="cx"> value *= 10;
</span><span class="cx"> value += *iterator - '0';
</span><span class="cx"> if (UNLIKELY(value.hasOverflowed()))
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Overflow);
</ins><span class="cx"> ++iterator;
</span><span class="cx"> break;
</span><span class="cx"> case State::Octal:
</span><span class="cx"> ASSERT(didSeeSyntaxViolation);
</span><span class="cx"> if (*iterator < '0' || *iterator > '7')
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Failure);
</ins><span class="cx"> value *= 8;
</span><span class="cx"> value += *iterator - '0';
</span><span class="cx"> if (UNLIKELY(value.hasOverflowed()))
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Overflow);
</ins><span class="cx"> ++iterator;
</span><span class="cx"> break;
</span><span class="cx"> case State::Hex:
</span><span class="cx"> ASSERT(didSeeSyntaxViolation);
</span><span class="cx"> if (!isASCIIHexDigit(*iterator))
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Failure);
</ins><span class="cx"> value *= 16;
</span><span class="cx"> value += toASCIIHexValue(*iterator);
</span><span class="cx"> if (UNLIKELY(value.hasOverflowed()))
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4PieceParsingError::Overflow);
</ins><span class="cx"> ++iterator;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -2214,12 +2219,18 @@
</span><span class="cx"> return values[exponent];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+enum class URLParser::IPv4ParsingError {
+ Failure,
+ NotIPv4,
+};
+
</ins><span class="cx"> template<typename CharacterTypeForSyntaxViolation, typename CharacterType>
</span><del>-std::optional<URLParser::IPv4Address> URLParser::parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>& iteratorForSyntaxViolationPosition, CodePointIterator<CharacterType> iterator)
</del><ins>+Expected<URLParser::IPv4Address, URLParser::IPv4ParsingError> URLParser::parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>& iteratorForSyntaxViolationPosition, CodePointIterator<CharacterType> iterator)
</ins><span class="cx"> {
</span><del>- Vector<uint32_t, 4> items;
- items.reserveInitialCapacity(4);
</del><ins>+ Vector<Expected<uint32_t, URLParser::IPv4PieceParsingError>, 4> items;
</ins><span class="cx"> bool didSeeSyntaxViolation = false;
</span><ins>+ if (!iterator.atEnd() && *iterator == '.')
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
</ins><span class="cx"> while (!iterator.atEnd()) {
</span><span class="cx"> if (isTabOrNewline(*iterator)) {
</span><span class="cx"> didSeeSyntaxViolation = true;
</span><span class="lines">@@ -2227,35 +2238,39 @@
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx"> if (items.size() >= 4)
</span><del>- return std::nullopt;
- if (auto item = parseIPv4Piece(iterator, didSeeSyntaxViolation))
- items.append(item.value());
- else
- return std::nullopt;
- if (!iterator.atEnd()) {
- if (items.size() >= 4)
- return std::nullopt;
- if (*iterator == '.')
- ++iterator;
- else
- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ items.append(parseIPv4Piece(iterator, didSeeSyntaxViolation));
+ if (!iterator.atEnd() && *iterator == '.') {
+ ++iterator;
+ if (iterator.atEnd())
+ syntaxViolation(iteratorForSyntaxViolationPosition);
+ else if (*iterator == '.')
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> if (!iterator.atEnd() || !items.size() || items.size() > 4)
</span><del>- return std::nullopt;
</del><ins>+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ for (const auto& item : items) {
+ if (!item.hasValue() && item.error() == IPv4PieceParsingError::Failure)
+ return makeUnexpected(IPv4ParsingError::NotIPv4);
+ }
+ for (const auto& item : items) {
+ if (!item.hasValue() && item.error() == IPv4PieceParsingError::Overflow)
+ return makeUnexpected(IPv4ParsingError::Failure);
+ }
</ins><span class="cx"> if (items.size() > 1) {
</span><span class="cx"> for (size_t i = 0; i < items.size() - 1; i++) {
</span><del>- if (items[i] > 255)
- return std::nullopt;
</del><ins>+ if (items[i].value() > 255)
+ return makeUnexpected(IPv4ParsingError::Failure);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><del>- if (items[items.size() - 1] >= pow256(5 - items.size()))
- return std::nullopt;
</del><ins>+ if (items[items.size() - 1].value() >= pow256(5 - items.size()))
+ return makeUnexpected(IPv4ParsingError::Failure);
</ins><span class="cx">
</span><span class="cx"> if (didSeeSyntaxViolation)
</span><span class="cx"> syntaxViolation(iteratorForSyntaxViolationPosition);
</span><del>- for (auto item : items) {
- if (item > 255)
</del><ins>+ for (const auto& item : items) {
+ if (item.value() > 255)
</ins><span class="cx"> syntaxViolation(iteratorForSyntaxViolationPosition);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2262,9 +2277,9 @@
</span><span class="cx"> if (UNLIKELY(items.size() != 4))
</span><span class="cx"> syntaxViolation(iteratorForSyntaxViolationPosition);
</span><span class="cx">
</span><del>- IPv4Address ipv4 = items.takeLast();
</del><ins>+ IPv4Address ipv4 = items.takeLast().value();
</ins><span class="cx"> for (size_t counter = 0; counter < items.size(); ++counter)
</span><del>- ipv4 += items[counter] * pow256(3 - counter);
</del><ins>+ ipv4 += items[counter].value() * pow256(3 - counter);
</ins><span class="cx"> return ipv4;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2634,7 +2649,8 @@
</span><span class="cx"> if (isForbiddenHostCodePoint(*iterator))
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><del>- if (auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator))) {
</del><ins>+ auto address = parseIPv4Host(hostIterator, CodePointIterator<CharacterType>(hostIterator, iterator));
+ if (address) {
</ins><span class="cx"> serializeIPv4(address.value());
</span><span class="cx"> m_url.m_hostEnd = currentPosition(iterator);
</span><span class="cx"> if (iterator.atEnd()) {
</span><span class="lines">@@ -2643,6 +2659,8 @@
</span><span class="cx"> }
</span><span class="cx"> return parsePort(iterator);
</span><span class="cx"> }
</span><ins>+ if (address.error() == IPv4ParsingError::Failure)
+ return false;
</ins><span class="cx"> for (; hostIterator != iterator; ++hostIterator) {
</span><span class="cx"> if (UNLIKELY(isTabOrNewline(*hostIterator))) {
</span><span class="cx"> syntaxViolation(hostIterator);
</span><span class="lines">@@ -2692,7 +2710,8 @@
</span><span class="cx"> Vector<LChar, defaultInlineBufferSize>& asciiDomainValue = asciiDomain.value();
</span><span class="cx"> const LChar* asciiDomainCharacters = asciiDomainValue.data();
</span><span class="cx">
</span><del>- if (auto address = parseIPv4Host(hostBegin, CodePointIterator<LChar>(asciiDomainValue.begin(), asciiDomainValue.end()))) {
</del><ins>+ auto address = parseIPv4Host(hostBegin, CodePointIterator<LChar>(asciiDomainValue.begin(), asciiDomainValue.end()));
+ if (address) {
</ins><span class="cx"> serializeIPv4(address.value());
</span><span class="cx"> m_url.m_hostEnd = currentPosition(iterator);
</span><span class="cx"> if (iterator.atEnd()) {
</span><span class="lines">@@ -2701,6 +2720,8 @@
</span><span class="cx"> }
</span><span class="cx"> return parsePort(iterator);
</span><span class="cx"> }
</span><ins>+ if (address.error() == IPv4ParsingError::Failure)
+ return false;
</ins><span class="cx">
</span><span class="cx"> appendToASCIIBuffer(asciiDomainCharacters, asciiDomainValue.size());
</span><span class="cx"> m_url.m_hostEnd = currentPosition(iterator);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.h (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.h        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Source/WebCore/platform/URLParser.h        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> #include "TextEncoding.h"
</span><span class="cx"> #include "URL.h"
</span><ins>+#include <wtf/Expected.h>
</ins><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx">
</span><span class="cx"> struct UIDNA;
</span><span class="lines">@@ -110,8 +111,10 @@
</span><span class="cx">
</span><span class="cx"> using IPv4Address = uint32_t;
</span><span class="cx"> void serializeIPv4(IPv4Address);
</span><del>- template<typename CharacterTypeForSyntaxViolation, typename CharacterType> std::optional<IPv4Address> parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>&, CodePointIterator<CharacterType>);
- template<typename CharacterType> std::optional<uint32_t> parseIPv4Piece(CodePointIterator<CharacterType>&, bool& syntaxViolation);
</del><ins>+ enum class IPv4ParsingError;
+ enum class IPv4PieceParsingError;
+ template<typename CharacterTypeForSyntaxViolation, typename CharacterType> Expected<IPv4Address, IPv4ParsingError> parseIPv4Host(const CodePointIterator<CharacterTypeForSyntaxViolation>&, CodePointIterator<CharacterType>);
+ template<typename CharacterType> Expected<uint32_t, URLParser::IPv4PieceParsingError> parseIPv4Piece(CodePointIterator<CharacterType>&, bool& syntaxViolation);
</ins><span class="cx"> using IPv6Address = std::array<uint16_t, 8>;
</span><span class="cx"> template<typename CharacterType> std::optional<IPv6Address> parseIPv6Host(CodePointIterator<CharacterType>);
</span><span class="cx"> template<typename CharacterType> std::optional<uint32_t> parseIPv4PieceInsideIPv6(CodePointIterator<CharacterType>&);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Tools/ChangeLog        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-13 Alex Christensen <achristensen@webkit.org>
+
+ URLs with an invalid IPv4 address should be invalid
+ https://bugs.webkit.org/show_bug.cgi?id=168260
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+ (TestWebKitAPI::TEST_F):
+ Update tests to reflect new correct behavior.
+
</ins><span class="cx"> 2017-02-13 Don Olmstead <don.olmstead@am.sony.com>
</span><span class="cx">
</span><span class="cx"> [WinCairo] Add Build Slave
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (212278 => 212279)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2017-02-14 07:16:57 UTC (rev 212278)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2017-02-14 07:43:28 UTC (rev 212279)
</span><span class="lines">@@ -493,11 +493,22 @@
</span><span class="cx"> checkURL("http://\t//\\///user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
</span><span class="cx"> checkURL("http:/\\user:@webkit.org:99?foo", {"http", "user", "", "webkit.org", 99, "/", "foo", "", "http://user@webkit.org:99/?foo"});
</span><span class="cx"> checkURL("http://127.0.0.1", {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"});
</span><del>- checkURL("http://127.0.0.1.", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
- checkURL("http://127.0.0.1./", {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
- checkURL("http://0x100.0/", {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
- checkURL("http://0.0.0x100.0/", {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
- checkURL("http://0.0.0.0x100/", {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
</del><ins>+ checkURLDifferences("http://127.0.0.1.",
+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+ checkURLDifferences("http://127.0.0.1./",
+ {"http", "", "", "127.0.0.1", 0, "/", "", "", "http://127.0.0.1/"},
+ {"http", "", "", "127.0.0.1.", 0, "/", "", "", "http://127.0.0.1./"});
+ checkURL("http://127.0.0.1../", {"http", "", "", "127.0.0.1..", 0, "/", "", "", "http://127.0.0.1../"});
+ checkURLDifferences("http://0x100.0/",
+ {"", "", "", "", 0, "", "", "", "http://0x100.0/"},
+ {"http", "", "", "0x100.0", 0, "/", "", "", "http://0x100.0/"});
+ checkURLDifferences("http://0.0.0x100.0/",
+ {"", "", "", "", 0, "", "", "", "http://0.0.0x100.0/"},
+ {"http", "", "", "0.0.0x100.0", 0, "/", "", "", "http://0.0.0x100.0/"});
+ checkURLDifferences("http://0.0.0.0x100/",
+ {"", "", "", "", 0, "", "", "", "http://0.0.0.0x100/"},
+ {"http", "", "", "0.0.0.0x100", 0, "/", "", "", "http://0.0.0.0x100/"});
</ins><span class="cx"> checkURL("http://host:123?", {"http", "", "", "host", 123, "/", "", "", "http://host:123/?"});
</span><span class="cx"> checkURL("http://host:123?query", {"http", "", "", "host", 123, "/", "query", "", "http://host:123/?query"});
</span><span class="cx"> checkURL("http://host:123#", {"http", "", "", "host", 123, "/", "", "", "http://host:123/#"});
</span></span></pre>
</div>
</div>
</body>
</html>