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

Side by Side Diff: Source/core/dom/custom/CustomElement.cpp

Issue 493713002: Invalid chars should not be allowed as first character in custom element name (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « LayoutTests/fast/dom/custom/invalid-first-char-combinators-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (isValidName(lower, EmbedderNames)) 64 if (isValidName(lower, EmbedderNames))
65 return; 65 return;
66 embedderCustomElementNames().append(lower); 66 embedderCustomElementNames().append(lower);
67 } 67 }
68 68
69 bool CustomElement::isValidName(const AtomicString& name, NameSet validNames) 69 bool CustomElement::isValidName(const AtomicString& name, NameSet validNames)
70 { 70 {
71 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames( ).find(name)) 71 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames( ).find(name))
72 return Document::isValidName(name); 72 return Document::isValidName(name);
73 73
74 if ((validNames & StandardNames) && kNotFound != name.find('-')) { 74 if ((validNames & StandardNames) && kNotFound != name.find('-') && kNotFound == name.find(':')) {
dglazkov 2014/10/16 17:41:26 This change is good.
75 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ()); 75 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ());
76 if (reservedNames.isEmpty()) { 76 if (reservedNames.isEmpty()) {
77 reservedNames.append(MathMLNames::annotation_xmlTag.localName()); 77 reservedNames.append(MathMLNames::annotation_xmlTag.localName());
78 #if ENABLE(SVG_FONTS) 78 #if ENABLE(SVG_FONTS)
79 reservedNames.append(SVGNames::font_faceTag.localName()); 79 reservedNames.append(SVGNames::font_faceTag.localName());
80 reservedNames.append(SVGNames::font_face_srcTag.localName()); 80 reservedNames.append(SVGNames::font_face_srcTag.localName());
81 reservedNames.append(SVGNames::font_face_uriTag.localName()); 81 reservedNames.append(SVGNames::font_face_uriTag.localName());
82 reservedNames.append(SVGNames::font_face_formatTag.localName()); 82 reservedNames.append(SVGNames::font_face_formatTag.localName());
83 reservedNames.append(SVGNames::font_face_nameTag.localName()); 83 reservedNames.append(SVGNames::font_face_nameTag.localName());
84 reservedNames.append(SVGNames::missing_glyphTag.localName()); 84 reservedNames.append(SVGNames::missing_glyphTag.localName());
85 #endif 85 #endif
86 } 86 }
87 87
88 if (kNotFound == reservedNames.find(name)) 88 if (kNotFound == reservedNames.find(name)) {
89 if (!name.string().is8Bit()) {
90 const UChar32 c = name.characters16()[0];
91 if (c == 0x0B83 || c == 0x0F88 || c == 0x0F89 || c == 0x0F8A || c == 0x0F8B)
dglazkov 2014/10/07 15:13:13 This set of character comparisons seems out of pla
dglazkov 2014/10/16 17:41:26 What I meant to say here is that you should not be
92 return false;
93 }
94
89 return Document::isValidName(name.string()); 95 return Document::isValidName(name.string());
96 }
90 } 97 }
91 98
92 return false; 99 return false;
93 } 100 }
94 101
95 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition> passDefinition) 102 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition> passDefinition)
96 { 103 {
97 RefPtr<CustomElementDefinition> definition(passDefinition); 104 RefPtr<CustomElementDefinition> definition(passDefinition);
98 105
99 switch (element->customElementState()) { 106 switch (element->customElementState()) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 break; 146 break;
140 147
141 case Element::WaitingForUpgrade: 148 case Element::WaitingForUpgrade:
142 case Element::Upgraded: 149 case Element::Upgraded:
143 CustomElementObserver::notifyElementWasDestroyed(element); 150 CustomElementObserver::notifyElementWasDestroyed(element);
144 break; 151 break;
145 } 152 }
146 } 153 }
147 154
148 } // namespace blink 155 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/custom/invalid-first-char-combinators-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698