Title: [193449] branches/safari-601.1.46-branch/Source/WebCore
Revision
193449
Author
timo...@apple.com
Date
2015-12-04 12:53:15 -0800 (Fri, 04 Dec 2015)

Log Message

Merge r188222. rdar://problem/23581597

Modified Paths

Diff

Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (193448 => 193449)


--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-12-04 20:53:11 UTC (rev 193448)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-12-04 20:53:15 UTC (rev 193449)
@@ -1,5 +1,23 @@
 2015-12-04  Timothy Hatcher  <timo...@apple.com>
 
+        Merge r188222. rdar://problem/23581597
+
+    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-12-04  Timothy Hatcher  <timo...@apple.com>
+
         Merge r186891. rdar://problem/23581597
 
     2015-07-16  Joseph Pecoraro  <pecor...@apple.com>

Modified: branches/safari-601.1.46-branch/Source/WebCore/inspector/InspectorStyleSheet.cpp (193448 => 193449)


--- branches/safari-601.1.46-branch/Source/WebCore/inspector/InspectorStyleSheet.cpp	2015-12-04 20:53:11 UTC (rev 193448)
+++ branches/safari-601.1.46-branch/Source/WebCore/inspector/InspectorStyleSheet.cpp	2015-12-04 20:53:15 UTC (rev 193449)
@@ -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

Reply via email to