<!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>[198289] 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/198289">198289</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-03-16 11:31:32 -0700 (Wed, 16 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>URL Parsing should signal failure for illegal IDN
https://bugs.webkit.org/show_bug.cgi?id=154945
&lt;rdar://problem/8014795&gt;

Reviewed by Brent Fulgham.

Source/WebCore:

WebCore::URL will now invalidate URLs with illegal IDN. And functions inside WebCoreNSURLExtras.h
that deal with IDN mapping will now return nil to signal error.

Test: fast/url/invalid-idn.html

* platform/URL.cpp:
(WebCore::isSchemeFirstChar):
(WebCore::URL::init):
(WebCore::appendEncodedHostname):
(WebCore::encodeHostnames):
(WebCore::encodeRelativeString):
* platform/mac/WebCoreNSURLExtras.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::mapHostNameWithRange):
(WebCore::hostNameNeedsDecodingWithRange):
(WebCore::hostNameNeedsEncodingWithRange):
(WebCore::decodeHostNameWithRange):
(WebCore::encodeHostNameWithRange):
(WebCore::decodeHostName):
(WebCore::encodeHostName):
(WebCore::collectRangesThatNeedMapping):
(WebCore::mapHostNames):
(WebCore::URLWithData):
(WebCore::dataWithUserTypedString):
(WebCore::URLWithUserTypedString):
(WebCore::URLWithUserTypedStringDeprecated):
(WebCore::userVisibleString):

Source/WebKit/ios:

* Misc/WebNSStringExtrasIOS.m:
(-[NSString _web_possibleURLsForForUserTypedString:]):
* WebView/WebPDFViewPlaceholder.mm:
(-[WebPDFViewPlaceholder _updateTitleForURL:]):

Source/WebKit/mac:

In this patch, we add new SPIs _webkit_URLWithUserTypedString, _webkit_decodeHostName and
_webkit_encodeHostName which will return nil while dealing with illegal IDN.

Old SPIs _web_URLWithUserTypedString, _web_decodeHostName and _web_encodeHostName are marked
deprecated as they ignore URL parsing failure.

* History/WebHistoryItem.mm:
(-[WebHistoryItem initFromDictionaryRepresentation:]):
* Misc/WebKitErrors.m:
(+[NSError _webKitErrorWithCode:failingURL:]):
* Misc/WebNSFileManagerExtras.mm:
(-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]):
* Misc/WebNSPasteboardExtras.mm:
(-[NSPasteboard _web_bestURL]):
* Misc/WebNSURLExtras.h:
* Misc/WebNSURLExtras.mm:
(+[NSURL _web_URLWithUserTypedString:]):
(+[NSURL _webkit_URLWithUserTypedString:relativeToURL:]):
(+[NSURL _webkit_URLWithUserTypedString:]):
(-[NSString _web_decodeHostName]):
(-[NSString _web_encodeHostName]):
(-[NSString _webkit_decodeHostName]):
(-[NSString _webkit_encodeHostName]):
* Panels/WebAuthenticationPanel.m:
(-[WebAuthenticationPanel setUpForChallenge:]):
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::canonicalizeURLString):

Tools:

* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController fetch:]):
* TestWebKitAPI/Tests/Cocoa/URLExtras.mm:
(TestWebKitAPI::TEST):

LayoutTests:

* fast/url/host-expected.txt:
* fast/url/idna2003-expected.txt:
* fast/url/invalid-idn-expected.txt: Added.
* fast/url/invalid-idn.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasturlhostexpectedtxt">trunk/LayoutTests/fast/url/host-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasturlidna2003expectedtxt">trunk/LayoutTests/fast/url/idna2003-expected.txt</a></li>
<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="#trunkSourceWebCoreplatformmacWebCoreNSURLExtrash">trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebCoreNSURLExtrasmm">trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm</a></li>
<li><a href="#trunkSourceWebKitiosChangeLog">trunk/Source/WebKit/ios/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitiosMiscWebNSStringExtrasIOSm">trunk/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m</a></li>
<li><a href="#trunkSourceWebKitiosWebViewWebPDFViewPlaceholdermm">trunk/Source/WebKit/ios/WebView/WebPDFViewPlaceholder.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacHistoryWebHistoryItemmm">trunk/Source/WebKit/mac/History/WebHistoryItem.mm</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebKitErrorsm">trunk/Source/WebKit/mac/Misc/WebKitErrors.m</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSFileManagerExtrasmm">trunk/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSPasteboardExtrasmm">trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSURLExtrash">trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSURLExtrasmm">trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm</a></li>
<li><a href="#trunkSourceWebKitmacPanelsWebAuthenticationPanelm">trunk/Source/WebKit/mac/Panels/WebAuthenticationPanel.m</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebEditorClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsermacWK2BrowserWindowControllerm">trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsCocoaURLExtrasmm">trunk/Tools/TestWebKitAPI/Tests/Cocoa/URLExtras.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasturlinvalididnexpectedtxt">trunk/LayoutTests/fast/url/invalid-idn-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasturlinvalididnhtml">trunk/LayoutTests/fast/url/invalid-idn.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/LayoutTests/ChangeLog        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-03-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        URL Parsing should signal failure for illegal IDN
+        https://bugs.webkit.org/show_bug.cgi?id=154945
+        &lt;rdar://problem/8014795&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * fast/url/host-expected.txt:
+        * fast/url/idna2003-expected.txt:
+        * fast/url/invalid-idn-expected.txt: Added.
+        * fast/url/invalid-idn.html: Added.
+
</ins><span class="cx"> 2016-03-16  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for setting Function.name from computed properties.
</span></span></pre></div>
<a id="trunkLayoutTestsfasturlhostexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/url/host-expected.txt (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/url/host-expected.txt        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/LayoutTests/fast/url/host-expected.txt        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -8,7 +8,7 @@
</span><span class="cx"> FAIL canonicalize('http://GOO  goo.com/') should be http://goo%20%20goo.com/. Was http://GOO  goo.com/.
</span><span class="cx"> PASS canonicalize('http://GOO​⁠goo.com/') is 'http://googoo.com/'
</span><span class="cx"> PASS canonicalize('http://www.foo。bar.com/') is 'http://www.foo.bar.com/'
</span><del>-FAIL canonicalize('http://﷐zyx.com/') should be http://%EF%BF%BDzyx.com/. Was http:/.
</del><ins>+FAIL canonicalize('http://﷐zyx.com/') should be http://%EF%BF%BDzyx.com/. Was about:blank.
</ins><span class="cx"> FAIL canonicalize('http://%ef%b7%90zyx.com/') should be http://%EF%BF%BDzyx.com/. Was http://%ef%b7%90zyx.com/.
</span><span class="cx"> PASS canonicalize('http://Go.com/') is 'http://go.com/'
</span><span class="cx"> FAIL canonicalize('http://%41.com/') should be http://a.com/. Was http://%41.com/.
</span></span></pre></div>
<a id="trunkLayoutTestsfasturlidna2003expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/url/idna2003-expected.txt (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/url/idna2003-expected.txt        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/LayoutTests/fast/url/idna2003-expected.txt        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -17,21 +17,21 @@
</span><span class="cx"> PASS canonicalize('http://www.looĸout.net/') is 'http://www.xn--looout-5bb.net/'
</span><span class="cx"> FAIL canonicalize('http://www.lookout.net⩴80/') should be http://www.lookout.net::%3D80/. Was http://www.lookout.net⩴80/.
</span><span class="cx"> FAIL canonicalize('http://www .lookout.net/') should be http://www%20.lookout.net/. Was http://www .lookout.net/.
</span><del>-FAIL canonicalize('http:// lookout.net/') should be http://%E1%9A%80lookout.net/. Was http:/.
</del><ins>+FAIL canonicalize('http:// lookout.net/') should be http://%E1%9A%80lookout.net/. Was about:blank.
</ins><span class="cx"> FAIL canonicalize('http://lookout.net/') should be http://%1Flookout.net/. Was http://lookout.net/.
</span><del>-FAIL canonicalize('http://look۝out.net/') should be http://look%DB%9Dout.net/. Was http:/.
-FAIL canonicalize('http://look᠎out.net/') should be http://look%E1%A0%8Eout.net/. Was http:/.
</del><ins>+FAIL canonicalize('http://look۝out.net/') should be http://look%DB%9Dout.net/. Was about:blank.
+FAIL canonicalize('http://look᠎out.net/') should be http://look%E1%A0%8Eout.net/. Was about:blank.
</ins><span class="cx"> FAIL canonicalize('http://look⁠out.net/') should be http://look%E2%81%A0out.net/. Was http://lookout.net/.
</span><span class="cx"> FAIL canonicalize('http://lookout.net/') should be http://look%EF%BB%BFout.net/. Was http://lookout.net/.
</span><del>-FAIL canonicalize('http://look🿾out.net/') should be http://look%F0%9F%BF%BEout.net/. Was http:/.
-FAIL canonicalize('http://lookout.net/') should be http://look%EF%BF%BAout.net/. Was http:/.
-FAIL canonicalize('http://look⿰out.net/') should be http://look%E2%BF%B0out.net/. Was http:/.
</del><ins>+FAIL canonicalize('http://look🿾out.net/') should be http://look%F0%9F%BF%BEout.net/. Was about:blank.
+FAIL canonicalize('http://lookout.net/') should be http://look%EF%BF%BAout.net/. Was about:blank.
+FAIL canonicalize('http://look⿰out.net/') should be http://look%E2%BF%B0out.net/. Was about:blank.
</ins><span class="cx"> FAIL canonicalize('http://looḱout.net/') should be http://look%CD%81out.net/. Was http://xn--looout-kp7b.net/.
</span><del>-FAIL canonicalize('http://look‮out.net/') should be http://look%E2%80%AEout.net/. Was http:/.
-FAIL canonicalize('http://lookout.net/') should be http://look%E2%81%ABout.net/. Was http:/.
-FAIL canonicalize('http://look󠀁out.net/') should be http://look%F3%A0%80%81out.net/. Was http:/.
-FAIL canonicalize('http://look󠀠out.net/') should be http://look%F3%A0%80%A0out.net/. Was http:/.
-FAIL canonicalize('http://look־out.net/') should be http://look%D6%BEout.net/. Was http:/.
</del><ins>+FAIL canonicalize('http://look‮out.net/') should be http://look%E2%80%AEout.net/. Was about:blank.
+FAIL canonicalize('http://lookout.net/') should be http://look%E2%81%ABout.net/. Was about:blank.
+FAIL canonicalize('http://look󠀁out.net/') should be http://look%F3%A0%80%81out.net/. Was about:blank.
+FAIL canonicalize('http://look󠀠out.net/') should be http://look%F3%A0%80%A0out.net/. Was about:blank.
+FAIL canonicalize('http://look־out.net/') should be http://look%D6%BEout.net/. Was about:blank.
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfasturlinvalididnexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/url/invalid-idn-expected.txt (0 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/url/invalid-idn-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/url/invalid-idn-expected.txt        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+Test passes if all the invalid urls are converted to about:blank.
+about:blank
+about:blank
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasturlinvalididnhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/url/invalid-idn.html (0 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/url/invalid-idn.html                                (rev 0)
+++ trunk/LayoutTests/fast/url/invalid-idn.html        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-16&quot;&gt;
+&lt;!-- Set the base so that the current URL does not affect the tests. --&gt;
+&lt;base href=&quot;&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+// Start the bidding at 42 for no particular reason.
+var lastID = 42;
+
+function canonicalize(url)
+{
+    var id = ++lastID;
+    document.write(&quot;&lt;a id='&quot; + id + &quot;' href='&quot; + url + &quot;'&gt;&lt;/a&gt;&quot;);
+    return document.getElementById(id).href;
+}
+
+// Those are all invalid URLs. They should not be accepted by the parser.
+var testSet = [
+    'http://.com',
+    'http://www.اast.fm'
+];
+
+document.write(&quot;Test passes if all the invalid urls are converted to about:blank.&lt;br&gt;&quot;);
+for (var i = 0; i &lt; testSet.length; ++i) {
+    src = canonicalize(testSet[i]);
+    document.write(src + &quot;&lt;br&gt;&quot;);
+}
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebCore/ChangeLog        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2016-03-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        URL Parsing should signal failure for illegal IDN
+        https://bugs.webkit.org/show_bug.cgi?id=154945
+        &lt;rdar://problem/8014795&gt;
+
+        Reviewed by Brent Fulgham.
+
+        WebCore::URL will now invalidate URLs with illegal IDN. And functions inside WebCoreNSURLExtras.h
+        that deal with IDN mapping will now return nil to signal error.
+
+        Test: fast/url/invalid-idn.html
+
+        * platform/URL.cpp:
+        (WebCore::isSchemeFirstChar):
+        (WebCore::URL::init):
+        (WebCore::appendEncodedHostname):
+        (WebCore::encodeHostnames):
+        (WebCore::encodeRelativeString):
+        * platform/mac/WebCoreNSURLExtras.h:
+        * platform/mac/WebCoreNSURLExtras.mm:
+        (WebCore::mapHostNameWithRange):
+        (WebCore::hostNameNeedsDecodingWithRange):
+        (WebCore::hostNameNeedsEncodingWithRange):
+        (WebCore::decodeHostNameWithRange):
+        (WebCore::encodeHostNameWithRange):
+        (WebCore::decodeHostName):
+        (WebCore::encodeHostName):
+        (WebCore::collectRangesThatNeedMapping):
+        (WebCore::mapHostNames):
+        (WebCore::URLWithData):
+        (WebCore::dataWithUserTypedString):
+        (WebCore::URLWithUserTypedString):
+        (WebCore::URLWithUserTypedStringDeprecated):
+        (WebCore::userVisibleString):
+
</ins><span class="cx"> 2016-03-16  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Don't invalidate style unnecessarily when setting inline style cssText
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URL.cpp (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URL.cpp        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebCore/platform/URL.cpp        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static int copyPathRemovingDots(char* dst, const char* src, int srcStart, int srcEnd);
</span><del>-static void encodeRelativeString(const String&amp; rel, const TextEncoding&amp;, CharBuffer&amp; ouput);
</del><ins>+static bool encodeRelativeString(const String&amp; rel, const TextEncoding&amp;, CharBuffer&amp; ouput);
</ins><span class="cx"> static String substituteBackslashes(const String&amp;);
</span><span class="cx"> 
</span><span class="cx"> static inline bool isSchemeFirstChar(char c) { return characterClassTable[static_cast&lt;unsigned char&gt;(c)] &amp; SchemeFirstChar; }
</span><span class="lines">@@ -490,7 +490,12 @@
</span><span class="cx">         strBuffer[len] = 0;
</span><span class="cx">         str = strBuffer.data();
</span><span class="cx">     } else {
</span><del>-        encodeRelativeString(rel, encoding, strBuffer);
</del><ins>+        if (!encodeRelativeString(rel, encoding, strBuffer)) {
+            m_string = blankURL();
+            invalidate();
+            return;
+        }
+
</ins><span class="cx">         str = strBuffer.data();
</span><span class="cx">         len = strlen(str);
</span><span class="cx">     }
</span><span class="lines">@@ -1681,7 +1686,8 @@
</span><span class="cx"> 
</span><span class="cx"> // Appends the punycoded hostname identified by the given string and length to
</span><span class="cx"> // the output buffer. The result will not be null terminated.
</span><del>-static void appendEncodedHostname(UCharBuffer&amp; buffer, StringView string)
</del><ins>+// Return value of false means error in encoding.
+static bool appendEncodedHostname(UCharBuffer&amp; buffer, StringView string)
</ins><span class="cx"> {
</span><span class="cx">     // Needs to be big enough to hold an IDN-encoded name.
</span><span class="cx">     // For host names bigger than this, we won't do IDN encoding, which is almost certainly OK.
</span><span class="lines">@@ -1689,7 +1695,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (string.length() &gt; hostnameBufferLength || containsOnlyASCII(string)) {
</span><span class="cx">         append(buffer, string);
</span><del>-        return;
</del><ins>+        return true;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     UChar hostnameBuffer[hostnameBufferLength];
</span><span class="lines">@@ -1705,8 +1711,11 @@
</span><span class="cx"> #pragma GCC diagnostic pop
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (error == U_ZERO_ERROR)
</del><ins>+    if (error == U_ZERO_ERROR) {
</ins><span class="cx">         buffer.append(hostnameBuffer, numCharactersConverted);
</span><ins>+        return true;
+    }
+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void findHostnamesInMailToURL(StringView string, Vector&lt;std::pair&lt;int, int&gt;&gt;&amp; nameRanges)
</span><span class="lines">@@ -1819,7 +1828,8 @@
</span><span class="cx"> 
</span><span class="cx"> // Converts all hostnames found in the given input to punycode, preserving the
</span><span class="cx"> // rest of the URL unchanged. The output will NOT be null-terminated.
</span><del>-static void encodeHostnames(StringView string, UCharBuffer&amp; buffer)
</del><ins>+// Return value of false means error in encoding.
+static bool encodeHostnames(StringView string, UCharBuffer&amp; buffer)
</ins><span class="cx"> {
</span><span class="cx">     buffer.clear();
</span><span class="cx"> 
</span><span class="lines">@@ -1831,7 +1841,8 @@
</span><span class="cx">         for (int i = 0; i &lt; n; ++i) {
</span><span class="cx">             const std::pair&lt;int, int&gt;&amp; r = hostnameRanges[i];
</span><span class="cx">             append(buffer, string.substring(p, r.first - p));
</span><del>-            appendEncodedHostname(buffer, string.substring(r.first, r.second - r.first));
</del><ins>+            if (!appendEncodedHostname(buffer, string.substring(r.first, r.second - r.first)))
+                return false;
</ins><span class="cx">             p = r.second;
</span><span class="cx">         }
</span><span class="cx">         // This will copy either everything after the last hostname, or the
</span><span class="lines">@@ -1841,19 +1852,24 @@
</span><span class="cx">         int hostStart, hostEnd;
</span><span class="cx">         if (findHostnameInHierarchicalURL(string, hostStart, hostEnd)) {
</span><span class="cx">             append(buffer, string.substring(0, hostStart)); // Before hostname.
</span><del>-            appendEncodedHostname(buffer, string.substring(hostStart, hostEnd - hostStart));
</del><ins>+            if (!appendEncodedHostname(buffer, string.substring(hostStart, hostEnd - hostStart)))
+                return false;
</ins><span class="cx">             append(buffer, string.substring(hostEnd)); // After hostname.
</span><span class="cx">         } else {
</span><span class="cx">             // No hostname to encode, return the input.
</span><span class="cx">             append(buffer, string);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void encodeRelativeString(const String&amp; rel, const TextEncoding&amp; encoding, CharBuffer&amp; output)
</del><ins>+// Return value of false means error in encoding.
+static bool encodeRelativeString(const String&amp; rel, const TextEncoding&amp; encoding, CharBuffer&amp; output)
</ins><span class="cx"> {
</span><span class="cx">     UCharBuffer s;
</span><del>-    encodeHostnames(rel, s);
</del><ins>+    if (!encodeHostnames(rel, s))
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     TextEncoding pathEncoding(UTF8Encoding()); // Path is always encoded as UTF-8; other parts may depend on the scheme.
</span><span class="cx"> 
</span><span class="lines">@@ -1878,6 +1894,8 @@
</span><span class="cx">         memcpy(output.data() + pathDecoded.length(), otherDecoded.data(), otherDecoded.length());
</span><span class="cx">     }
</span><span class="cx">     output.append('\0'); // null-terminate the output.
</span><ins>+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static String substituteBackslashes(const String&amp; string)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebCoreNSURLExtrash"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -33,18 +33,19 @@
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT NSString *userVisibleString(NSURL *);
</span><span class="cx"> WEBCORE_EXPORT NSURL *URLByCanonicalizingURL(NSURL *);
</span><del>-WEBCORE_EXPORT NSURL *URLWithUserTypedString(NSString *, NSURL *baseURL);
</del><ins>+WEBCORE_EXPORT NSURL *URLWithUserTypedString(NSString *, NSURL *baseURL); // Return value of nil means error.
</ins><span class="cx"> WEBCORE_EXPORT NSURL *URLByRemovingUserInfo(NSURL *);
</span><del>-WEBCORE_EXPORT BOOL hostNameNeedsDecodingWithRange(NSString *, NSRange);
-WEBCORE_EXPORT BOOL hostNameNeedsEncodingWithRange(NSString *, NSRange);
-WEBCORE_EXPORT NSString *decodeHostNameWithRange(NSString *, NSRange);
-WEBCORE_EXPORT NSString *encodeHostNameWithRange(NSString *, NSRange);
-WEBCORE_EXPORT NSString *decodeHostName(NSString *);
-WEBCORE_EXPORT NSString *encodeHostName(NSString *);
</del><ins>+WEBCORE_EXPORT BOOL hostNameNeedsDecodingWithRange(NSString *, NSRange, BOOL* error);
+WEBCORE_EXPORT BOOL hostNameNeedsEncodingWithRange(NSString *, NSRange, BOOL* error);
+WEBCORE_EXPORT NSString *decodeHostNameWithRange(NSString *, NSRange); // Return value of nil means error.
+WEBCORE_EXPORT NSString *encodeHostNameWithRange(NSString *, NSRange); // Return value of nil means error.
+WEBCORE_EXPORT NSString *decodeHostName(NSString *); // Return value of nil means error.
+WEBCORE_EXPORT NSString *encodeHostName(NSString *); // Return value of nil means error.
</ins><span class="cx"> WEBCORE_EXPORT NSURL *URLByTruncatingOneCharacterBeforeComponent(NSURL *, CFURLComponentType);
</span><span class="cx"> WEBCORE_EXPORT NSURL *URLWithData(NSData *, NSURL *baseURL);
</span><span class="cx"> WEBCORE_EXPORT NSData *originalURLData(NSURL *);
</span><span class="cx"> WEBCORE_EXPORT NSData *dataForURLComponentType(NSURL *, CFURLComponentType);
</span><ins>+WEBCORE_EXPORT NSURL *URLWithUserTypedStringDeprecated(NSString *, NSURL *baseURL);
</ins><span class="cx"> 
</span><span class="cx"> NSRange rangeOfURLScheme(NSString *);
</span><span class="cx"> WEBCORE_EXPORT BOOL isUserVisibleURL(NSString *);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebCoreNSURLExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -453,7 +453,7 @@
</span><span class="cx"> // Return value of nil means no mapping is necessary.
</span><span class="cx"> // If makeString is NO, then return value is either nil or self to indicate mapping is necessary.
</span><span class="cx"> // If makeString is YES, then return value is either nil or the mapped string.
</span><del>-static NSString *mapHostNameWithRange(NSString *string, NSRange range, BOOL encode, BOOL makeString)
</del><ins>+static NSString *mapHostNameWithRange(NSString *string, NSRange range, BOOL encode, BOOL makeString, BOOL *error)
</ins><span class="cx"> {
</span><span class="cx">     if (range.length &gt; HOST_NAME_BUFFER_LENGTH)
</span><span class="cx">         return nil;
</span><span class="lines">@@ -476,10 +476,12 @@
</span><span class="cx">     int length = range.length;
</span><span class="cx">     [string getCharacters:sourceBuffer range:range];
</span><span class="cx">     
</span><del>-    UErrorCode error = U_ZERO_ERROR;
-    int32_t numCharactersConverted = (encode ? uidna_IDNToASCII : uidna_IDNToUnicode)(sourceBuffer, length, destinationBuffer, HOST_NAME_BUFFER_LENGTH, UIDNA_ALLOW_UNASSIGNED, NULL, &amp;error);
-    if (error != U_ZERO_ERROR)
</del><ins>+    UErrorCode uerror = U_ZERO_ERROR;
+    int32_t numCharactersConverted = (encode ? uidna_IDNToASCII : uidna_IDNToUnicode)(sourceBuffer, length, destinationBuffer, HOST_NAME_BUFFER_LENGTH, UIDNA_ALLOW_UNASSIGNED, NULL, &amp;uerror);
+    if (U_FAILURE(uerror)) {
+        *error = YES;
</ins><span class="cx">         return nil;
</span><ins>+    }
</ins><span class="cx">     
</span><span class="cx">     if (numCharactersConverted == length &amp;&amp; !memcmp(sourceBuffer, destinationBuffer, length * sizeof(UChar)))
</span><span class="cx">         return nil;
</span><span class="lines">@@ -487,52 +489,71 @@
</span><span class="cx">     if (!encode &amp;&amp; !allCharactersInIDNScriptWhiteList(destinationBuffer, numCharactersConverted) &amp;&amp; !allCharactersAllowedByTLDRules(destinationBuffer, numCharactersConverted))
</span><span class="cx">         return nil;
</span><span class="cx">     
</span><del>-    return makeString ? (NSString *)[NSString stringWithCharacters:destinationBuffer length:numCharactersConverted] : string;
</del><ins>+    return makeString ? [NSString stringWithCharacters:destinationBuffer length:numCharactersConverted] : string;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-BOOL hostNameNeedsDecodingWithRange(NSString *string, NSRange range)
</del><ins>+BOOL hostNameNeedsDecodingWithRange(NSString *string, NSRange range, BOOL *error)
</ins><span class="cx"> {
</span><del>-     return mapHostNameWithRange(string, range, NO, NO) != nil;
</del><ins>+    return mapHostNameWithRange(string, range, NO, NO, error) != nil;
</ins><span class="cx"> }
</span><span class="cx">  
</span><del>-BOOL hostNameNeedsEncodingWithRange(NSString *string, NSRange range)
</del><ins>+BOOL hostNameNeedsEncodingWithRange(NSString *string, NSRange range, BOOL *error)
</ins><span class="cx"> {
</span><del>-     return mapHostNameWithRange(string, range, YES,  NO) != nil;
</del><ins>+    return mapHostNameWithRange(string, range, YES,  NO, error) != nil;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NSString *decodeHostNameWithRange(NSString *string, NSRange range)
</span><span class="cx"> {
</span><del>-    return mapHostNameWithRange(string, range, NO, YES);
</del><ins>+    BOOL error = NO;
+    NSString *host = mapHostNameWithRange(string, range, NO, YES, &amp;error);
+    if (error)
+        return nil;
+    return !host ? string : host;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NSString *encodeHostNameWithRange(NSString *string, NSRange range)
</span><span class="cx"> {
</span><del>-    return mapHostNameWithRange(string, range, YES, YES);
</del><ins>+    BOOL error = NO;
+    NSString *host = mapHostNameWithRange(string, range, YES, YES, &amp;error);
+    if (error)
+        return nil;
+    return !host ? string : host;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NSString *decodeHostName(NSString *string)
</span><span class="cx"> {
</span><del>-    NSString *name = mapHostNameWithRange(string, NSMakeRange(0, [string length]), NO, YES);
-    return !name ? string : name;
</del><ins>+    BOOL error = NO;
+    NSString *host = mapHostNameWithRange(string, NSMakeRange(0, [string length]), NO, YES, &amp;error);
+    if (error)
+        return nil;
+    return !host ? string : host;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NSString *encodeHostName(NSString *string)
</span><span class="cx"> {
</span><del>-    NSString *name =  mapHostNameWithRange(string, NSMakeRange(0, [string length]), YES, YES);
-    return !name ? string : name;
</del><ins>+    BOOL error = NO;
+    NSString *host = mapHostNameWithRange(string, NSMakeRange(0, [string length]), YES, YES, &amp;error);
+    if (error)
+        return nil;
+    return !host ? string : host;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void collectRangesThatNeedMapping(NSString *string, NSRange range, void *context, BOOL encode)
</span><span class="cx"> {
</span><del>-    BOOL needsMapping = encode ? hostNameNeedsEncodingWithRange(string, range) : hostNameNeedsDecodingWithRange(string, range);
-    if (!needsMapping)
</del><ins>+    // Generally, we want to optimize for the case where there is one host name that does not need mapping.
+    // Therefore, we use nil to indicate no mapping here and an empty array to indicate error.
+
+    BOOL error = NO;
+    BOOL needsMapping = encode ? hostNameNeedsEncodingWithRange(string, range, &amp;error) : hostNameNeedsDecodingWithRange(string, range, &amp;error);
+    if (!error &amp;&amp; !needsMapping)
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     NSMutableArray **array = (NSMutableArray **)context;
</span><span class="cx">     if (!*array)
</span><span class="cx">         *array = [[NSMutableArray alloc] init];
</span><span class="cx">     
</span><del>-    [*array addObject:[NSValue valueWithRange:range]];
</del><ins>+    if (!error)
+        [*array addObject:[NSValue valueWithRange:range]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void collectRangesThatNeedEncoding(NSString *string, NSRange range, void *context)
</span><span class="lines">@@ -681,6 +702,9 @@
</span><span class="cx">     applyHostNameFunctionToURLString(string, f, &amp;hostNameRanges);
</span><span class="cx">     if (!hostNameRanges)
</span><span class="cx">         return string;
</span><ins>+
+    if (![hostNameRanges count])
+        return nil;
</ins><span class="cx">     
</span><span class="cx">     // Do the mapping.
</span><span class="cx">     NSMutableString *mutableCopy = [string mutableCopy];
</span><span class="lines">@@ -787,24 +811,18 @@
</span><span class="cx">             result = CFBridgingRelease(CFURLCreateAbsoluteURLWithBytes(NULL, bytes, length, kCFStringEncodingISOLatin1, (CFURLRef)baseURL, YES));
</span><span class="cx">     } else
</span><span class="cx">         result = [NSURL URLWithString:@&quot;&quot;];
</span><del>-                
</del><ins>+
</ins><span class="cx">     return result;
</span><span class="cx"> }
</span><del>-
-NSURL *URLWithUserTypedString(NSString *string, NSURL *URL)
</del><ins>+static NSData *dataWithUserTypedString(NSString *string)
</ins><span class="cx"> {
</span><del>-    if (!string)
-        return nil;
-
-    string = mapHostNames(stringByTrimmingWhitespace(string), YES);
-    
</del><span class="cx">     NSData *userTypedData = [string dataUsingEncoding:NSUTF8StringEncoding];
</span><span class="cx">     ASSERT(userTypedData);
</span><span class="cx">     
</span><span class="cx">     const UInt8* inBytes = static_cast&lt;const UInt8 *&gt;([userTypedData bytes]);
</span><span class="cx">     int inLength = [userTypedData length];
</span><span class="cx">     if (!inLength)
</span><del>-        return [NSURL URLWithString:@&quot;&quot;];
</del><ins>+        return nil;
</ins><span class="cx">     
</span><span class="cx">     char* outBytes = static_cast&lt;char *&gt;(malloc(inLength * 3)); // large enough to %-escape every character
</span><span class="cx">     char* p = outBytes;
</span><span class="lines">@@ -822,10 +840,41 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    NSData *data = [NSData dataWithBytesNoCopy:outBytes length:outLength]; // adopts outBytes
</del><ins>+    return [NSData dataWithBytesNoCopy:outBytes length:outLength]; // adopts outBytes
+}
+
+NSURL *URLWithUserTypedString(NSString *string, NSURL *URL)
+{
+    if (!string)
+        return nil;
+
+    string = mapHostNames(stringByTrimmingWhitespace(string), YES);
+    if (!string)
+        return nil;
+
+    NSData *data = dataWithUserTypedString(string);
+    if (!data)
+        return [NSURL URLWithString:@&quot;&quot;];
+
</ins><span class="cx">     return URLWithData(data, URL);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+NSURL *URLWithUserTypedStringDeprecated(NSString *string, NSURL *URL)
+{
+    if (!string)
+        return nil;
+
+    NSURL *result = URLWithUserTypedString(string, URL);
+    if (!result) {
+        NSData *resultData = dataWithUserTypedString(string);
+        if (!resultData)
+            return [NSURL URLWithString:@&quot;&quot;];
+        result = URLWithData(resultData, URL);
+    }
+
+    return result;
+}
+
</ins><span class="cx"> static BOOL hasQuestionMarkOnlyQueryString(NSURL *URL)
</span><span class="cx"> {
</span><span class="cx">     CFRange rangeWithSeparators;
</span><span class="lines">@@ -1071,8 +1120,13 @@
</span><span class="cx">     
</span><span class="cx">     free(after);
</span><span class="cx">     
</span><del>-    if (mayNeedHostNameDecoding)
-        result = mapHostNames(result, NO);
</del><ins>+    if (mayNeedHostNameDecoding) {
+        // FIXME: Is it good to ignore the failure of mapHostNames and keep result intact?
+        NSString *mappedResult = mapHostNames(result, NO);
+        if (mappedResult)
+            result = mappedResult;
+    }
+
</ins><span class="cx">     result = [result precomposedStringWithCanonicalMapping];
</span><span class="cx">     return CFBridgingRelease(createStringWithEscapedUnsafeCharacters((CFStringRef)result));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitiosChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/ChangeLog (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/ChangeLog        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/ios/ChangeLog        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-03-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        URL Parsing should signal failure for illegal IDN
+        https://bugs.webkit.org/show_bug.cgi?id=154945
+        &lt;rdar://problem/8014795&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * Misc/WebNSStringExtrasIOS.m:
+        (-[NSString _web_possibleURLsForForUserTypedString:]):
+        * WebView/WebPDFViewPlaceholder.mm:
+        (-[WebPDFViewPlaceholder _updateTitleForURL:]):
+
</ins><span class="cx"> 2016-03-15  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r198203.
</span></span></pre></div>
<a id="trunkSourceWebKitiosMiscWebNSStringExtrasIOSm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/ios/Misc/WebNSStringExtrasIOS.m        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx">             
</span><span class="cx">             if (URLHasScheme) {
</span><span class="cx">                 // - use it unchanged
</span><del>-                NSURL *URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                NSURL *URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                 if (URL != nil) {
</span><span class="cx">                     [result addObject:URL];
</span><span class="cx">                 }
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">                 if ([[workString lowercaseString] hasPrefix:@&quot;www.&quot;]) {
</span><span class="cx">                     // - just prepend &quot;http://&quot;
</span><span class="cx">                     [workString insertString:@&quot;http://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx">                 } else if ([[workString lowercaseString] hasPrefix:@&quot;ftp.&quot;]) {
</span><span class="cx">                     // - just prepend &quot;ftp://&quot;
</span><span class="cx">                     [workString insertString:@&quot;ftp://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">                 } else if (firstAtRange.location != NSNotFound &amp;&amp; firstAtRange.location &lt; firstSlashRange.location) {
</span><span class="cx">                     // - justprepend &quot;http://&quot;
</span><span class="cx">                     [workString insertString:@&quot;http://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -134,14 +134,14 @@
</span><span class="cx">                 } else if (firstDotRange.location != NSNotFound &amp;&amp; firstDotRange.location &lt; firstSlashRange.location) {
</span><span class="cx">                     // - try prepending &quot;http://&quot;
</span><span class="cx">                     [workString insertString:@&quot;http://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="cx">                     
</span><span class="cx">                     // - try prepending &quot;http://www.&quot;
</span><span class="cx">                     [workString insertString:@&quot;www.&quot; atIndex:strlen(&quot;http://&quot;)];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">                            [[workString lowercaseString] hasPrefix:@&quot;localhost/&quot;]) {
</span><span class="cx">                     // - just prepend &quot;http://&quot;
</span><span class="cx">                     [workString insertString:@&quot;http://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -160,7 +160,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                     // - try prepending &quot;http://&quot;
</span><span class="cx">                     [workString insertString:@&quot;http://&quot; atIndex:0];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx">                         [workString insertString:@&quot;.com&quot; atIndex:endOfHostnameOrPort];
</span><span class="cx">                     }
</span><span class="cx">                     [workString insertString:@&quot;www.&quot; atIndex:strlen(&quot;http://&quot;)];
</span><del>-                    URL = [NSURL _web_URLWithUserTypedString:workString];
</del><ins>+                    URL = [NSURL _webkit_URLWithUserTypedString:workString];
</ins><span class="cx">                     if (URL != nil) {
</span><span class="cx">                         [result addObject:URL];
</span><span class="cx">                     }
</span></span></pre></div>
<a id="trunkSourceWebKitiosWebViewWebPDFViewPlaceholdermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ios/WebView/WebPDFViewPlaceholder.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ios/WebView/WebPDFViewPlaceholder.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/ios/WebView/WebPDFViewPlaceholder.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx"> {
</span><span class="cx">     NSString *titleFromURL = [URL lastPathComponent];
</span><span class="cx">     if (![titleFromURL length] || [titleFromURL isEqualToString:@&quot;/&quot;])
</span><del>-        titleFromURL = [[URL _web_hostString] _web_decodeHostName];
</del><ins>+        titleFromURL = [[URL _web_hostString] _webkit_decodeHostName];
</ins><span class="cx"> 
</span><span class="cx">     [self setTitle:titleFromURL];
</span><span class="cx">     [[self _frame] _dispatchDidReceiveTitle:titleFromURL];
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2016-03-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        URL Parsing should signal failure for illegal IDN
+        https://bugs.webkit.org/show_bug.cgi?id=154945
+        &lt;rdar://problem/8014795&gt;
+
+        Reviewed by Brent Fulgham.
+
+        In this patch, we add new SPIs _webkit_URLWithUserTypedString, _webkit_decodeHostName and
+        _webkit_encodeHostName which will return nil while dealing with illegal IDN.
+
+        Old SPIs _web_URLWithUserTypedString, _web_decodeHostName and _web_encodeHostName are marked
+        deprecated as they ignore URL parsing failure.
+
+        * History/WebHistoryItem.mm:
+        (-[WebHistoryItem initFromDictionaryRepresentation:]):
+        * Misc/WebKitErrors.m:
+        (+[NSError _webKitErrorWithCode:failingURL:]):
+        * Misc/WebNSFileManagerExtras.mm:
+        (-[NSFileManager _webkit_setMetadataURL:referrer:atPath:]):
+        * Misc/WebNSPasteboardExtras.mm:
+        (-[NSPasteboard _web_bestURL]):
+        * Misc/WebNSURLExtras.h:
+        * Misc/WebNSURLExtras.mm:
+        (+[NSURL _web_URLWithUserTypedString:]):
+        (+[NSURL _webkit_URLWithUserTypedString:relativeToURL:]):
+        (+[NSURL _webkit_URLWithUserTypedString:]):
+        (-[NSString _web_decodeHostName]):
+        (-[NSString _web_encodeHostName]):
+        (-[NSString _webkit_decodeHostName]):
+        (-[NSString _webkit_encodeHostName]):
+        * Panels/WebAuthenticationPanel.m:
+        (-[WebAuthenticationPanel setUpForChallenge:]):
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::canonicalizeURLString):
+
</ins><span class="cx"> 2016-03-15  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ios-sim debug] API test WebKit1.AudioSessionCategoryIOS timing out
</span></span></pre></div>
<a id="trunkSourceWebKitmacHistoryWebHistoryItemmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/History/WebHistoryItem.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/History/WebHistoryItem.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/History/WebHistoryItem.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -333,7 +333,7 @@
</span><span class="cx">     // Check if we've read a broken URL from the file that has non-Latin1 chars.  If so, try to convert
</span><span class="cx">     // as if it was from user typing.
</span><span class="cx">     if (![URLString canBeConvertedToEncoding:NSISOLatin1StringEncoding]) {
</span><del>-        NSURL *tempURL = [NSURL _web_URLWithUserTypedString:URLString];
</del><ins>+        NSURL *tempURL = [NSURL _webkit_URLWithUserTypedString:URLString];
</ins><span class="cx">         ASSERT(tempURL);
</span><span class="cx">         NSString *newURLString = [tempURL _web_originalDataAsString];
</span><span class="cx">         core(_private)-&gt;setURLString(newURLString);
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebKitErrorsm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebKitErrors.m (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebKitErrors.m        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Misc/WebKitErrors.m        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> 
</span><span class="cx"> + (NSError *)_webKitErrorWithCode:(int)code failingURL:(NSString *)URLString
</span><span class="cx"> {
</span><del>-    return [self _webKitErrorWithDomain:WebKitErrorDomain code:code URL:[NSURL _web_URLWithUserTypedString:URLString]];
</del><ins>+    return [self _webKitErrorWithDomain:WebKitErrorDomain code:code URL:[NSURL _webkit_URLWithUserTypedString:URLString]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (id)_initWithPluginErrorCode:(int)code
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSFileManagerExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Misc/WebNSFileManagerExtras.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">     ASSERT(URLString);
</span><span class="cx">     ASSERT(path);
</span><span class="cx"> 
</span><del>-    NSURL *URL = [NSURL _web_URLWithUserTypedString:URLString];
</del><ins>+    NSURL *URL = [NSURL _webkit_URLWithUserTypedString:URLString];
</ins><span class="cx">     if (URL)
</span><span class="cx">         URLString = [[URL _web_URLByRemovingUserInfo] _web_userVisibleString];
</span><span class="cx">  
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSPasteboardExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx">     if ([types containsObject:NSStringPboardType]) {
</span><span class="cx">         NSString *URLString = [self stringForType:NSStringPboardType];
</span><span class="cx">         if ([URLString _webkit_looksLikeAbsoluteURL]) {
</span><del>-            NSURL *URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
</del><ins>+            NSURL *URL = [[NSURL _webkit_URLWithUserTypedString:URLString] _webkit_canonicalize];
</ins><span class="cx">             if (URL) {
</span><span class="cx">                 return URL;
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSURLExtrash"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -33,9 +33,16 @@
</span><span class="cx"> 
</span><span class="cx"> @interface NSURL (WebNSURLExtras)
</span><span class="cx"> 
</span><ins>+// Deprecated as it ignores URL parsing error.
+// Please use the _webkit_ counterparts.
</ins><span class="cx"> + (NSURL *)_web_URLWithUserTypedString:(NSString *)string;
</span><span class="cx"> + (NSURL *)_web_URLWithUserTypedString:(NSString *)string relativeToURL:(NSURL *)URL;
</span><span class="cx"> 
</span><ins>+// New SPI.
+// Return value of nil means error in URL parsing.
++ (NSURL *)_webkit_URLWithUserTypedString:(NSString *)string;
++ (NSURL *)_webkit_URLWithUserTypedString:(NSString *)string relativeToURL:(NSURL *)URL;
+
</ins><span class="cx"> + (NSURL *)_web_URLWithDataAsString:(NSString *)string;
</span><span class="cx"> + (NSURL *)_web_URLWithDataAsString:(NSString *)string relativeToURL:(NSURL *)baseURL;
</span><span class="cx"> 
</span><span class="lines">@@ -75,9 +82,18 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_web_isUserVisibleURL;
</span><span class="cx"> 
</span><del>-- (NSString *)_web_decodeHostName; // turns funny-looking ASCII form into Unicode, returns self if no decoding needed, convenient cover
-- (NSString *)_web_encodeHostName; // turns Unicode into funny-looking ASCII form, returns self if no decoding needed, convenient cover
</del><ins>+// Deprecated as it ignores URL parsing error.
+// Please use the _webkit_ counterparts.
+// turns funny-looking ASCII form into Unicode, returns self if no decoding needed, convenient cover
+- (NSString *)_web_decodeHostName;
+// turns Unicode into funny-looking ASCII form, returns self if no decoding needed, convenient cover
+- (NSString *)_web_encodeHostName;
</ins><span class="cx"> 
</span><ins>+// New SPI.
+// Return value of nil means error in URL parsing.
+- (NSString *)_webkit_decodeHostName;
+- (NSString *)_webkit_encodeHostName;
+
</ins><span class="cx"> - (BOOL)_webkit_isJavaScriptURL;
</span><span class="cx"> - (BOOL)_webkit_isFileURL;
</span><span class="cx"> - (BOOL)_webkit_looksLikeAbsoluteURL;
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSURLExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -57,11 +57,21 @@
</span><span class="cx"> 
</span><span class="cx"> + (NSURL *)_web_URLWithUserTypedString:(NSString *)string relativeToURL:(NSURL *)URL
</span><span class="cx"> {
</span><del>-    return URLWithUserTypedString(string, URL);
</del><ins>+    return URLWithUserTypedStringDeprecated(string, URL);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (NSURL *)_web_URLWithUserTypedString:(NSString *)string
</span><span class="cx"> {
</span><ins>+    return URLWithUserTypedStringDeprecated(string, nil);
+}
+
++ (NSURL *)_webkit_URLWithUserTypedString:(NSString *)string relativeToURL:(NSURL *)URL
+{
+    return URLWithUserTypedString(string, URL);
+}
+
++ (NSURL *)_webkit_URLWithUserTypedString:(NSString *)string
+{
</ins><span class="cx">     return URLWithUserTypedString(string, nil);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -255,11 +265,23 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)_web_decodeHostName
</span><span class="cx"> {
</span><del>-    return decodeHostName(self);
</del><ins>+    NSString *name = decodeHostName(self);
+    return !name ? self : name;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)_web_encodeHostName
</span><span class="cx"> {
</span><ins>+    NSString *name = encodeHostName(self);
+    return !name ? self : name;
+}
+
+- (NSString *)_webkit_decodeHostName
+{
+    return decodeHostName(self);
+}
+
+- (NSString *)_webkit_encodeHostName
+{
</ins><span class="cx">     return encodeHostName(self);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacPanelsWebAuthenticationPanelm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Panels/WebAuthenticationPanel.m (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Panels/WebAuthenticationPanel.m        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/Panels/WebAuthenticationPanel.m        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -128,9 +128,9 @@
</span><span class="cx"> 
</span><span class="cx">     NSString *host;
</span><span class="cx">     if ([space port] == 0) {
</span><del>-        host = [[space host] _web_decodeHostName];
</del><ins>+        host = [[space host] _webkit_decodeHostName];
</ins><span class="cx">     } else {
</span><del>-        host = [NSString stringWithFormat:@&quot;%@:%ld&quot;, [[space host] _web_decodeHostName], (long)[space port]];
</del><ins>+        host = [NSString stringWithFormat:@&quot;%@:%ld&quot;, [[space host] _webkit_decodeHostName], (long)[space port]];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     NSString *realm = [space realm];
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebEditorClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -419,7 +419,7 @@
</span><span class="cx"> {
</span><span class="cx">     NSURL *URL = nil;
</span><span class="cx">     if ([URLString _webkit_looksLikeAbsoluteURL])
</span><del>-        URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
</del><ins>+        URL = [[NSURL _webkit_URLWithUserTypedString:URLString] _webkit_canonicalize];
</ins><span class="cx">     return URL;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Tools/ChangeLog        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-03-16  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        URL Parsing should signal failure for illegal IDN
+        https://bugs.webkit.org/show_bug.cgi?id=154945
+        &lt;rdar://problem/8014795&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController fetch:]):
+        * TestWebKitAPI/Tests/Cocoa/URLExtras.mm:
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2016-03-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS Simulator] Test result snapshots are upside down
</span></span></pre></div>
<a id="trunkToolsMiniBrowsermacWK2BrowserWindowControllerm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx"> {
</span><span class="cx">     [urlText setStringValue:[self addProtocolIfNecessary:[urlText stringValue]]];
</span><span class="cx"> 
</span><del>-    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL _web_URLWithUserTypedString:[urlText stringValue]]]];
</del><ins>+    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL _webkit_URLWithUserTypedString:[urlText stringValue]]]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (IBAction)showHideWebView:(id)sender
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsCocoaURLExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/Cocoa/URLExtras.mm (198288 => 198289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/Cocoa/URLExtras.mm        2016-03-16 18:16:32 UTC (rev 198288)
+++ trunk/Tools/TestWebKitAPI/Tests/Cocoa/URLExtras.mm        2016-03-16 18:31:32 UTC (rev 198289)
</span><span class="lines">@@ -127,4 +127,23 @@
</span><span class="cx">     EXPECT_STREQ(&quot;site.com\xE3\x80\x80othersite.org&quot;, [WebCore::decodeHostName(@&quot;site.com\xE3\x80\x80othersite.org&quot;) UTF8String]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(WebCore, URLExtras_ParsingError)
+{
+    // Expect IDN failure.
+    NSURL *url = WebCore::URLWithUserTypedString(@&quot;http://.com&quot;, nil);
+    EXPECT_TRUE(url == nil);
+
+    NSString *encodedHostName = WebCore::encodeHostName(@&quot;http://.com&quot;);
+    EXPECT_TRUE(encodedHostName == nil);
+}
+
+TEST(WebCore, URLExtras_Nil)
+{
+    NSURL *url1 = WebCore::URLWithUserTypedString(nil, nil);
+    EXPECT_TRUE(url1 == nil);
+
+    NSURL *url2 = WebCore::URLWithUserTypedStringDeprecated(nil, nil);
+    EXPECT_TRUE(url2 == nil);
+}
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre>
</div>
</div>

</body>
</html>