[xml] possible bug in xmlHasNsProp
- From: Martijn Faassen <faassen infrae com>
- To: xml gnome org
- Subject: [xml] possible bug in xmlHasNsProp
- Date: Sun, 12 Sep 2004 01:28:49 +0200
Hi there,
I think I just ran into a bug in xmlHasNsProp.
If it is invoked like this:
xmlNsHasProp(node, 'foo', NULL)
what I'd expect is the attribute 'foo' that is *not* in any namespace
(i.e. doesn't have a namespace prefix). This means that if that
attribute, foo not in a namespace, does not exist, I'd expect to get
NULL as a result, even if there is actually an attribute 'foo' in some
namespace. Unfortunately, xmlNsHasProp *does* actually return that
attribute 'foo' with the namespace. This means it is impossible to
actually look up a namespace-less attribute node safely using
xmlNsHasProp (and xmlHasProp is no help either).
The problem seems to be in the following check:
if (nameSpace == NULL)
return(xmlHasProp(node, name));
but a fallback on xmlHasProp is not right; it does a search irrespective
of namespaces.
xmlNsGetProp in contrast actually does the right thing here:
if (nameSpace == NULL)
return(xmlGetNoNsProp(node, name));
if falls back on xmlGetNoNsProp, which explicitly searches for
attributes with no namespace at all, instead of falling back on
xmlGetProp. A bugfix would involve introducing the equivalent
xmlHasNoNsProp and falling back on that instead.
Regards,
Martijn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]