added code to ignore unknown namespace prefix for attributes

(actually the parser should've rejected it before here)
This commit is contained in:
peterl%netscape.com 1999-06-10 05:18:46 +00:00
Родитель fa94e3b67e
Коммит 784f0c9bee
19 изменённых файлов: 115 добавлений и 8 удалений

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsIContent.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsITextContent.h"
#include "nsINameSpaceManager.h"
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
@ -158,6 +159,9 @@ nsDOMAttribute::GetValue(nsString& aValue)
nsresult attrResult;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, mValue);
if (NS_CONTENT_ATTR_NOT_THERE == attrResult) {
mValue.Truncate();
@ -177,6 +181,9 @@ nsDOMAttribute::SetValue(const nsString& aValue)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->SetAttribute(nameSpaceID, nameAtom, aValue, PR_TRUE);
NS_IF_RELEASE(nameAtom);
}
@ -199,6 +206,9 @@ nsDOMAttribute::GetSpecified(PRBool* aSpecified)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, value);
NS_IF_RELEASE(nameAtom);
if (NS_CONTENT_ATTR_HAS_VALUE == attrResult) {
@ -369,6 +379,9 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
mContent->GetAttribute(nameSpaceID, nameAtom, value);
newAttr = new nsDOMAttribute(nsnull, mName, value);
}

Просмотреть файл

@ -241,6 +241,9 @@ nsDOMAttributeMap::GetNamedItem(const nsString &aAttrName,
nsAutoString normalizedName;
mContent->ParseAttributeString(aAttrName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, normalizedName);
result = GetNamedItemCommon(normalizedName,
nameSpaceID,
@ -279,6 +282,9 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
// Get normalized attribute name
attribute->GetName(name);
mContent->ParseAttributeString(name, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, name);
name.ToCString(buf, sizeof(buf));
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &oldAttribute);
@ -361,6 +367,9 @@ nsDOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
nsAutoString name;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, name);
name.ToCString(buf, sizeof(buf));
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &attribute);

Просмотреть файл

@ -47,11 +47,11 @@
#include "nsIDOMDOMImplementation.h"
#include "nsGenericElement.h"
#include "nsCSSPropIDs.h"
#include "nsCSSProps.h"
//#include "nsCSSPropIDs.h"
//#include "nsCSSProps.h"
#include "nsICSSStyleSheet.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
//#include "nsICSSStyleRule.h"
//#include "nsICSSDeclaration.h"
#include "nsITextContent.h"
#include "nsXIFConverter.h"

Просмотреть файл

@ -394,6 +394,9 @@ nsGenericElement::GetAttribute(const nsString& aName, nsString& aReturn)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
mContent->GetAttribute(nameSpaceID, nameAtom, aReturn);
NS_RELEASE(nameAtom);
@ -409,6 +412,9 @@ nsGenericElement::SetAttribute(const nsString& aName,
nsresult result = NS_OK;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->SetAttribute(nameSpaceID, nameAtom, aValue, PR_TRUE);
NS_RELEASE(nameAtom);
@ -423,6 +429,9 @@ nsGenericElement::RemoveAttribute(const nsString& aName)
nsresult result = NS_OK;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->UnsetAttribute(nameSpaceID, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);

Просмотреть файл

@ -442,6 +442,9 @@ nsXULAttributes::GetNamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (NS_FAILED(rv = mContent->ParseAttributeString(aName, name, nameSpaceID)))
return rv;
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
// XXX doing this instead of calling mContent->GetAttribute() will
// make it a lot harder to lazily instantiate properties from the
// graph. The problem is, how else do we get the named item?

Просмотреть файл

@ -879,6 +879,9 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
NS_WARNING("unable to parse attribute name");
return rv;
}
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetAttribute(nameSpaceID, nameAtom, aReturn);
NS_RELEASE(nameAtom);

Просмотреть файл

@ -1643,6 +1643,9 @@ RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& a
}
// If we get here, it's a "vanilla" property: push its value into the graph.
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
@ -1746,6 +1749,9 @@ RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString
// It's a "vanilla" property: push its value into the graph.
nsCOMPtr<nsIRDFResource> property;
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
return rv;

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsIContent.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsITextContent.h"
#include "nsINameSpaceManager.h"
static NS_DEFINE_IID(kIDOMAttrIID, NS_IDOMATTR_IID);
static NS_DEFINE_IID(kIDOMAttributePrivateIID, NS_IDOMATTRIBUTEPRIVATE_IID);
@ -158,6 +159,9 @@ nsDOMAttribute::GetValue(nsString& aValue)
nsresult attrResult;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, mValue);
if (NS_CONTENT_ATTR_NOT_THERE == attrResult) {
mValue.Truncate();
@ -177,6 +181,9 @@ nsDOMAttribute::SetValue(const nsString& aValue)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->SetAttribute(nameSpaceID, nameAtom, aValue, PR_TRUE);
NS_IF_RELEASE(nameAtom);
}
@ -199,6 +206,9 @@ nsDOMAttribute::GetSpecified(PRBool* aSpecified)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
attrResult = mContent->GetAttribute(nameSpaceID, nameAtom, value);
NS_IF_RELEASE(nameAtom);
if (NS_CONTENT_ATTR_HAS_VALUE == attrResult) {
@ -369,6 +379,9 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(mName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
mContent->GetAttribute(nameSpaceID, nameAtom, value);
newAttr = new nsDOMAttribute(nsnull, mName, value);
}

Просмотреть файл

@ -241,6 +241,9 @@ nsDOMAttributeMap::GetNamedItem(const nsString &aAttrName,
nsAutoString normalizedName;
mContent->ParseAttributeString(aAttrName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, normalizedName);
result = GetNamedItemCommon(normalizedName,
nameSpaceID,
@ -279,6 +282,9 @@ nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
// Get normalized attribute name
attribute->GetName(name);
mContent->ParseAttributeString(name, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, name);
name.ToCString(buf, sizeof(buf));
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &oldAttribute);
@ -361,6 +367,9 @@ nsDOMAttributeMap::RemoveNamedItem(const nsString& aName, nsIDOMNode** aReturn)
nsAutoString name;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNormalizedName(nameSpaceID, nameAtom, name);
name.ToCString(buf, sizeof(buf));
result = GetNamedItemCommon(name, nameSpaceID, nameAtom, &attribute);

Просмотреть файл

@ -47,11 +47,11 @@
#include "nsIDOMDOMImplementation.h"
#include "nsGenericElement.h"
#include "nsCSSPropIDs.h"
#include "nsCSSProps.h"
//#include "nsCSSPropIDs.h"
//#include "nsCSSProps.h"
#include "nsICSSStyleSheet.h"
#include "nsICSSStyleRule.h"
#include "nsICSSDeclaration.h"
//#include "nsICSSStyleRule.h"
//#include "nsICSSDeclaration.h"
#include "nsITextContent.h"
#include "nsXIFConverter.h"

Просмотреть файл

@ -394,6 +394,9 @@ nsGenericElement::GetAttribute(const nsString& aName, nsString& aReturn)
PRInt32 nameSpaceID;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
mContent->GetAttribute(nameSpaceID, nameAtom, aReturn);
NS_RELEASE(nameAtom);
@ -409,6 +412,9 @@ nsGenericElement::SetAttribute(const nsString& aName,
nsresult result = NS_OK;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->SetAttribute(nameSpaceID, nameAtom, aValue, PR_TRUE);
NS_RELEASE(nameAtom);
@ -423,6 +429,9 @@ nsGenericElement::RemoveAttribute(const nsString& aName)
nsresult result = NS_OK;
mContent->ParseAttributeString(aName, nameAtom, nameSpaceID);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
result = mContent->UnsetAttribute(nameSpaceID, nameAtom, PR_TRUE);
NS_RELEASE(nameAtom);

Просмотреть файл

@ -1073,6 +1073,9 @@ RDFContentSinkImpl::AddProperties(const nsIParserNode& aNode,
nsRDFParserUtils::StripAndConvert(v);
nsAutoString k;
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetNameSpaceURI(nameSpaceID, k);
k.Append(attr->GetUnicode());

Просмотреть файл

@ -879,6 +879,9 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
NS_WARNING("unable to parse attribute name");
return rv;
}
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetAttribute(nameSpaceID, nameAtom, aReturn);
NS_RELEASE(nameAtom);

Просмотреть файл

@ -1643,6 +1643,9 @@ RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& a
}
// If we get here, it's a "vanilla" property: push its value into the graph.
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
@ -1746,6 +1749,9 @@ RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString
// It's a "vanilla" property: push its value into the graph.
nsCOMPtr<nsIRDFResource> property;
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
return rv;

Просмотреть файл

@ -1508,6 +1508,9 @@ RDFXULBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName
// the RDF graph to update. So, build an RDF resource from the
// property name...
nsCOMPtr<nsIRDFResource> property;
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
if (NS_FAILED(rv = GetResource(nameSpaceID, nameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
return rv;
@ -1580,6 +1583,9 @@ RDFXULBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aN
}
nsCOMPtr<nsIRDFResource> property;
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
if (NS_FAILED(rv = GetResource(nameSpaceID, nameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
return rv;

Просмотреть файл

@ -442,6 +442,9 @@ nsXULAttributes::GetNamedItem(const nsString& aName, nsIDOMNode** aReturn)
if (NS_FAILED(rv = mContent->ParseAttributeString(aName, name, nameSpaceID)))
return rv;
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
// XXX doing this instead of calling mContent->GetAttribute() will
// make it a lot harder to lazily instantiate properties from the
// graph. The problem is, how else do we get the named item?

Просмотреть файл

@ -879,6 +879,9 @@ RDFElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
NS_WARNING("unable to parse attribute name");
return rv;
}
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
GetAttribute(nameSpaceID, nameAtom, aReturn);
NS_RELEASE(nameAtom);

Просмотреть файл

@ -1643,6 +1643,9 @@ RDFGenericBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& a
}
// If we get here, it's a "vanilla" property: push its value into the graph.
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
@ -1746,6 +1749,9 @@ RDFGenericBuilderImpl::OnRemoveAttribute(nsIDOMElement* aElement, const nsString
// It's a "vanilla" property: push its value into the graph.
nsCOMPtr<nsIRDFResource> property;
if (kNameSpaceID_Unknown == attrNameSpaceID) {
attrNameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
if (NS_FAILED(rv = GetResource(attrNameSpaceID, attrNameAtom, getter_AddRefs(property)))) {
NS_ERROR("unable to construct resource");
return rv;

Просмотреть файл

@ -1188,6 +1188,9 @@ XULContentSinkImpl::AddAttributes(const nsIParserNode& aNode,
nsIAtom* prefix = CutNameSpacePrefix(attr);
if (prefix) {
SplitQualifiedName(key, nameSpaceID, attr);
if (kNameSpaceID_Unknown == nameSpaceID) {
nameSpaceID = kNameSpaceID_None; // ignore unknown prefix XXX is this correct?
}
NS_RELEASE(prefix);
}
else {