Re: [xml] xmlGetNodePath() returns invalid path for XML_DTD_NODE

2021-03-13 Thread Nick Wellnhofer via xml

On 08/02/2021 18:01, Christoph M. Becker wrote:

On 08.02.2021 at 17:23, Nick Wellnhofer wrote:

This should be fixed for other node types as well. Does the attached
patch work for you?


Yes, that works fine.  Thank you!


This is fixed in master now:

https://gitlab.gnome.org/GNOME/libxml2/-/commit/e20c9c148c725e2933efa143ee6a543a5cae4204

Nick

___
xml mailing list, project page  http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlGetNodePath() returns invalid path for XML_DTD_NODE

2021-02-08 Thread Christoph M. Becker via xml
On 08.02.2021 at 17:23, Nick Wellnhofer wrote:

> On 28/01/2021 14:51, Christoph M. Becker via xml wrote:
>> -    if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
>> +    if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)
>> +    || (node->type == XML_DTD_NODE))
>>   return (NULL);
>
> This should be fixed for other node types as well. Does the attached
> patch work for you?

Yes, that works fine.  Thank you!

Christoph
___
xml mailing list, project page  http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml


Re: [xml] xmlGetNodePath() returns invalid path for XML_DTD_NODE

2021-02-08 Thread Nick Wellnhofer via xml

On 28/01/2021 14:51, Christoph M. Becker via xml wrote:

-if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)
+|| (node->type == XML_DTD_NODE))
  return (NULL);


This should be fixed for other node types as well. Does the attached patch 
work for you?


Nick

diff --git a/tree.c b/tree.c
index d2347dfdf..636f81fed 100644
--- a/tree.c
+++ b/tree.c
@@ -4881,7 +4881,9 @@ xmlGetNodePath(const xmlNode *node)
 }
 next = ((xmlAttrPtr) cur)->parent;
 } else {
-next = cur->parent;
+xmlFree(buf);
+xmlFree(buffer);
+return (NULL);
 }
 
 /*
___
xml mailing list, project page  http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml


[xml] xmlGetNodePath() returns invalid path for XML_DTD_NODE

2021-01-28 Thread Christoph M. Becker via xml
Hi all,

I'm forwarding this from , because I think
it is a libxml2 issue.

The problem is that calling xmlGetNodePath() on an XML_DTD_NODE returns
"/?", which is to my knowledge an invalid XPath expression.  Instead, if
I'm not mistaken, the function should return NULL instead.


 tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tree.c b/tree.c
index 08b1a50..fe1f701 100644
--- a/tree.c
+++ b/tree.c
@@ -4684,7 +4684,8 @@ xmlGetNodePath(const xmlNode *node)
 char nametemp[100];
 int occur = 0, generic;

-if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)
+|| (node->type == XML_DTD_NODE))
 return (NULL);

 buf_len = 500;


Regards,
Christoph

___
xml mailing list, project page  http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml