Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp

Issue 2607403002: Disallow setting invalid values for registered properties via CSSOM (Closed)
Patch Set: fix comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSParserImpl.h" 5 #include "core/css/parser/CSSParserImpl.h"
6 6
7 #include "core/css/CSSCustomIdentValue.h" 7 #include "core/css/CSSCustomIdentValue.h"
8 #include "core/css/CSSCustomPropertyDeclaration.h" 8 #include "core/css/CSSCustomPropertyDeclaration.h"
9 #include "core/css/CSSKeyframesRule.h" 9 #include "core/css/CSSKeyframesRule.h"
10 #include "core/css/CSSStyleSheet.h" 10 #include "core/css/CSSStyleSheet.h"
11 #include "core/css/PropertyRegistry.h"
11 #include "core/css/StyleRuleImport.h" 12 #include "core/css/StyleRuleImport.h"
12 #include "core/css/StyleRuleKeyframe.h" 13 #include "core/css/StyleRuleKeyframe.h"
13 #include "core/css/StyleRuleNamespace.h" 14 #include "core/css/StyleRuleNamespace.h"
14 #include "core/css/StyleSheetContents.h" 15 #include "core/css/StyleSheetContents.h"
15 #include "core/css/parser/CSSAtRuleID.h" 16 #include "core/css/parser/CSSAtRuleID.h"
16 #include "core/css/parser/CSSLazyParsingState.h" 17 #include "core/css/parser/CSSLazyParsingState.h"
17 #include "core/css/parser/CSSLazyPropertyParserImpl.h" 18 #include "core/css/parser/CSSLazyPropertyParserImpl.h"
18 #include "core/css/parser/CSSParserObserver.h" 19 #include "core/css/parser/CSSParserObserver.h"
19 #include "core/css/parser/CSSParserObserverWrapper.h" 20 #include "core/css/parser/CSSParserObserverWrapper.h"
20 #include "core/css/parser/CSSParserSelector.h" 21 #include "core/css/parser/CSSParserSelector.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (!parser.m_parsedProperties.isEmpty()) { 62 if (!parser.m_parsedProperties.isEmpty()) {
62 didParse = true; 63 didParse = true;
63 didChange = declaration->addParsedProperties(parser.m_parsedProperties); 64 didChange = declaration->addParsedProperties(parser.m_parsedProperties);
64 } 65 }
65 return MutableStylePropertySet::SetResult{didParse, didChange}; 66 return MutableStylePropertySet::SetResult{didParse, didChange};
66 } 67 }
67 68
68 MutableStylePropertySet::SetResult CSSParserImpl::parseVariableValue( 69 MutableStylePropertySet::SetResult CSSParserImpl::parseVariableValue(
69 MutableStylePropertySet* declaration, 70 MutableStylePropertySet* declaration,
70 const AtomicString& propertyName, 71 const AtomicString& propertyName,
72 const PropertyRegistry* registry,
71 const String& value, 73 const String& value,
72 bool important, 74 bool important,
73 const CSSParserContext& context, 75 const CSSParserContext& context,
74 bool isAnimationTainted) { 76 bool isAnimationTainted) {
75 CSSParserImpl parser(context); 77 CSSParserImpl parser(context);
76 CSSTokenizer tokenizer(value); 78 CSSTokenizer tokenizer(value);
77 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important, 79 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important,
78 isAnimationTainted); 80 isAnimationTainted);
79 bool didParse = false; 81 bool didParse = false;
80 bool didChange = false; 82 bool didChange = false;
81 if (!parser.m_parsedProperties.isEmpty()) { 83 if (!parser.m_parsedProperties.isEmpty()) {
84 if (registry) {
85 const PropertyRegistry::Registration* registration =
86 registry->registration(propertyName);
87 // TODO(timloh): This is a bit wasteful, we parse the registered property
88 // to validate but throw away the result.
89 if (registration &&
90 !registration->syntax().parse(tokenizer.tokenRange(),
91 isAnimationTainted)) {
92 return MutableStylePropertySet::SetResult{didParse, didChange};
93 }
94 }
82 didParse = true; 95 didParse = true;
83 didChange = declaration->addParsedProperties(parser.m_parsedProperties); 96 didChange = declaration->addParsedProperties(parser.m_parsedProperties);
84 } 97 }
85 return MutableStylePropertySet::SetResult{didParse, didChange}; 98 return MutableStylePropertySet::SetResult{didParse, didChange};
86 } 99 }
87 100
88 static inline void filterProperties( 101 static inline void filterProperties(
89 bool important, 102 bool important,
90 const HeapVector<CSSProperty, 256>& input, 103 const HeapVector<CSSProperty, 256>& input,
91 HeapVector<CSSProperty, 256>& output, 104 HeapVector<CSSProperty, 256>& output,
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 else 977 else
965 return nullptr; // Parser error, invalid value in keyframe selector 978 return nullptr; // Parser error, invalid value in keyframe selector
966 if (range.atEnd()) 979 if (range.atEnd())
967 return result; 980 return result;
968 if (range.consume().type() != CommaToken) 981 if (range.consume().type() != CommaToken)
969 return nullptr; // Parser error 982 return nullptr; // Parser error
970 } 983 }
971 } 984 }
972 985
973 } // namespace blink 986 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParserImpl.h ('k') | third_party/WebKit/Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698