<!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>[206648] 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/206648">206648</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-09-30 11:46:28 -0700 (Fri, 30 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>URLParser: handle syntax violations in non-UTF-8 encoded queries
https://bugs.webkit.org/show_bug.cgi?id=162770

Reviewed by Tim Horton.

Source/WebCore:

There is a fast path for queries of URLs that use UTF-8 encoding, which are quite common.
For non-UTF-8 encoded queries, which are less common, we put the code points in a Vector&lt;UChar&gt;
and encode them all at once.  If there is a syntax violation in the query, we need to copy the
syntax-violation-free string up to the beginning of the query, then encode the query.

Covered by new API tests.

* platform/URLParser.cpp:
(WebCore::URLParser::percentEncodeByte):
(WebCore::URLParser::encodeQuery):
(WebCore::URLParser::parse):
* platform/URLParser.h:

Tools:

* TestWebKitAPI/Tests/WebCore/URLParser.cpp:
(TestWebKitAPI::checkURL):
(TestWebKitAPI::TEST_F):
Tests with emoji change behavior when we insert a tab between the surrogates, so don't do the
insert-tab-at-each-location verification that syntax violations are handled correctly.</pre>

<h3>Modified Paths</h3>
<ul>
<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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206647 => 206648)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-30 18:44:16 UTC (rev 206647)
+++ trunk/Source/WebCore/ChangeLog        2016-09-30 18:46:28 UTC (rev 206648)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-09-30  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        URLParser: handle syntax violations in non-UTF-8 encoded queries
+        https://bugs.webkit.org/show_bug.cgi?id=162770
+
+        Reviewed by Tim Horton.
+
+        There is a fast path for queries of URLs that use UTF-8 encoding, which are quite common.
+        For non-UTF-8 encoded queries, which are less common, we put the code points in a Vector&lt;UChar&gt;
+        and encode them all at once.  If there is a syntax violation in the query, we need to copy the
+        syntax-violation-free string up to the beginning of the query, then encode the query.
+
+        Covered by new API tests.
+
+        * platform/URLParser.cpp:
+        (WebCore::URLParser::percentEncodeByte):
+        (WebCore::URLParser::encodeQuery):
+        (WebCore::URLParser::parse):
+        * platform/URLParser.h:
+
</ins><span class="cx"> 2016-09-27  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove a couple of unused members from PlatformKeyboardEvent
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.cpp (206647 => 206648)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.cpp        2016-09-30 18:44:16 UTC (rev 206647)
+++ trunk/Source/WebCore/platform/URLParser.cpp        2016-09-30 18:46:28 UTC (rev 206648)
</span><span class="lines">@@ -494,6 +494,7 @@
</span><span class="cx"> 
</span><span class="cx"> void URLParser::percentEncodeByte(uint8_t byte)
</span><span class="cx"> {
</span><ins>+    ASSERT(m_didSeeSyntaxViolation);
</ins><span class="cx">     appendToASCIIBuffer('%');
</span><span class="cx">     appendToASCIIBuffer(upperNibbleToASCIIHexDigit(byte));
</span><span class="cx">     appendToASCIIBuffer(lowerNibbleToASCIIHexDigit(byte));
</span><span class="lines">@@ -562,15 +563,39 @@
</span><span class="cx">             appendToASCIIBuffer(byte);
</span><span class="cx">     }
</span><span class="cx"> }
</span><del>-    
-void URLParser::encodeQuery(const Vector&lt;UChar&gt;&amp; source, const TextEncoding&amp; encoding)
</del><ins>+
+template&lt;typename CharacterType&gt;
+void URLParser::encodeQuery(const Vector&lt;UChar&gt;&amp; source, const TextEncoding&amp; encoding, CodePointIterator&lt;CharacterType&gt; iterator)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: It is unclear in the spec what to do when encoding fails. The behavior should be specified and tested.
</span><span class="cx">     CString encoded = encoding.encode(StringView(source.data(), source.size()), URLEncodedEntitiesForUnencodables);
</span><span class="cx">     const char* data = encoded.data();
</span><span class="cx">     size_t length = encoded.length();
</span><del>-    for (size_t i = 0; i &lt; length; ++i) {
</del><ins>+    
+    if (!length == !iterator.atEnd()) {
+        syntaxViolation(iterator);
+        return;
+    }
+    
+    size_t i = 0;
+    for (; i &lt; length; ++i) {
+        ASSERT(!iterator.atEnd());
</ins><span class="cx">         uint8_t byte = data[i];
</span><ins>+        if (UNLIKELY(byte != *iterator)) {
+            syntaxViolation(iterator);
+            break;
+        }
+        if (UNLIKELY(shouldPercentEncodeQueryByte(byte))) {
+            syntaxViolation(iterator);
+            break;
+        }
+        appendToASCIIBuffer(byte);
+        ++iterator;
+    }
+    ASSERT((i == length) == iterator.atEnd());
+    for (; i &lt; length; ++i) {
+        ASSERT(m_didSeeSyntaxViolation);
+        uint8_t byte = data[i];
</ins><span class="cx">         if (shouldPercentEncodeQueryByte(byte))
</span><span class="cx">             percentEncodeByte(byte);
</span><span class="cx">         else
</span><span class="lines">@@ -1103,6 +1128,7 @@
</span><span class="cx">     }
</span><span class="cx">     CodePointIterator&lt;CharacterType&gt; c(input, input + endIndex);
</span><span class="cx">     CodePointIterator&lt;CharacterType&gt; authorityOrHostBegin;
</span><ins>+    CodePointIterator&lt;CharacterType&gt; queryBegin;
</ins><span class="cx">     while (UNLIKELY(!c.atEnd() &amp;&amp; isC0ControlOrSpace(*c))) {
</span><span class="cx">         syntaxViolation(c);
</span><span class="cx">         ++c;
</span><span class="lines">@@ -1127,7 +1153,8 @@
</span><span class="cx">         PathStart,
</span><span class="cx">         Path,
</span><span class="cx">         CannotBeABaseURLPath,
</span><del>-        Query,
</del><ins>+        UTF8Query,
+        NonUTF8Query,
</ins><span class="cx">         Fragment,
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -1288,8 +1315,13 @@
</span><span class="cx">             case '?':
</span><span class="cx">                 copyURLPartsUntil(base, URLPart::PathEnd, c);
</span><span class="cx">                 appendToASCIIBuffer('?');
</span><del>-                state = State::Query;
</del><span class="cx">                 ++c;
</span><ins>+                if (isUTF8Encoding)
+                    state = State::UTF8Query;
+                else {
+                    queryBegin = c;
+                    state = State::NonUTF8Query;
+                }
</ins><span class="cx">                 break;
</span><span class="cx">             case '#':
</span><span class="cx">                 copyURLPartsUntil(base, URLPart::QueryEnd, c);
</span><span class="lines">@@ -1431,6 +1463,13 @@
</span><span class="cx">                 if (base.isValid() &amp;&amp; base.protocolIs(&quot;file&quot;))
</span><span class="cx">                     copyURLPartsUntil(base, URLPart::PathEnd, c);
</span><span class="cx">                 appendToASCIIBuffer(&quot;///?&quot;, 4);
</span><ins>+                ++c;
+                if (isUTF8Encoding)
+                    state = State::UTF8Query;
+                else {
+                    queryBegin = c;
+                    state = State::NonUTF8Query;
+                }
</ins><span class="cx">                 m_url.m_userStart = currentPosition(c) - 2;
</span><span class="cx">                 m_url.m_userEnd = m_url.m_userStart;
</span><span class="cx">                 m_url.m_passwordEnd = m_url.m_userStart;
</span><span class="lines">@@ -1438,8 +1477,6 @@
</span><span class="cx">                 m_url.m_portEnd = m_url.m_userStart;
</span><span class="cx">                 m_url.m_pathAfterLastSlash = m_url.m_userStart + 1;
</span><span class="cx">                 m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
</span><del>-                state = State::Query;
-                ++c;
</del><span class="cx">                 break;
</span><span class="cx">             case '#':
</span><span class="cx">                 syntaxViolation(c);
</span><span class="lines">@@ -1533,9 +1570,14 @@
</span><span class="cx">                             syntaxViolation(c);
</span><span class="cx">                             appendToASCIIBuffer(&quot;/?&quot;, 2);
</span><span class="cx">                             ++c;
</span><ins>+                            if (isUTF8Encoding)
+                                state = State::UTF8Query;
+                            else {
+                                queryBegin = c;
+                                state = State::NonUTF8Query;
+                            }
</ins><span class="cx">                             m_url.m_pathAfterLastSlash = currentPosition(c) - 1;
</span><span class="cx">                             m_url.m_pathEnd = m_url.m_pathAfterLastSlash;
</span><del>-                            state = State::Query;
</del><span class="cx">                             break;
</span><span class="cx">                         }
</span><span class="cx">                         if (UNLIKELY(*c == '#')) {
</span><span class="lines">@@ -1601,7 +1643,14 @@
</span><span class="cx">             }
</span><span class="cx">             if (*c == '?') {
</span><span class="cx">                 m_url.m_pathEnd = currentPosition(c);
</span><del>-                state = State::Query;
</del><ins>+                appendToASCIIBuffer('?');
+                ++c;
+                if (isUTF8Encoding)
+                    state = State::UTF8Query;
+                else {
+                    queryBegin = c;
+                    state = State::NonUTF8Query;
+                }
</ins><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="cx">             if (*c == '#') {
</span><span class="lines">@@ -1628,7 +1677,14 @@
</span><span class="cx">             LOG_STATE(&quot;CannotBeABaseURLPath&quot;);
</span><span class="cx">             if (*c == '?') {
</span><span class="cx">                 m_url.m_pathEnd = currentPosition(c);
</span><del>-                state = State::Query;
</del><ins>+                appendToASCIIBuffer('?');
+                ++c;
+                if (isUTF8Encoding)
+                    state = State::UTF8Query;
+                else {
+                    queryBegin = c;
+                    state = State::NonUTF8Query;
+                }
</ins><span class="cx">             } else if (*c == '#') {
</span><span class="cx">                 m_url.m_pathEnd = currentPosition(c);
</span><span class="cx">                 m_url.m_queryEnd = m_url.m_pathEnd;
</span><span class="lines">@@ -1642,11 +1698,10 @@
</span><span class="cx">                 ++c;
</span><span class="cx">             }
</span><span class="cx">             break;
</span><del>-        case State::Query:
-            LOG_STATE(&quot;Query&quot;);
</del><ins>+        case State::UTF8Query:
+            LOG_STATE(&quot;UTF8Query&quot;);
+            ASSERT(queryBegin == CodePointIterator&lt;CharacterType&gt;());
</ins><span class="cx">             if (*c == '#') {
</span><del>-                if (!isUTF8Encoding)
-                    encodeQuery(queryBuffer, encoding);
</del><span class="cx">                 m_url.m_queryEnd = currentPosition(c);
</span><span class="cx">                 state = State::Fragment;
</span><span class="cx">                 break;
</span><span class="lines">@@ -1657,6 +1712,20 @@
</span><span class="cx">                 appendCodePoint(queryBuffer, *c);
</span><span class="cx">             ++c;
</span><span class="cx">             break;
</span><ins>+        case State::NonUTF8Query:
+            do {
+                LOG_STATE(&quot;NonUTF8Query&quot;);
+                ASSERT(queryBegin != CodePointIterator&lt;CharacterType&gt;());
+                if (*c == '#') {
+                    encodeQuery(queryBuffer, encoding, CodePointIterator&lt;CharacterType&gt;(queryBegin, c));
+                    m_url.m_queryEnd = currentPosition(c);
+                    state = State::Fragment;
+                    break;
+                }
+                appendCodePoint(queryBuffer, *c);
+                advance(c, queryBegin);
+            } while (!c.atEnd());
+            break;
</ins><span class="cx">         case State::Fragment:
</span><span class="cx">             do {
</span><span class="cx">                 LOG(URLParser, &quot;State Fragment&quot;);
</span><span class="lines">@@ -1859,13 +1928,19 @@
</span><span class="cx">         m_url.m_queryEnd = m_url.m_pathEnd;
</span><span class="cx">         m_url.m_fragmentEnd = m_url.m_pathEnd;
</span><span class="cx">         break;
</span><del>-    case State::Query:
-        LOG_FINAL_STATE(&quot;Query&quot;);
-        if (!isUTF8Encoding)
-            encodeQuery(queryBuffer, encoding);
</del><ins>+    case State::UTF8Query:
+        LOG_FINAL_STATE(&quot;UTF8Query&quot;);
+        ASSERT(queryBegin == CodePointIterator&lt;CharacterType&gt;());
</ins><span class="cx">         m_url.m_queryEnd = currentPosition(c);
</span><span class="cx">         m_url.m_fragmentEnd = m_url.m_queryEnd;
</span><span class="cx">         break;
</span><ins>+    case State::NonUTF8Query:
+        LOG_FINAL_STATE(&quot;NonUTF8Query&quot;);
+        ASSERT(queryBegin != CodePointIterator&lt;CharacterType&gt;());
+        encodeQuery(queryBuffer, encoding, CodePointIterator&lt;CharacterType&gt;(queryBegin, c));
+        m_url.m_queryEnd = currentPosition(c);
+        m_url.m_fragmentEnd = m_url.m_queryEnd;
+        break;
</ins><span class="cx">     case State::Fragment:
</span><span class="cx">         {
</span><span class="cx">             LOG_FINAL_STATE(&quot;Fragment&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URLParser.h (206647 => 206648)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URLParser.h        2016-09-30 18:44:16 UTC (rev 206647)
+++ trunk/Source/WebCore/platform/URLParser.h        2016-09-30 18:46:28 UTC (rev 206648)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx">     void appendToASCIIBuffer(UChar32);
</span><span class="cx">     void appendToASCIIBuffer(const char*, size_t);
</span><span class="cx">     void appendToASCIIBuffer(const LChar* characters, size_t size) { appendToASCIIBuffer(reinterpret_cast&lt;const char*&gt;(characters), size); }
</span><del>-    void encodeQuery(const Vector&lt;UChar&gt;&amp; source, const TextEncoding&amp;);
</del><ins>+    template&lt;typename CharacterType&gt; void encodeQuery(const Vector&lt;UChar&gt;&amp; source, const TextEncoding&amp;, CodePointIterator&lt;CharacterType&gt;);
</ins><span class="cx">     void copyASCIIStringUntil(const String&amp;, size_t lengthIf8Bit, size_t lengthIf16Bit);
</span><span class="cx">     StringView parsedDataView(size_t start, size_t length);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (206647 => 206648)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-09-30 18:44:16 UTC (rev 206647)
+++ trunk/Tools/ChangeLog        2016-09-30 18:46:28 UTC (rev 206648)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-09-30  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        URLParser: handle syntax violations in non-UTF-8 encoded queries
+        https://bugs.webkit.org/show_bug.cgi?id=162770
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebCore/URLParser.cpp:
+        (TestWebKitAPI::checkURL):
+        (TestWebKitAPI::TEST_F):
+        Tests with emoji change behavior when we insert a tab between the surrogates, so don't do the
+        insert-tab-at-each-location verification that syntax violations are handled correctly.
+
</ins><span class="cx"> 2016-09-30  Megan Gardner  &lt;megan_gardner@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make it possible to test web-related user-interface features
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreURLParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp (206647 => 206648)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-09-30 18:44:16 UTC (rev 206647)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URLParser.cpp        2016-09-30 18:46:28 UTC (rev 206648)
</span><span class="lines">@@ -961,7 +961,7 @@
</span><span class="cx">         {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;w&quot;, 0, &quot;/&quot;, &quot;%ED%A0%80&quot;, &quot;&quot;, &quot;http://w/?%ED%A0%80&quot;});
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void checkURL(const String&amp; urlString, const TextEncoding&amp; encoding, const ExpectedParts&amp; parts)
</del><ins>+static void checkURL(const String&amp; urlString, const TextEncoding&amp; encoding, const ExpectedParts&amp; parts, bool checkTabs = true)
</ins><span class="cx"> {
</span><span class="cx">     URLParser parser(urlString, { }, encoding);
</span><span class="cx">     auto url = parser.result();
</span><span class="lines">@@ -975,13 +975,32 @@
</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>-    // FIXME: check tabs here like we do for checkURL and checkRelativeURL.
</del><ins>+    if (checkTabs) {
+        for (size_t i = 0; i &lt; urlString.length(); ++i) {
+            String urlStringWithTab = makeString(urlString.substring(0, i), &quot;\t&quot;, urlString.substring(i));
+            ExpectedParts invalidPartsWithTab = {&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 0, &quot;&quot; , &quot;&quot;, &quot;&quot;, urlStringWithTab};
+            checkURL(urlStringWithTab, encoding, parts.isInvalid() ? invalidPartsWithTab : parts, false);
+        }
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST_F(URLParserTest, QueryEncoding)
</span><span class="cx"> {
</span><del>-    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;)});
-    // FIXME: Add tests with other encodings.
</del><ins>+    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;)}, false);
+    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;)}, false);
+
+    TextEncoding latin1(String(&quot;latin1&quot;));
+    checkURL(&quot;http://host/?query with%20spaces&quot;, latin1, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;query%20with%20spaces&quot;, &quot;&quot;, &quot;http://host/?query%20with%20spaces&quot;});
+    checkURL(&quot;http://host/?query&quot;, latin1, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;query&quot;, &quot;&quot;, &quot;http://host/?query&quot;});
+    checkURL(&quot;http://host/?\tquery&quot;, latin1, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;query&quot;, &quot;&quot;, &quot;http://host/?query&quot;});
+    checkURL(&quot;http://host/?q\tuery&quot;, latin1, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;query&quot;, &quot;&quot;, &quot;http://host/?query&quot;});
+    checkURL(&quot;http://host/?query with SpAcEs#fragment&quot;, latin1, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;query%20with%20SpAcEs&quot;, &quot;fragment&quot;, &quot;http://host/?query%20with%20SpAcEs#fragment&quot;});
+
+    TextEncoding unrecognized(String(&quot;unrecognized invalid encoding name&quot;));
+    checkURL(&quot;http://host/?query&quot;, unrecognized, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://host/?&quot;});
+    checkURL(&quot;http://host/?&quot;, unrecognized, {&quot;http&quot;, &quot;&quot;, &quot;&quot;, &quot;host&quot;, 0, &quot;/&quot;, &quot;&quot;, &quot;&quot;, &quot;http://host/?&quot;});
+
+    // FIXME: Add more tests with other encodings and things like non-ascii characters, emoji and unmatched surrogate pairs.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre>
</div>
</div>

</body>
</html>