diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index 388154ac8d1..a23af3ad1fc 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -826,15 +826,22 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo)
&rv);
if (NS_SUCCEEDED(rv)) {
- nsAutoString tag;
- aNodeInfo->GetName(tag);
+ nsAutoString tmpName;
+ aNodeInfo->GetName(tmpName);
// Find tag in tag table
PRInt32 id;
+ rv = parserService->HTMLStringTagToId(tmpName, &id);
+ if (eHTMLTag_userdefined == nsHTMLTag(id)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
- rv = parserService->HTMLStringTagToId(tag, &id);
+ // Create atom for tag and then create content object
+ nsAutoString tag;
+ rv = parserService->HTMLIdToStringTag(id, tag);
nsCOMPtr atom(dont_AddRef(NS_NewAtom(tag.GetUnicode())));
nsCOMPtr newName;
aNodeInfo->NameChanged(atom, *getter_AddRefs(newName));
+
rv = MakeContentObject(nsHTMLTag(id), newName, nsnull, nsnull, aResult);
}
diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
index 388154ac8d1..a23af3ad1fc 100644
--- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
@@ -826,15 +826,22 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo)
&rv);
if (NS_SUCCEEDED(rv)) {
- nsAutoString tag;
- aNodeInfo->GetName(tag);
+ nsAutoString tmpName;
+ aNodeInfo->GetName(tmpName);
// Find tag in tag table
PRInt32 id;
+ rv = parserService->HTMLStringTagToId(tmpName, &id);
+ if (eHTMLTag_userdefined == nsHTMLTag(id)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
- rv = parserService->HTMLStringTagToId(tag, &id);
+ // Create atom for tag and then create content object
+ nsAutoString tag;
+ rv = parserService->HTMLIdToStringTag(id, tag);
nsCOMPtr atom(dont_AddRef(NS_NewAtom(tag.GetUnicode())));
nsCOMPtr newName;
aNodeInfo->NameChanged(atom, *getter_AddRefs(newName));
+
rv = MakeContentObject(nsHTMLTag(id), newName, nsnull, nsnull, aResult);
}