After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 328896 - Wrong path calculation in xmlGetNodePath
Wrong path calculation in xmlGetNodePath
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other All
: Normal normal
: ---
Assigned To: kbuchcik
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-01-27 21:04 UTC by Liron
Modified: 2006-05-05 08:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Liron 2006-01-27 21:04:10 UTC
Please describe the problem:
When using xmlGetNodePath in tree.c the XPath is not calculated right for text 
and cdata nodes. Starting with line 4333 of the offical 2.6.23 release:
        } else if ((cur->type == XML_TEXT_NODE) ||
                   (cur->type == XML_CDATA_SECTION_NODE)) {
            sep = "/";
	    name = "text()";
            next = cur->parent;

            /*
             * Thumbler index computation
             */
            tmp = cur->prev;
            while (tmp != NULL) {
                if ((cur->type == XML_TEXT_NODE) ||
		    (cur->type == XML_CDATA_SECTION_NODE))
		    occur++;
                tmp = tmp->prev;
            }

the result is that every text node gets its absolute child position as an index 
instead of an index relative to other text siblings.

Fix:
The condition should be checked against tmp->type instead of cur->type (which 
is obviously either text or cdata and doesn't really change through the loop)

I found a reference to that problem in the archives but couldn't locate a bug 
report
http://mail.gnome.org/archives/xml/2005-March/msg00146.html

Thank you
Liron

Steps to reproduce:
1. Call xmlGetNodePath on any text node which is not the first child to see 
that it's returned index is its absolute index and not by type


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 kbuchcik 2006-02-15 10:59:25 UTC
Looks like a copy&paste bug.
Fixed in CVS: tree.c, revision 1.364.

Thanks for the report!