Title: [214358] trunk
- Revision
- 214358
- Author
- [email protected]
- Date
- 2017-03-24 11:17:48 -0700 (Fri, 24 Mar 2017)
Log Message
REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
https://bugs.webkit.org/show_bug.cgi?id=169167
Reviewed by Simon Fraser.
Source/WebCore:
When testing content extensions, we have always called an API function that internally
has called AtomicString::init somewhere before we start compiling the content extension.
On iOS, though, we call [_WKUserContentExtensionStore compileContentExtensionForIdentifier:...]
without having already called anything that calls AtomicString::init. The new CSS parser is now
failing to parse some selectors because CSSSelectorParser::defaultNamespace is returning starAtom,
which is a null atomic string before AtomicString::init is called.
Covered by a new API test.
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::isValidCSSSelector):
(WebCore::ContentExtensions::loadAction):
(WebCore::ContentExtensions::isValidSelector): Deleted.
* contentextensions/ContentExtensionParser.h:
Call AtomicString::init before checking if a css selector is valid.
Tools:
* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F):
Test an example of a selector that was incorrectly determined to be invalid.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (214357 => 214358)
--- trunk/Source/WebCore/ChangeLog 2017-03-24 18:01:18 UTC (rev 214357)
+++ trunk/Source/WebCore/ChangeLog 2017-03-24 18:17:48 UTC (rev 214358)
@@ -1,3 +1,26 @@
+2017-03-24 Alex Christensen <[email protected]>
+
+ REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
+ https://bugs.webkit.org/show_bug.cgi?id=169167
+
+ Reviewed by Simon Fraser.
+
+ When testing content extensions, we have always called an API function that internally
+ has called AtomicString::init somewhere before we start compiling the content extension.
+ On iOS, though, we call [_WKUserContentExtensionStore compileContentExtensionForIdentifier:...]
+ without having already called anything that calls AtomicString::init. The new CSS parser is now
+ failing to parse some selectors because CSSSelectorParser::defaultNamespace is returning starAtom,
+ which is a null atomic string before AtomicString::init is called.
+
+ Covered by a new API test.
+
+ * contentextensions/ContentExtensionParser.cpp:
+ (WebCore::ContentExtensions::isValidCSSSelector):
+ (WebCore::ContentExtensions::loadAction):
+ (WebCore::ContentExtensions::isValidSelector): Deleted.
+ * contentextensions/ContentExtensionParser.h:
+ Call AtomicString::init before checking if a css selector is valid.
+
2017-03-24 Youenn Fablet <[email protected]>
Add libwebrtc backend support for RTCRtpSender::replaceTrack
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp (214357 => 214358)
--- trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp 2017-03-24 18:01:18 UTC (rev 214357)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp 2017-03-24 18:17:48 UTC (rev 214358)
@@ -231,8 +231,9 @@
return WTFMove(trigger);
}
-static bool isValidSelector(const String& selector)
+bool isValidCSSSelector(const String& selector)
{
+ AtomicString::init();
CSSParserContext context(HTMLQuirksMode);
CSSParser parser(context);
CSSSelectorList selectorList;
@@ -267,7 +268,7 @@
return makeUnexpected(ContentExtensionError::JSONInvalidCSSDisplayNoneActionType);
String selectorString = asString(selector)->value(&exec);
- if (!isValidSelector(selectorString)) {
+ if (!isValidCSSSelector(selectorString)) {
// Skip rules with invalid selectors to be backwards-compatible.
return {std::nullopt};
}
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionParser.h (214357 => 214358)
--- trunk/Source/WebCore/contentextensions/ContentExtensionParser.h 2017-03-24 18:01:18 UTC (rev 214357)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionParser.h 2017-03-24 18:17:48 UTC (rev 214358)
@@ -39,6 +39,7 @@
class ContentExtensionRule;
Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(String&&);
+WEBCORE_EXPORT bool isValidCSSSelector(const String&);
} // namespace ContentExtensions
} // namespace WebCore
Modified: trunk/Tools/ChangeLog (214357 => 214358)
--- trunk/Tools/ChangeLog 2017-03-24 18:01:18 UTC (rev 214357)
+++ trunk/Tools/ChangeLog 2017-03-24 18:17:48 UTC (rev 214358)
@@ -1,3 +1,14 @@
+2017-03-24 Alex Christensen <[email protected]>
+
+ REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
+ https://bugs.webkit.org/show_bug.cgi?id=169167
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+ (TestWebKitAPI::TEST_F):
+ Test an example of a selector that was incorrectly determined to be invalid.
+
2017-03-24 Jonathan Bedard <[email protected]>
Increase timeout for booting simulators.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (214357 => 214358)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp 2017-03-24 18:01:18 UTC (rev 214357)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp 2017-03-24 18:17:48 UTC (rev 214358)
@@ -30,6 +30,7 @@
#include <WebCore/CombinedURLFilters.h>
#include <WebCore/ContentExtensionCompiler.h>
#include <WebCore/ContentExtensionError.h>
+#include <WebCore/ContentExtensionParser.h>
#include <WebCore/ContentExtensionsBackend.h>
#include <WebCore/DFA.h>
#include <WebCore/DFABytecodeCompiler.h>
@@ -2870,4 +2871,9 @@
testRequest(searchBackend, mainDocumentRequest("zzz://www.ddjjyyy.xxx/"), { ContentExtensions::ActionType::CSSDisplayNoneSelector });
}
+TEST_F(ContentExtensionTest, ValidSelector)
+{
+ EXPECT_TRUE(WebCore::ContentExtensions::isValidCSSSelector("a[href*=hsv]"));
+}
+
} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes