<!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>[206887] 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/206887">206887</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-10-06 16:05:17 -0700 (Thu, 06 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>URLParser: Non-ASCII characters in Non-UTF-8 encoded queries of relative URLs with ws, wss, or nonspecial schemes should be UTF-8 encoded
https://bugs.webkit.org/show_bug.cgi?id=163089

Reviewed by Tim Horton.

Source/WebCore:

This is a change similar to <a href="http://trac.webkit.org/projects/webkit/changeset/206818">r206818</a> but with relative URLs.
This matches the spec, URL::parse, and other browsers' behavior.
Covered by new API tests for URLParser.
This also fixes tests like http/tests/misc/url-in-utf32le.html when URLParser is enabled.

* platform/URL.cpp:
(WebCore::URL::URL):
Use the same encoding for the URL constructor whether or not the URLParser is enabled.
* platform/URLParser.cpp:
(WebCore::URLParser::copyURLPartsUntil):
(WebCore::URLParser::parse):
(WebCore::isSpecial): Deleted.
* platform/URLParser.h:
Use UTF-8 for non-special, ws, or wss schemes.

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformURLcpp">trunk/Source/WebCore/platform/URL.cpp</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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Source/WebCore/ChangeLog        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-10-06  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        URLParser: Non-ASCII characters in Non-UTF-8 encoded queries of relative URLs with ws, wss, or nonspecial schemes should be UTF-8 encoded
+        https://bugs.webkit.org/show_bug.cgi?id=163089
+
+        Reviewed by Tim Horton.
+
+        This is a change similar to r206818 but with relative URLs.
+        This matches the spec, URL::parse, and other browsers' behavior.
+        Covered by new API tests for URLParser.
+        This also fixes tests like http/tests/misc/url-in-utf32le.html when URLParser is enabled.
+
+        * platform/URL.cpp:
+        (WebCore::URL::URL):
+        Use the same encoding for the URL constructor whether or not the URLParser is enabled.
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::copyURLPartsUntil):
+        (WebCore::URLParser::parse):
+        (WebCore::isSpecial): Deleted.
+        * platform/URLParser.h:
+        Use UTF-8 for non-special, ws, or wss schemes.
+
</ins><span class="cx"> 2016-10-06  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add back ASSERT(!needsLayout) to RenderTableSection which is now valid
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URL.cpp (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URL.cpp        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Source/WebCore/platform/URL.cpp        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -464,14 +464,14 @@
</span><span class="cx"> 
</span><span class="cx"> URL::URL(const URL&amp; base, const String&amp; relative, const TextEncoding&amp; encoding)
</span><span class="cx"> {
</span><ins>+    // For UTF-{7,16,32}, we want to use UTF-8 for the query part as
+    // we do when submitting a form. A form with GET method
+    // has its contents added to a URL as query params and it makes sense
+    // to be consistent.
</ins><span class="cx">     if (URLParser::enabled()) {
</span><del>-        URLParser parser(relative, base, encoding);
</del><ins>+        URLParser parser(relative, base, encoding.encodingForFormSubmission());
</ins><span class="cx">         *this = parser.result();
</span><span class="cx">     } else {
</span><del>-        // For UTF-{7,16,32}, we want to use UTF-8 for the query part as
-        // we do when submitting a form. A form with GET method
-        // has its contents added to a URL as query params and it makes sense
-        // to be consistent.
</del><span class="cx">         init(base, relative, encoding.encodingForFormSubmission());
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.cpp (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.cpp        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Source/WebCore/platform/URLParser.cpp        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -688,24 +688,6 @@
</span><span class="cx">     NonSpecial
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-ALWAYS_INLINE bool isSpecial(Scheme scheme)
-{
-    switch (scheme) {
-    case Scheme::WS:
-    case Scheme::WSS:
-    case Scheme::File:
-    case Scheme::FTP:
-    case Scheme::Gopher:
-    case Scheme::HTTP:
-    case Scheme::HTTPS:
-        return true;
-    case Scheme::NonSpecial:
-        return false;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
</del><span class="cx"> ALWAYS_INLINE static Scheme scheme(StringView scheme)
</span><span class="cx"> {
</span><span class="cx">     auto length = scheme.length();
</span><span class="lines">@@ -834,7 +816,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename CharacterType&gt;
</span><del>-void URLParser::copyURLPartsUntil(const URL&amp; base, URLPart part, const CodePointIterator&lt;CharacterType&gt;&amp; iterator)
</del><ins>+void URLParser::copyURLPartsUntil(const URL&amp; base, URLPart part, const CodePointIterator&lt;CharacterType&gt;&amp; iterator, bool&amp; isUTF8Encoding)
</ins><span class="cx"> {
</span><span class="cx">     syntaxViolation(iterator);
</span><span class="cx"> 
</span><span class="lines">@@ -873,7 +855,24 @@
</span><span class="cx">         m_url.m_protocolIsInHTTPFamily = base.m_protocolIsInHTTPFamily;
</span><span class="cx">         m_url.m_schemeEnd = base.m_schemeEnd;
</span><span class="cx">     }
</span><del>-    m_urlIsSpecial = isSpecial(scheme(StringView(m_asciiBuffer.data(), m_url.m_schemeEnd)));
</del><ins>+    switch (scheme(StringView(m_asciiBuffer.data(), m_url.m_schemeEnd))) {
+    case Scheme::WS:
+    case Scheme::WSS:
+        isUTF8Encoding = true;
+        FALLTHROUGH;
+    case Scheme::File:
+    case Scheme::FTP:
+    case Scheme::Gopher:
+    case Scheme::HTTP:
+    case Scheme::HTTPS:
+        m_urlIsSpecial = true;
+        return;
+    case Scheme::NonSpecial:
+        m_urlIsSpecial = false;
+        isUTF8Encoding = true;
+        return;
+    }
+    ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static const char* dotASCIICode = &quot;2e&quot;;
</span><span class="lines">@@ -1308,7 +1307,7 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">             if (base.m_cannotBeABaseURL &amp;&amp; *c == '#') {
</span><del>-                copyURLPartsUntil(base, URLPart::QueryEnd, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::QueryEnd, c, isUTF8Encoding);
</ins><span class="cx">                 state = State::Fragment;
</span><span class="cx">                 appendToASCIIBuffer('#');
</span><span class="cx">                 ++c;
</span><span class="lines">@@ -1318,7 +1317,7 @@
</span><span class="cx">                 state = State::Relative;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><del>-            copyURLPartsUntil(base, URLPart::SchemeEnd, c);
</del><ins>+            copyURLPartsUntil(base, URLPart::SchemeEnd, c, isUTF8Encoding);
</ins><span class="cx">             appendToASCIIBuffer(':');
</span><span class="cx">             state = State::File;
</span><span class="cx">             break;
</span><span class="lines">@@ -1368,7 +1367,7 @@
</span><span class="cx">                 ++c;
</span><span class="cx">                 break;
</span><span class="cx">             case '?':
</span><del>-                copyURLPartsUntil(base, URLPart::PathEnd, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::PathEnd, c, isUTF8Encoding);
</ins><span class="cx">                 appendToASCIIBuffer('?');
</span><span class="cx">                 ++c;
</span><span class="cx">                 if (isUTF8Encoding)
</span><span class="lines">@@ -1379,13 +1378,13 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">             case '#':
</span><del>-                copyURLPartsUntil(base, URLPart::QueryEnd, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::QueryEnd, c, isUTF8Encoding);
</ins><span class="cx">                 appendToASCIIBuffer('#');
</span><span class="cx">                 state = State::Fragment;
</span><span class="cx">                 ++c;
</span><span class="cx">                 break;
</span><span class="cx">             default:
</span><del>-                copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c, isUTF8Encoding);
</ins><span class="cx">                 state = State::Path;
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="lines">@@ -1394,11 +1393,11 @@
</span><span class="cx">             LOG_STATE(&quot;RelativeSlash&quot;);
</span><span class="cx">             if (*c == '/' || *c == '\\') {
</span><span class="cx">                 ++c;
</span><del>-                copyURLPartsUntil(base, URLPart::SchemeEnd, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::SchemeEnd, c, isUTF8Encoding);
</ins><span class="cx">                 appendToASCIIBuffer(&quot;://&quot;, 3);
</span><span class="cx">                 state = State::SpecialAuthorityIgnoreSlashes;
</span><span class="cx">             } else {
</span><del>-                copyURLPartsUntil(base, URLPart::PortEnd, c);
</del><ins>+                copyURLPartsUntil(base, URLPart::PortEnd, c, isUTF8Encoding);
</ins><span class="cx">                 appendToASCIIBuffer('/');
</span><span class="cx">                 m_url.m_pathAfterLastSlash = base.m_portEnd + 1;
</span><span class="cx">                 state = State::Path;
</span><span class="lines">@@ -1531,7 +1530,7 @@
</span><span class="cx">             case '?':
</span><span class="cx">                 syntaxViolation(c);
</span><span class="cx">                 if (base.isValid() &amp;&amp; base.protocolIs(&quot;file&quot;)) {
</span><del>-                    copyURLPartsUntil(base, URLPart::PathEnd, c);
</del><ins>+                    copyURLPartsUntil(base, URLPart::PathEnd, c, isUTF8Encoding);
</ins><span class="cx">                     appendToASCIIBuffer('?');
</span><span class="cx">                     ++c;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1555,7 +1554,7 @@
</span><span class="cx">             case '#':
</span><span class="cx">                 syntaxViolation(c);
</span><span class="cx">                 if (base.isValid() &amp;&amp; base.protocolIs(&quot;file&quot;)) {
</span><del>-                    copyURLPartsUntil(base, URLPart::QueryEnd, c);
</del><ins>+                    copyURLPartsUntil(base, URLPart::QueryEnd, c, isUTF8Encoding);
</ins><span class="cx">                     appendToASCIIBuffer('#');
</span><span class="cx">                 } else {
</span><span class="cx">                     appendToASCIIBuffer(&quot;///#&quot;, 4);
</span><span class="lines">@@ -1574,7 +1573,7 @@
</span><span class="cx">             default:
</span><span class="cx">                 syntaxViolation(c);
</span><span class="cx">                 if (base.isValid() &amp;&amp; base.protocolIs(&quot;file&quot;) &amp;&amp; shouldCopyFileURL(c))
</span><del>-                    copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c);
</del><ins>+                    copyURLPartsUntil(base, URLPart::PathAfterLastSlash, c, isUTF8Encoding);
</ins><span class="cx">                 else {
</span><span class="cx">                     appendToASCIIBuffer(&quot;///&quot;, 3);
</span><span class="cx">                     m_url.m_userStart = currentPosition(c) - 1;
</span><span class="lines">@@ -1847,7 +1846,7 @@
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     case State::SpecialRelativeOrAuthority:
</span><span class="cx">         LOG_FINAL_STATE(&quot;SpecialRelativeOrAuthority&quot;);
</span><del>-        copyURLPartsUntil(base, URLPart::QueryEnd, c);
</del><ins>+        copyURLPartsUntil(base, URLPart::QueryEnd, c, isUTF8Encoding);
</ins><span class="cx">         m_url.m_fragmentEnd = m_url.m_queryEnd;
</span><span class="cx">         break;
</span><span class="cx">     case State::PathOrAuthority:
</span><span class="lines">@@ -1870,7 +1869,7 @@
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     case State::RelativeSlash:
</span><span class="cx">         LOG_FINAL_STATE(&quot;RelativeSlash&quot;);
</span><del>-        copyURLPartsUntil(base, URLPart::PortEnd, c);
</del><ins>+        copyURLPartsUntil(base, URLPart::PortEnd, c, isUTF8Encoding);
</ins><span class="cx">         appendToASCIIBuffer('/');
</span><span class="cx">         m_url.m_pathAfterLastSlash = base.m_portEnd + 1;
</span><span class="cx">         m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
</span><span class="lines">@@ -1935,7 +1934,7 @@
</span><span class="cx">     case State::File:
</span><span class="cx">         LOG_FINAL_STATE(&quot;File&quot;);
</span><span class="cx">         if (base.isValid() &amp;&amp; base.protocolIs(&quot;file&quot;)) {
</span><del>-            copyURLPartsUntil(base, URLPart::QueryEnd, c);
</del><ins>+            copyURLPartsUntil(base, URLPart::QueryEnd, c, isUTF8Encoding);
</ins><span class="cx">             appendToASCIIBuffer(':');
</span><span class="cx">         }
</span><span class="cx">         syntaxViolation(c);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.h (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.h        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Source/WebCore/platform/URLParser.h        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx">     void serializeIPv6(IPv6Address);
</span><span class="cx"> 
</span><span class="cx">     enum class URLPart;
</span><del>-    template&lt;typename CharacterType&gt; void copyURLPartsUntil(const URL&amp; base, URLPart, const CodePointIterator&lt;CharacterType&gt;&amp;);
</del><ins>+    template&lt;typename CharacterType&gt; void copyURLPartsUntil(const URL&amp; base, URLPart, const CodePointIterator&lt;CharacterType&gt;&amp;, bool&amp; isUTF8Encoding);
</ins><span class="cx">     static size_t urlLengthUntilPart(const URL&amp;, URLPart);
</span><span class="cx">     void popPath();
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Tools/ChangeLog        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2016-10-06  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        URLParser: Non-ASCII characters in Non-UTF-8 encoded queries of relative URLs with ws, wss, or nonspecial schemes should be UTF-8 encoded
+        https://bugs.webkit.org/show_bug.cgi?id=163089
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::checkURL):
+        (TestWebKitAPI::TEST_F):
+
+2016-10-06  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
</ins><span class="cx">         Skip tabs and newlines between end of query and beginning of fragment in non-UTF-8-encoded URLs
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=163071
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206886 => 206887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-10-06 22:47:47 UTC (rev 206886)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-10-06 23:05:17 UTC (rev 206887)
</span><span class="lines">@@ -118,13 +118,14 @@
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(url));
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</span><span class="cx"> 
</span><del>-    if (testTabs == TestTabs::Yes) {
-        for (size_t i = 0; i &lt; urlString.length(); ++i) {
-            String urlStringWithTab = insertTabAtLocation(urlString, i);
-            checkURL(urlStringWithTab,
-                parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
-                TestTabs::No);
-        }
</del><ins>+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURL(urlStringWithTab,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -367,14 +368,15 @@
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(url));
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</span><span class="cx">     
</span><del>-    if (testTabs == TestTabs::Yes) {
-        for (size_t i = 0; i &lt; urlString.length(); ++i) {
-            String urlStringWithTab = insertTabAtLocation(urlString, i);
-            checkRelativeURL(urlStringWithTab,
-                baseURLString,
-                parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
-                TestTabs::No);
-        }
</del><ins>+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkRelativeURL(urlStringWithTab,
+            baseURLString,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -491,14 +493,15 @@
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(url));
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</span><span class="cx">     
</span><del>-    if (testTabs == TestTabs::Yes) {
-        for (size_t i = 0; i &lt; urlString.length(); ++i) {
-            String urlStringWithTab = insertTabAtLocation(urlString, i);
-            checkURLDifferences(urlStringWithTab,
-                partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
-                partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
-                TestTabs::No);
-        }
</del><ins>+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURLDifferences(urlStringWithTab,
+            partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
+            partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
+            TestTabs::No);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -535,14 +538,15 @@
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(url));
</span><span class="cx">     EXPECT_TRUE(URLParser::internalValuesConsistent(oldURL));
</span><span class="cx"> 
</span><del>-    if (testTabs == TestTabs::Yes) {
-        for (size_t i = 0; i &lt; urlString.length(); ++i) {
-            String urlStringWithTab = insertTabAtLocation(urlString, i);
-            checkRelativeURLDifferences(urlStringWithTab, baseURLString,
-                partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
-                partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
-                TestTabs::No);
-        }
</del><ins>+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkRelativeURLDifferences(urlStringWithTab, baseURLString,
+            partsNew.isInvalid() ? invalidParts(urlStringWithTab) : partsNew,
+            partsOld.isInvalid() ? invalidParts(urlStringWithTab) : partsOld,
+            TestTabs::No);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1173,16 +1177,43 @@
</span><span class="cx">     EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
</span><span class="cx">     EXPECT_TRUE(eq(parts.string, url.string()));
</span><span class="cx"> 
</span><del>-    if (testTabs == TestTabs::Yes) {
-        for (size_t i = 0; i &lt; urlString.length(); ++i) {
-            String urlStringWithTab = insertTabAtLocation(urlString, i);
-            checkURL(urlStringWithTab, encoding,
-                parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
-                TestTabs::No);
-        }
</del><ins>+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURL(urlStringWithTab, encoding,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void checkURL(const String&amp; urlString, const String&amp; baseURLString, const TextEncoding&amp; encoding, const ExpectedParts&amp; parts, TestTabs testTabs = TestTabs::Yes)
+{
+    URLParser baseParser(baseURLString, { }, encoding);
+    URLParser parser(urlString, baseParser.result(), encoding);
+    auto url = parser.result();
+    EXPECT_TRUE(eq(parts.protocol, url.protocol()));
+    EXPECT_TRUE(eq(parts.user, url.user()));
+    EXPECT_TRUE(eq(parts.password, url.pass()));
+    EXPECT_TRUE(eq(parts.host, url.host()));
+    EXPECT_EQ(parts.port, url.port());
+    EXPECT_TRUE(eq(parts.path, url.path()));
+    EXPECT_TRUE(eq(parts.query, url.query()));
+    EXPECT_TRUE(eq(parts.fragment, url.fragmentIdentifier()));
+    EXPECT_TRUE(eq(parts.string, url.string()));
+    
+    if (testTabs == TestTabs::No)
+        return;
+
+    for (size_t i = 0; i &lt; urlString.length(); ++i) {
+        String urlStringWithTab = insertTabAtLocation(urlString, i);
+        checkURL(urlStringWithTab, baseURLString, encoding,
+            parts.isInvalid() ? invalidParts(urlStringWithTab) : parts,
+            TestTabs::No);
+    }
+}
+
</ins><span class="cx"> TEST_F(URLParserTest, QueryEncoding)
</span><span class="cx"> {
</span><span class="cx">     checkURL(utf16String(u&quot;http://host?ß😍#ß😍&quot;), UTF8Encoding(), {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;%C3%9F%F0%9F%98%8D&quot;, utf16String(u&quot;ß😍&quot;), utf16String(u&quot;http://host/?%C3%9F%F0%9F%98%8D#ß😍&quot;)}, testTabsValueForSurrogatePairs);
</span><span class="lines">@@ -1207,7 +1238,14 @@
</span><span class="cx">     checkURL(makeString(&quot;asdf://host/path?&quot;, withUmlauts), iso88591, {&quot;asdf&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/path&quot;, &quot;%C3%9C%D0%B0%D1%91&quot;, &quot;&quot;, &quot;asdf://host/path?%C3%9C%D0%B0%D1%91&quot;});
</span><span class="cx">     checkURL(makeString(&quot;https://host/path?&quot;, withUmlauts), iso88591, {&quot;https&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/path&quot;, &quot;%DC%26%231072%3B%26%231105%3B&quot;, &quot;&quot;, &quot;https://host/path?%DC%26%231072%3B%26%231105%3B&quot;});
</span><span class="cx">     checkURL(makeString(&quot;gopher://host/path?&quot;, withUmlauts), iso88591, {&quot;gopher&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/path&quot;, &quot;%DC%26%231072%3B%26%231105%3B&quot;, &quot;&quot;, &quot;gopher://host/path?%DC%26%231072%3B%26%231105%3B&quot;});
</span><del>-    
</del><ins>+    checkURL(makeString(&quot;/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;ws://example.com/&quot;, iso88591, {&quot;ws&quot;, &quot;&quot;, &quot;&quot;, &quot;example.com&quot;, 0, &quot;/path&quot;, &quot;%C3%9C%D0%B0%D1%91&quot;, &quot;fragment&quot;, &quot;ws://example.com/path?%C3%9C%D0%B0%D1%91#fragment&quot;});
+    checkURL(makeString(&quot;/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;wss://example.com/&quot;, iso88591, {&quot;wss&quot;, &quot;&quot;, &quot;&quot;, &quot;example.com&quot;, 0, &quot;/path&quot;, &quot;%C3%9C%D0%B0%D1%91&quot;, &quot;fragment&quot;, &quot;wss://example.com/path?%C3%9C%D0%B0%D1%91#fragment&quot;});
+    checkURL(makeString(&quot;/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;asdf://example.com/&quot;, iso88591, {&quot;asdf&quot;, &quot;&quot;, &quot;&quot;, &quot;example.com&quot;, 0, &quot;/path&quot;, &quot;%C3%9C%D0%B0%D1%91&quot;, &quot;fragment&quot;, &quot;asdf://example.com/path?%C3%9C%D0%B0%D1%91#fragment&quot;});
+    checkURL(makeString(&quot;/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;https://example.com/&quot;, iso88591, {&quot;https&quot;, &quot;&quot;, &quot;&quot;, &quot;example.com&quot;, 0, &quot;/path&quot;, &quot;%DC%26%231072%3B%26%231105%3B&quot;, &quot;fragment&quot;, &quot;https://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment&quot;});
+    checkURL(makeString(&quot;/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;gopher://example.com/&quot;, iso88591, {&quot;gopher&quot;, &quot;&quot;, &quot;&quot;, &quot;example.com&quot;, 0, &quot;/path&quot;, &quot;%DC%26%231072%3B%26%231105%3B&quot;, &quot;fragment&quot;, &quot;gopher://example.com/path?%DC%26%231072%3B%26%231105%3B#fragment&quot;});
+    checkURL(makeString(&quot;gopher://host/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;asdf://example.com/?doesntmatter&quot;, iso88591, {&quot;gopher&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/path&quot;, &quot;%DC%26%231072%3B%26%231105%3B&quot;, &quot;fragment&quot;, &quot;gopher://host/path?%DC%26%231072%3B%26%231105%3B#fragment&quot;});
+    checkURL(makeString(&quot;asdf://host/path?&quot;, withUmlauts, &quot;#fragment&quot;), &quot;http://example.com/?doesntmatter&quot;, iso88591, {&quot;asdf&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/path&quot;, &quot;%C3%9C%D0%B0%D1%91&quot;, &quot;fragment&quot;, &quot;asdf://host/path?%C3%9C%D0%B0%D1%91#fragment&quot;});
+
</ins><span class="cx">     // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>