Title: [188222] trunk/Source/WebCore
- Revision
- 188222
- Author
- drou...@apple.com
- Date
- 2015-08-10 13:33:38 -0700 (Mon, 10 Aug 2015)
Log Message
Web Inspector: Invalid selectors can be applied to the stylesheet
https://bugs.webkit.org/show_bug.cgi?id=147230
Reviewed by Timothy Hatcher.
* inspector/InspectorStyleSheet.cpp:
(WebCore::isValidSelectorListString):
(WebCore::InspectorStyleSheet::setRuleSelector):
Now checks to see that the supplied selector is valid before trying to commit it to the rule.
(WebCore::InspectorStyleSheet::addRule):
(WebCore::checkStyleRuleSelector): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (188221 => 188222)
--- trunk/Source/WebCore/ChangeLog 2015-08-10 20:33:26 UTC (rev 188221)
+++ trunk/Source/WebCore/ChangeLog 2015-08-10 20:33:38 UTC (rev 188222)
@@ -1,3 +1,17 @@
+2015-08-10 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Invalid selectors can be applied to the stylesheet
+ https://bugs.webkit.org/show_bug.cgi?id=147230
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::isValidSelectorListString):
+ (WebCore::InspectorStyleSheet::setRuleSelector):
+ Now checks to see that the supplied selector is valid before trying to commit it to the rule.
+ (WebCore::InspectorStyleSheet::addRule):
+ (WebCore::checkStyleRuleSelector): Deleted.
+
2015-08-10 James Craig <jcr...@apple.com>
AX: Address follow-up comments in bug 145684
Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (188221 => 188222)
--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2015-08-10 20:33:26 UTC (rev 188221)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp 2015-08-10 20:33:38 UTC (rev 188222)
@@ -637,15 +637,30 @@
return rule->selectorText();
}
+static bool isValidSelectorListString(const String& selector, Document* document)
+{
+ CSSSelectorList selectorList;
+ createCSSParser(document)->parseSelector(selector, selectorList);
+ return selectorList.isValid();
+}
+
bool InspectorStyleSheet::setRuleSelector(const InspectorCSSId& id, const String& selector, ExceptionCode& ec)
{
if (!checkPageStyleSheet(ec))
return false;
+
+ // If the selector is invalid, do not proceed any further.
+ if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument())) {
+ ec = SYNTAX_ERR;
+ return false;
+ }
+
CSSStyleRule* rule = ruleForId(id);
if (!rule) {
ec = NOT_FOUND_ERR;
return false;
}
+
CSSStyleSheet* styleSheet = rule->parentStyleSheet();
if (!styleSheet || !ensureParsedDataReady()) {
ec = NOT_FOUND_ERR;
@@ -671,18 +686,11 @@
return true;
}
-static bool checkStyleRuleSelector(Document* document, const String& selector)
-{
- CSSSelectorList selectorList;
- createCSSParser(document)->parseSelector(selector, selectorList);
- return selectorList.isValid();
-}
-
CSSStyleRule* InspectorStyleSheet::addRule(const String& selector, ExceptionCode& ec)
{
if (!checkPageStyleSheet(ec))
return nullptr;
- if (!checkStyleRuleSelector(m_pageStyleSheet->ownerDocument(), selector)) {
+ if (!isValidSelectorListString(selector, m_pageStyleSheet->ownerDocument())) {
ec = SYNTAX_ERR;
return nullptr;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes