<!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>[194386] 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/194386">194386</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-12-23 02:04:44 -0800 (Wed, 23 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Content blockers should be able to promote http to https
https://bugs.webkit.org/show_bug.cgi?id=148966
Patch by Chris Aljoudi <chris@chrismatic.io> and Alex Christensen <achristensen@webkit.org> on 2015-12-23
Reviewed by Benjamin Poulain.
Source/WebCore:
Test: http/tests/contentextensions/make-https.html
* contentextensions/ContentExtensionActions.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::serializeActions):
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::loadAction):
* contentextensions/ContentExtensionRule.cpp:
(WebCore::ContentExtensions::Action::deserialize):
(WebCore::ContentExtensions::Action::deserializeType):
(WebCore::ContentExtensions::Action::serializedLength):
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
* platform/URL.cpp:
(WebCore::URL::isBlankURL):
(WebCore::defaultPortsMap):
(WebCore::defaultPortForProtocol):
(WebCore::isDefaultPortForProtocol):
(WebCore::portAllowed):
* platform/URL.h:
Tools:
* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(WebCore::ContentExtensions::operator<<):
(TestWebKitAPI::TEST_F):
LayoutTests:
* http/tests/contentextensions/make-https-expected.txt: Added.
* http/tests/contentextensions/make-https.html: Added.
* http/tests/contentextensions/make-https.html.json: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionActionsh">trunk/Source/WebCore/contentextensions/ContentExtensionActions.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionCompilercpp">trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionParsercpp">trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionRulecpp">trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformURLcpp">trunk/Source/WebCore/platform/URL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformURLh">trunk/Source/WebCore/platform/URL.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscontentextensionsmakehttpsexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsmakehttpshtml">trunk/LayoutTests/http/tests/contentextensions/make-https.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionsmakehttpshtmljson">trunk/LayoutTests/http/tests/contentextensions/make-https.html.json</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/LayoutTests/ChangeLog        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-12-23 Chris Aljoudi <chris@chrismatic.io> and Alex Christensen <achristensen@webkit.org>
+
+ Content blockers should be able to promote http to https
+ https://bugs.webkit.org/show_bug.cgi?id=148966
+
+ Reviewed by Benjamin Poulain.
+
+ * http/tests/contentextensions/make-https-expected.txt: Added.
+ * http/tests/contentextensions/make-https.html: Added.
+ * http/tests/contentextensions/make-https.html.json: Added.
+
</ins><span class="cx"> 2015-12-22 Xabier Rodriguez Calvar <calvaris@igalia.com>
</span><span class="cx">
</span><span class="cx"> [Streams API] Fix cosmetic things after importing spec tests
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsmakehttpsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt (0 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/make-https-expected.txt        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+http://127.0.0.1:8000/try_to_promote - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/contentextensions/make-https.html - didFinishLoading
+http://127.0.0.1:8000/try_to_promote - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/try_to_promote, http status code 404>
+http://127.0.0.1:8000/try_to_promote - didFinishLoading
+http://127.0.0.1/nope - willSendRequest <NSURLRequest URL http://127.0.0.1/nope, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+http://127.0.0.1/nope - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1/nope">
+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
+https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
+https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://127.0.0.1/promote to https://127.0.0.1/promote
+https://127.0.0.1/promote - willSendRequest <NSURLRequest URL https://127.0.0.1/promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+https://127.0.0.1/promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/promote">
+http://127.0.0.1:443/try_to_promote - willSendRequest <NSURLRequest URL http://127.0.0.1:443/try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+http://127.0.0.1:443/try_to_promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1:443/try_to_promote">
+http://127.0.0.1:1443/try_to_promote - willSendRequest <NSURLRequest URL http://127.0.0.1:1443/try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+http://127.0.0.1:1443/try_to_promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "http://127.0.0.1:1443/try_to_promote">
+CONSOLE MESSAGE: line 30: Content blocker promoted URL from http://promote/ to https://promote/
+https://promote/ - willSendRequest <NSURLRequest URL https://promote/, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+Blocked access to external URL https://promote/
+https://promote/ - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999>
+protocol://try_to_promote - willSendRequest <NSURLRequest URL protocol://try_to_promote, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+protocol://try_to_promote - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1002, failing URL "protocol://try_to_promote">
+https://127.0.0.1/already_promoted - willSendRequest <NSURLRequest URL https://127.0.0.1/already_promoted, main document URL http://127.0.0.1:8000/contentextensions/make-https.html, http method GET> redirectResponse (null)
+https://127.0.0.1/already_promoted - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -1004, failing URL "https://127.0.0.1/already_promoted">
+URLs with http, port 80, and promote in the url should be promoted to https with port 443.
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsmakehttpshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/make-https.html (0 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/make-https.html         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/make-https.html        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+<head>
+<script>
+if(window.testRunner) {
+ testRunner.dumpResourceLoadCallbacks();
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+var testURLs = [
+ "http://127.0.0.1:8000/try_to_promote",
+ "http://127.0.0.1:80/nope",
+ "http://127.0.0.1:80/promote",
+ "http://127.0.0.1:/promote",
+ "http://127.0.0.1/promote",
+ "http://127.0.0.1:443/try_to_promote",
+ "http://127.0.0.1:1443/try_to_promote",
+ "http://promote",
+ "protocol://try_to_promote",
+ "https://127.0.0.1/already_promoted"
+];
+function bodyLoaded() {
+ var testImage = new Image();
+ var currentImageIndex = 0;
+ var runTest = function() {
+ if(currentImageIndex >= testURLs.length) {
+ if(window.testRunner) {
+ testRunner.notifyDone();
+ }
+ return;
+ }
+ testImage.src = testURLs[currentImageIndex++];
+ };
+ testImage.addEventListener("load", runTest);
+ testImage.addEventListener("error", runTest);
+ runTest();
+}
+</script>
+</head>
+<body onload="bodyLoaded();">
+URLs with http, port 80, and promote in the url should be promoted to https with port 443.
+</body>
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionsmakehttpshtmljson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/contentextensions/make-https.html.json (0 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/make-https.html.json         (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/make-https.html.json        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+[
+ {
+ "action": {
+ "type": "make-https"
+ },
+ "trigger": {
+ "url-filter": "promote"
+ }
+ }
+]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/ChangeLog        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-12-23 Chris Aljoudi <chris@chrismatic.io> and Alex Christensen <achristensen@webkit.org>
+
+ Content blockers should be able to promote http to https
+ https://bugs.webkit.org/show_bug.cgi?id=148966
+
+ Reviewed by Benjamin Poulain.
+
+ Test: http/tests/contentextensions/make-https.html
+
+ * contentextensions/ContentExtensionActions.h:
+ * contentextensions/ContentExtensionCompiler.cpp:
+ (WebCore::ContentExtensions::serializeActions):
+ * contentextensions/ContentExtensionParser.cpp:
+ (WebCore::ContentExtensions::loadAction):
+ * contentextensions/ContentExtensionRule.cpp:
+ (WebCore::ContentExtensions::Action::deserialize):
+ (WebCore::ContentExtensions::Action::deserializeType):
+ (WebCore::ContentExtensions::Action::serializedLength):
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad):
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource):
+ * platform/URL.cpp:
+ (WebCore::URL::isBlankURL):
+ (WebCore::defaultPortsMap):
+ (WebCore::defaultPortForProtocol):
+ (WebCore::isDefaultPortForProtocol):
+ (WebCore::portAllowed):
+ * platform/URL.h:
+
</ins><span class="cx"> 2015-12-22 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Try to fix the iOS build after r194378
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionActionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionActions.h (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionActions.h        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionActions.h        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> CSSDisplayNoneSelector,
</span><span class="cx"> CSSDisplayNoneStyleSheet,
</span><span class="cx"> IgnorePreviousRules,
</span><ins>+ MakeHTTPS,
</ins><span class="cx"> InvalidAction,
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -102,37 +102,26 @@
</span><span class="cx">
</span><span class="cx"> Vector<unsigned> actionLocations;
</span><span class="cx">
</span><del>- // Block and BlockCookies do not need to be distinguishable. The order in which they are executed it irrelevant
- // since Block is a strict superset of BlockCookies.
- // Similarily, Block is a superset of CSSDisplayNone, and BlockCookies is independent from CSSDisplayNone.
- //
- // The only distinguisher is "IgnorePreviousRules".
- //
- // The trigger's Flags do not need to be distinguishable either. The way we use them is filtering the actions
- // based on the flag *after* matching.
- //
- // To reduce the number of unique actions, we keep track of the various action, indexed by their flag.
- // We only need to create new ones when encountering a IgnorePreviousRules.
- HashMap<uint32_t, uint32_t, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> blockActionsMap;
- HashMap<uint32_t, uint32_t, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> blockCookiesActionsMap;
</del><ins>+ // Order only matters because of IgnorePreviousRules. All other identical actions can be combined between each IgnorePreviousRules
+ // and CSSDisplayNone strings can be combined if their triggers are identical.
+ typedef HashMap<uint32_t, uint32_t, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> ActionMap;
+ ActionMap blockLoadActionsMap;
+ ActionMap blockCookiesActionsMap;
</ins><span class="cx"> PendingDisplayNoneActionsMap cssDisplayNoneActionsMap;
</span><del>- HashMap<uint32_t, uint32_t, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> ignorePreviousRuleActionsMap;
</del><ins>+ ActionMap ignorePreviousRuleActionsMap;
+ ActionMap makeHTTPSActionsMap;
</ins><span class="cx">
</span><span class="cx"> for (unsigned ruleIndex = 0; ruleIndex < ruleList.size(); ++ruleIndex) {
</span><span class="cx"> const ContentExtensionRule& rule = ruleList[ruleIndex];
</span><span class="cx"> ActionType actionType = rule.action().type();
</span><span class="cx">
</span><del>- RELEASE_ASSERT(actionType == ActionType::CSSDisplayNoneSelector
- || actionType == ActionType::BlockLoad
- || actionType == ActionType::BlockCookies
- || actionType == ActionType::IgnorePreviousRules);
-
</del><span class="cx"> if (actionType == ActionType::IgnorePreviousRules) {
</span><span class="cx"> resolvePendingDisplayNoneActions(actions, actionLocations, cssDisplayNoneActionsMap);
</span><span class="cx">
</span><del>- blockActionsMap.clear();
</del><ins>+ blockLoadActionsMap.clear();
</ins><span class="cx"> blockCookiesActionsMap.clear();
</span><span class="cx"> cssDisplayNoneActionsMap.clear();
</span><ins>+ makeHTTPSActionsMap.clear();
</ins><span class="cx"> } else
</span><span class="cx"> ignorePreviousRuleActionsMap.clear();
</span><span class="cx">
</span><span class="lines">@@ -150,22 +139,23 @@
</span><span class="cx">
</span><span class="cx"> ResourceFlags flags = rule.trigger().flags;
</span><span class="cx"> unsigned actionLocation = std::numeric_limits<unsigned>::max();
</span><ins>+
+ auto findOrMakeActionLocation = [&] (ActionMap& map)
+ {
+ const auto existingAction = map.find(flags);
+ if (existingAction == map.end()) {
+ actionLocation = actions.size();
+ actions.append(static_cast<SerializedActionByte>(actionType));
+ map.set(flags, actionLocation);
+ } else
+ actionLocation = existingAction->value;
+ };
</ins><span class="cx">
</span><span class="cx"> switch (actionType) {
</span><span class="cx"> case ActionType::CSSDisplayNoneStyleSheet:
</span><span class="cx"> case ActionType::InvalidAction:
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">
</span><del>- case ActionType::IgnorePreviousRules: {
- const auto existingAction = ignorePreviousRuleActionsMap.find(flags);
- if (existingAction == ignorePreviousRuleActionsMap.end()) {
- actionLocation = actions.size();
- actions.append(static_cast<SerializedActionByte>(rule.action().type()));
- ignorePreviousRuleActionsMap.set(flags, actionLocation);
- } else
- actionLocation = existingAction->value;
- break;
- }
</del><span class="cx"> case ActionType::CSSDisplayNoneSelector: {
</span><span class="cx"> const auto addResult = cssDisplayNoneActionsMap.add(rule.trigger(), PendingDisplayNoneActions());
</span><span class="cx"> PendingDisplayNoneActions& pendingDisplayNoneActions = addResult.iterator->value;
</span><span class="lines">@@ -175,27 +165,19 @@
</span><span class="cx"> actionLocation = std::numeric_limits<unsigned>::max();
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- case ActionType::BlockLoad: {
- const auto existingAction = blockActionsMap.find(flags);
- if (existingAction == blockActionsMap.end()) {
- actionLocation = actions.size();
- actions.append(static_cast<SerializedActionByte>(rule.action().type()));
- blockActionsMap.set(flags, actionLocation);
- } else
- actionLocation = existingAction->value;
</del><ins>+ case ActionType::IgnorePreviousRules:
+ findOrMakeActionLocation(ignorePreviousRuleActionsMap);
</ins><span class="cx"> break;
</span><del>- }
- case ActionType::BlockCookies: {
- const auto existingAction = blockCookiesActionsMap.find(flags);
- if (existingAction == blockCookiesActionsMap.end()) {
- actionLocation = actions.size();
- actions.append(static_cast<SerializedActionByte>(rule.action().type()));
- blockCookiesActionsMap.set(flags, actionLocation);
- } else
- actionLocation = existingAction->value;
</del><ins>+ case ActionType::BlockLoad:
+ findOrMakeActionLocation(blockLoadActionsMap);
</ins><span class="cx"> break;
</span><ins>+ case ActionType::BlockCookies:
+ findOrMakeActionLocation(blockCookiesActionsMap);
+ break;
+ case ActionType::MakeHTTPS:
+ findOrMakeActionLocation(makeHTTPSActionsMap);
+ break;
</ins><span class="cx"> }
</span><del>- }
</del><span class="cx">
</span><span class="cx"> actionLocations.append(actionLocation);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -216,6 +216,8 @@
</span><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx"> action = Action(ActionType::CSSDisplayNoneSelector, s);
</span><ins>+ } else if (actionType == "make-https") {
+ action = ActionType::MakeHTTPS;
</ins><span class="cx"> } else
</span><span class="cx"> return ContentExtensionError::JSONInvalidActionType;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionRulecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -49,6 +49,8 @@
</span><span class="cx"> return Action(ActionType::BlockLoad, location);
</span><span class="cx"> case ActionType::IgnorePreviousRules:
</span><span class="cx"> return Action(ActionType::IgnorePreviousRules, location);
</span><ins>+ case ActionType::MakeHTTPS:
+ return Action(ActionType::MakeHTTPS, location);
</ins><span class="cx"> case ActionType::CSSDisplayNoneSelector: {
</span><span class="cx"> uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool);
</span><span class="cx"> uint32_t stringStartIndex = location + headerLength;
</span><span class="lines">@@ -79,6 +81,7 @@
</span><span class="cx"> case ActionType::BlockLoad:
</span><span class="cx"> case ActionType::IgnorePreviousRules:
</span><span class="cx"> case ActionType::CSSDisplayNoneSelector:
</span><ins>+ case ActionType::MakeHTTPS:
</ins><span class="cx"> return type;
</span><span class="cx"> case ActionType::CSSDisplayNoneStyleSheet:
</span><span class="cx"> case ActionType::InvalidAction:
</span><span class="lines">@@ -94,6 +97,7 @@
</span><span class="cx"> case ActionType::BlockCookies:
</span><span class="cx"> case ActionType::BlockLoad:
</span><span class="cx"> case ActionType::IgnorePreviousRules:
</span><ins>+ case ActionType::MakeHTTPS:
</ins><span class="cx"> return sizeof(ActionType);
</span><span class="cx"> case ActionType::CSSDisplayNoneSelector: {
</span><span class="cx"> uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool);
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "DocumentLoader.h"
</span><span class="cx"> #include "ExtensionStyleSheets.h"
</span><span class="cx"> #include "Frame.h"
</span><ins>+#include "FrameLoaderClient.h"
</ins><span class="cx"> #include "MainFrame.h"
</span><span class="cx"> #include "ResourceLoadInfo.h"
</span><span class="cx"> #include "URL.h"
</span><span class="lines">@@ -189,6 +190,25 @@
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+ case ContentExtensions::ActionType::MakeHTTPS: {
+ const URL originalURL = request.url();
+ if (originalURL.protocolIs("http") && (!originalURL.hasPort() || isDefaultPortForProtocol(originalURL.port(), originalURL.protocol()))) {
+ URL newURL = originalURL;
+ newURL.setProtocol("https");
+ if (originalURL.hasPort())
+ newURL.setPort(defaultPortForProtocol("https"));
+ request.setURL(newURL);
+
+ if (resourceType == ResourceType::Document && initiatingDocumentLoader.isLoadingMainResource()) {
+ // This is to make sure the correct 'new' URL shows in the location bar.
+ initiatingDocumentLoader.request().setURL(newURL);
+ initiatingDocumentLoader.frameLoader()->client().dispatchDidChangeProvisionalURL();
+ }
+ if (currentDocument)
+ currentDocument->addConsoleMessage(MessageSource::ContentBlocker, MessageLevel::Info, makeString("Content blocker promoted URL from ", originalURL.string(), " to ", newURL.string()));
+ }
+ break;
+ }
</ins><span class="cx"> case ContentExtensions::ActionType::IgnorePreviousRules:
</span><span class="cx"> case ContentExtensions::ActionType::InvalidAction:
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -549,6 +549,8 @@
</span><span class="cx"> }
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><ins>+ url = request.resourceRequest().url(); // The content extension could have changed it from http to https.
+ url = MemoryCache::removeFragmentIdentifierIfNeeded(url); // Might need to remove fragment identifier again.
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URL.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URL.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/platform/URL.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include <unicode/uidna.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/HexNumber.h>
</span><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="lines">@@ -1989,20 +1990,28 @@
</span><span class="cx"> return protocolIs("about");
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+typedef HashMap<String, unsigned short, CaseFoldingHash> DefaultPortsMap;
+static const DefaultPortsMap& defaultPortsMap()
+{
+ static NeverDestroyed<const DefaultPortsMap> defaultPortsMap(DefaultPortsMap({
+ { "http", 80 },
+ { "https", 443 },
+ { "ftp", 21 },
+ { "ftps", 990 }
+ }));
+ return defaultPortsMap.get();
+}
+unsigned short defaultPortForProtocol(const String& protocol)
+{
+ return defaultPortsMap().get(protocol);
+}
+
</ins><span class="cx"> bool isDefaultPortForProtocol(unsigned short port, const String& protocol)
</span><span class="cx"> {
</span><span class="cx"> if (protocol.isEmpty())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- typedef HashMap<String, unsigned, CaseFoldingHash> DefaultPortsMap;
- DEPRECATED_DEFINE_STATIC_LOCAL(DefaultPortsMap, defaultPorts, ());
- if (defaultPorts.isEmpty()) {
- defaultPorts.set("http", 80);
- defaultPorts.set("https", 443);
- defaultPorts.set("ftp", 21);
- defaultPorts.set("ftps", 990);
- }
- return defaultPorts.get(protocol) == port;
</del><ins>+ return defaultPortForProtocol(protocol) == port;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool portAllowed(const URL& url)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformURLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/URL.h (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/URL.h        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Source/WebCore/platform/URL.h        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -246,6 +246,7 @@
</span><span class="cx"> WEBCORE_EXPORT bool protocolIsJavaScript(const String& url);
</span><span class="cx"> WEBCORE_EXPORT bool protocolIsInHTTPFamily(const String& url);
</span><span class="cx">
</span><ins>+unsigned short defaultPortForProtocol(const String& protocol);
</ins><span class="cx"> bool isDefaultPortForProtocol(unsigned short port, const String& protocol);
</span><span class="cx"> bool portAllowed(const URL&); // Blacklist ports that should never be used for Web resources.
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Tools/ChangeLog        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-12-23 Chris Aljoudi <chris@chrismatic.io> and Alex Christensen <achristensen@webkit.org>
+
+ Content blockers should be able to promote http to https
+ https://bugs.webkit.org/show_bug.cgi?id=148966
+
+ Reviewed by Benjamin Poulain.
+
+ * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+ (WebCore::ContentExtensions::operator<<):
+ (TestWebKitAPI::TEST_F):
+
</ins><span class="cx"> 2015-12-22 Hunseop Jeong <hs85.jeong@samsung.com>
</span><span class="cx">
</span><span class="cx"> [EFL] MiniBrowser should be able to choose the offline-web-application-cache option
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (194385 => 194386)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp        2015-12-23 03:22:47 UTC (rev 194385)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp        2015-12-23 10:04:44 UTC (rev 194386)
</span><span class="lines">@@ -50,17 +50,19 @@
</span><span class="cx"> {
</span><span class="cx"> switch (action) {
</span><span class="cx"> case ActionType::BlockLoad:
</span><del>- return os << "ContentFilterAction::BlockLoad";
</del><ins>+ return os << "ActionType::BlockLoad";
</ins><span class="cx"> case ActionType::BlockCookies:
</span><del>- return os << "ContentFilterAction::BlockCookies";
</del><ins>+ return os << "ActionType::BlockCookies";
</ins><span class="cx"> case ActionType::CSSDisplayNoneSelector:
</span><del>- return os << "ContentFilterAction::CSSDisplayNone";
</del><ins>+ return os << "ActionType::CSSDisplayNone";
</ins><span class="cx"> case ActionType::CSSDisplayNoneStyleSheet:
</span><del>- return os << "ContentFilterAction::CSSDisplayNoneStyleSheet";
</del><ins>+ return os << "ActionType::CSSDisplayNoneStyleSheet";
</ins><span class="cx"> case ActionType::IgnorePreviousRules:
</span><del>- return os << "ContentFilterAction::IgnorePreviousRules";
</del><ins>+ return os << "ActionType::IgnorePreviousRules";
+ case ActionType::MakeHTTPS:
+ return os << "ActionType::MakeHTTPS";
</ins><span class="cx"> case ActionType::InvalidAction:
</span><del>- return os << "ContentFilterAction::InvalidAction";
</del><ins>+ return os << "ActionType::InvalidAction";
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -1438,18 +1440,18 @@
</span><span class="cx"> {
</span><span class="cx"> auto backend = makeBackend("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"A*D\"}},"
</span><span class="cx"> "{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"A*BA+\"}},"
</span><del>- "{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"A*BC\"}}]");
</del><ins>+ "{\"action\":{\"type\":\"make-https\"},\"trigger\":{\"url-filter\":\"A*BC\"}}]");
</ins><span class="cx">
</span><span class="cx"> testRequest(backend, mainDocumentRequest("http://webkit.org/D"), { ContentExtensions::ActionType::BlockLoad });
</span><span class="cx"> testRequest(backend, mainDocumentRequest("http://webkit.org/AAD"), { ContentExtensions::ActionType::BlockLoad });
</span><span class="cx"> testRequest(backend, mainDocumentRequest("http://webkit.org/AB"), { });
</span><span class="cx"> testRequest(backend, mainDocumentRequest("http://webkit.org/ABA"), { }, true);
</span><span class="cx"> testRequest(backend, mainDocumentRequest("http://webkit.org/ABAD"), { }, true);
</span><del>- testRequest(backend, mainDocumentRequest("http://webkit.org/BC"), { ContentExtensions::ActionType::BlockCookies });
- testRequest(backend, mainDocumentRequest("http://webkit.org/ABC"), { ContentExtensions::ActionType::BlockCookies });
- testRequest(backend, mainDocumentRequest("http://webkit.org/ABABC"), { ContentExtensions::ActionType::BlockCookies }, true);
- testRequest(backend, mainDocumentRequest("http://webkit.org/ABABCAD"), { ContentExtensions::ActionType::BlockCookies }, true);
- testRequest(backend, mainDocumentRequest("http://webkit.org/ABCAD"), { ContentExtensions::ActionType::BlockCookies, ContentExtensions::ActionType::BlockLoad });
</del><ins>+ testRequest(backend, mainDocumentRequest("http://webkit.org/BC"), { ContentExtensions::ActionType::MakeHTTPS });
+ testRequest(backend, mainDocumentRequest("http://webkit.org/ABC"), { ContentExtensions::ActionType::MakeHTTPS });
+ testRequest(backend, mainDocumentRequest("http://webkit.org/ABABC"), { ContentExtensions::ActionType::MakeHTTPS }, true);
+ testRequest(backend, mainDocumentRequest("http://webkit.org/ABABCAD"), { ContentExtensions::ActionType::MakeHTTPS }, true);
+ testRequest(backend, mainDocumentRequest("http://webkit.org/ABCAD"), { ContentExtensions::ActionType::MakeHTTPS, ContentExtensions::ActionType::BlockLoad });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST_F(ContentExtensionTest, StrictPrefixSeparatedMachines3Partitioning)
</span></span></pre>
</div>
</div>
</body>
</html>