<!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>[244853] 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/244853">244853</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2019-05-01 15:08:00 -0700 (Wed, 01 May 2019)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
https://bugs.webkit.org/show_bug.cgi?id=181950
<rdar://problem/43357371>
Reviewed by Brent Fulgham.
Source/WebCore:
This patch moves Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
to be more aligned with the HTML standard:
https://html.spec.whatwg.org/multipage/origin.html#is-a-registrable-domain-suffix-of-or-is-equal-to.
Besides that, it also removes redundant codes within the original method that is also done in
OriginAccessEntry::matchesOrigin.
Covered by new API tests.
* dom/Document.cpp:
(WebCore::Document::setDomain):
(WebCore::Document::domainIsRegisterable const): Deleted.
* dom/Document.h:
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::isMatchingRegistrableDomainSuffix const):
* page/SecurityOrigin.h:
Tools:
* TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp:
(TestWebKitAPI::TEST_F):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOrigincpp">trunk/Source/WebCore/page/SecurityOrigin.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSecurityOriginh">trunk/Source/WebCore/page/SecurityOrigin.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreSecurityOrigincpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Source/WebCore/ChangeLog 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-05-01 Jiewen Tan <jiewen_tan@apple.com>
+
+ Move Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
+ https://bugs.webkit.org/show_bug.cgi?id=181950
+ <rdar://problem/43357371>
+
+ Reviewed by Brent Fulgham.
+
+ This patch moves Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
+ to be more aligned with the HTML standard:
+ https://html.spec.whatwg.org/multipage/origin.html#is-a-registrable-domain-suffix-of-or-is-equal-to.
+ Besides that, it also removes redundant codes within the original method that is also done in
+ OriginAccessEntry::matchesOrigin.
+
+ Covered by new API tests.
+
+ * dom/Document.cpp:
+ (WebCore::Document::setDomain):
+ (WebCore::Document::domainIsRegisterable const): Deleted.
+ * dom/Document.h:
+ * page/SecurityOrigin.cpp:
+ (WebCore::SecurityOrigin::isMatchingRegistrableDomainSuffix const):
+ * page/SecurityOrigin.h:
+
</ins><span class="cx"> 2019-05-01 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> [iOS] Element::focus and Element::scrollIntoView do not clamp scroll positions
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -135,7 +135,6 @@
</span><span class="cx"> #include "NodeIterator.h"
</span><span class="cx"> #include "NodeRareData.h"
</span><span class="cx"> #include "NodeWithIndex.h"
</span><del>-#include "OriginAccessEntry.h"
</del><span class="cx"> #include "OverflowEvent.h"
</span><span class="cx"> #include "PageConsoleClient.h"
</span><span class="cx"> #include "PageGroup.h"
</span><span class="lines">@@ -4857,49 +4856,6 @@
</span><span class="cx"> return securityOrigin().domain();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool Document::domainIsRegisterable(const String& newDomain) const
-{
- if (newDomain.isEmpty())
- return false;
-
- const String& effectiveDomain = domain();
-
- // If the new domain is the same as the old domain, return true so that
- // we still call securityOrigin().setDomainForDOM. This will change the
- // security check behavior. For example, if a page loaded on port 8000
- // assigns its current domain using document.domain, the page will
- // allow other pages loaded on different ports in the same domain that
- // have also assigned to access this page.
- if (equalIgnoringASCIICase(effectiveDomain, newDomain))
- return true;
-
- // e.g. newDomain = webkit.org (10) and domain() = www.webkit.org (14)
- unsigned oldLength = effectiveDomain.length();
- unsigned newLength = newDomain.length();
- if (newLength >= oldLength)
- return false;
-
- auto ipAddressSetting = settings().treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : OriginAccessEntry::TreatIPAddressAsIPAddress;
- OriginAccessEntry accessEntry { securityOrigin().protocol(), newDomain, OriginAccessEntry::AllowSubdomains, ipAddressSetting };
- if (!accessEntry.matchesOrigin(securityOrigin()))
- return false;
-
- if (effectiveDomain[oldLength - newLength - 1] != '.')
- return false;
- if (StringView { effectiveDomain }.substring(oldLength - newLength) != newDomain)
- return false;
-
- auto potentialPublicSuffix = newDomain;
- if (potentialPublicSuffix.startsWith('.'))
- potentialPublicSuffix.remove(0, 1);
-
-#if ENABLE(PUBLIC_SUFFIX_LIST)
- return !isPublicSuffix(potentialPublicSuffix);
-#else
- return true;
-#endif
-}
-
</del><span class="cx"> ExceptionOr<void> Document::setDomain(const String& newDomain)
</span><span class="cx"> {
</span><span class="cx"> if (!frame())
</span><span class="lines">@@ -4917,7 +4873,7 @@
</span><span class="cx"> if (effectiveDomain.isEmpty())
</span><span class="cx"> return Exception { SecurityError, "The document has a null effectiveDomain." };
</span><span class="cx">
</span><del>- if (!domainIsRegisterable(newDomain))
</del><ins>+ if (!securityOrigin().isMatchingRegistrableDomainSuffix(newDomain, settings().treatIPAddressAsDomain()))
</ins><span class="cx"> return Exception { SecurityError, "Attempted to use a non-registrable domain." };
</span><span class="cx">
</span><span class="cx"> securityOrigin().setDomainFromDOM(newDomain);
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Source/WebCore/dom/Document.h 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -1644,8 +1644,6 @@
</span><span class="cx">
</span><span class="cx"> void platformSuspendOrStopActiveDOMObjects();
</span><span class="cx">
</span><del>- bool domainIsRegisterable(const String&) const;
-
</del><span class="cx"> void enableTemporaryTimeUserGesture();
</span><span class="cx">
</span><span class="cx"> bool isBodyPotentiallyScrollable(HTMLBodyElement&);
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOrigincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.cpp (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.cpp 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Source/WebCore/page/SecurityOrigin.cpp 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "SecurityOrigin.h"
</span><span class="cx">
</span><span class="cx"> #include "BlobURL.h"
</span><ins>+#include "OriginAccessEntry.h"
</ins><span class="cx"> #include "SchemeRegistry.h"
</span><span class="cx"> #include "SecurityPolicy.h"
</span><span class="cx"> #include "TextEncoding.h"
</span><span class="lines">@@ -432,6 +433,27 @@
</span><span class="cx"> return isSameSchemeHostPort(other);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool SecurityOrigin::isMatchingRegistrableDomainSuffix(const String& domainSuffix, bool treatIPAddressAsDomain) const
+{
+ if (domainSuffix.isEmpty())
+ return false;
+
+ auto ipAddressSetting = treatIPAddressAsDomain ? OriginAccessEntry::TreatIPAddressAsDomain : OriginAccessEntry::TreatIPAddressAsIPAddress;
+ OriginAccessEntry accessEntry { protocol(), domainSuffix, OriginAccessEntry::AllowSubdomains, ipAddressSetting };
+ if (!accessEntry.matchesOrigin(*this))
+ return false;
+
+ // Always return true if it is an exact match.
+ if (domainSuffix.length() == host().length())
+ return true;
+
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ return !isPublicSuffix(domainSuffix);
+#else
+ return true;
+#endif
+}
+
</ins><span class="cx"> void SecurityOrigin::grantLoadLocalResources()
</span><span class="cx"> {
</span><span class="cx"> // Granting privileges to some, but not all, documents in a SecurityOrigin
</span></span></pre></div>
<a id="trunkSourceWebCorepageSecurityOriginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SecurityOrigin.h (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SecurityOrigin.h 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Source/WebCore/page/SecurityOrigin.h 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -204,6 +204,10 @@
</span><span class="cx"> // https://html.spec.whatwg.org/multipage/browsers.html#same-origin
</span><span class="cx"> WEBCORE_EXPORT bool isSameOriginAs(const SecurityOrigin&) const;
</span><span class="cx">
</span><ins>+ // This method implements the "is a registrable domain suffix of or is equal to" algorithm from the HTML Standard:
+ // https://html.spec.whatwg.org/multipage/origin.html#is-a-registrable-domain-suffix-of-or-is-equal-to
+ WEBCORE_EXPORT bool isMatchingRegistrableDomainSuffix(const String&, bool treatIPAddressAsDomain = false) const;
+
</ins><span class="cx"> bool isPotentiallyTrustworthy() const { return m_isPotentiallyTrustworthy; }
</span><span class="cx"> void setIsPotentiallyTrustworthy(bool value) { m_isPotentiallyTrustworthy = value; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Tools/ChangeLog 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2019-05-01 Jiewen Tan <jiewen_tan@apple.com>
+
+ Move Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
+ https://bugs.webkit.org/show_bug.cgi?id=181950
+ <rdar://problem/43357371>
+
+ Reviewed by Brent Fulgham.
+
+ * TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp:
+ (TestWebKitAPI::TEST_F):
+
</ins><span class="cx"> 2019-05-01 Aakash Jain <aakash_jain@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove webkitpy and bindings EWS queues from dashboard
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreSecurityOrigincpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp (244852 => 244853)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp 2019-05-01 21:40:25 UTC (rev 244852)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp 2019-05-01 22:08:00 UTC (rev 244853)
</span><span class="lines">@@ -183,4 +183,44 @@
</span><span class="cx"> EXPECT_FALSE(SecurityOrigin::createFromString("dummy:a")->isPotentiallyTrustworthy());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+TEST_F(SecurityOriginTest, IsRegistrableDomainSuffix)
+{
+ auto exampleOrigin = SecurityOrigin::create(URL(URL(), "http://www.example.com"));
+ EXPECT_TRUE(exampleOrigin->isMatchingRegistrableDomainSuffix("example.com"));
+ EXPECT_TRUE(exampleOrigin->isMatchingRegistrableDomainSuffix("www.example.com"));
+#if !ENABLE(PUBLIC_SUFFIX_LIST)
+ EXPECT_TRUE(exampleOrigin->isMatchingRegistrableDomainSuffix("com"));
+#endif
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix(""));
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix("."));
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix(".example.com"));
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix(".www.example.com"));
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix("example.com."));
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ EXPECT_FALSE(exampleOrigin->isMatchingRegistrableDomainSuffix("com"));
+#endif
+
+ auto exampleDotOrigin = SecurityOrigin::create(URL(URL(), "http://www.example.com."));
+ EXPECT_TRUE(exampleDotOrigin->isMatchingRegistrableDomainSuffix("example.com."));
+ EXPECT_TRUE(exampleDotOrigin->isMatchingRegistrableDomainSuffix("www.example.com."));
+#if !ENABLE(PUBLIC_SUFFIX_LIST)
+ EXPECT_TRUE(exampleOrigin->isMatchingRegistrableDomainSuffix("com."));
+#endif
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix(""));
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix("."));
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix(".example.com."));
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix(".www.example.com."));
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix("example.com"));
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+ EXPECT_FALSE(exampleDotOrigin->isMatchingRegistrableDomainSuffix("com"));
+#endif
+
+ auto ipOrigin = SecurityOrigin::create(URL(URL(), "http://127.0.0.1"));
+ EXPECT_TRUE(ipOrigin->isMatchingRegistrableDomainSuffix("127.0.0.1", true));
+ EXPECT_FALSE(ipOrigin->isMatchingRegistrableDomainSuffix("127.0.0.2", true));
+
+ auto comOrigin = SecurityOrigin::create(URL(URL(), "http://com"));
+ EXPECT_TRUE(comOrigin->isMatchingRegistrableDomainSuffix("com"));
+}
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre>
</div>
</div>
</body>
</html>