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

Unified 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: Addrressing comments Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/custom/CustomElement.cpp
diff --git a/Source/core/dom/custom/CustomElement.cpp b/Source/core/dom/custom/CustomElement.cpp
index 4253c5fea893093d0354146864b2c070599e7442..e526bff26b43e5c958a0bc9a40ef3fcbf1927bf0 100644
--- a/Source/core/dom/custom/CustomElement.cpp
+++ b/Source/core/dom/custom/CustomElement.cpp
@@ -66,6 +66,24 @@ void CustomElement::addEmbedderCustomElementName(const AtomicString& name)
embedderCustomElementNames().append(lower);
}
+static inline bool isValidNCName(const AtomicString& name)
+{
+ if (kNotFound != name.find(':'))
+ return false;
+
+ if (!name.string().is8Bit()) {
+ const UChar32 c = name.characters16()[0];
+ // These characters comes under CombiningChar in NCName and according to
+ // NCName only BaseChar and Ideodgraphic can come as first chars.
+ // Also these characters come under Letter_Other in UnicodeData, thats
+ // why they pass as valid document name.
+ if (c == 0x0B83 || c == 0x0F88 || c == 0x0F89 || c == 0x0F8A || c == 0x0F8B)
+ return false;
+ }
+
+ return Document::isValidName(name.string());
+}
+
bool CustomElement::isValidName(const AtomicString& name, NameSet validNames)
{
if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames().find(name))
@@ -79,7 +97,7 @@ bool CustomElement::isValidName(const AtomicString& name, NameSet validNames)
}
if (kNotFound == reservedNames.find(name))
- return Document::isValidName(name.string());
+ return isValidNCName(name);
}
return false;

Powered by Google App Engine
This is Rietveld 408576698