[xml] Bug in uri.c

Date view Thread view Subject view Author view

From: Marc Sanfacon (sanm@copernic.com)
Date: Tue Aug 22 2000 - 15:29:26 EDT


Hi there,
        I am using libxml2-2.2.2 under Windows, using VC 6.0 SP4.
        I found 2 problems in uri.c in the function 'xmlBuildURI' when given
these parameters:

        xmlBuildURI("http://news.gnome.org/gnome-news/", "/");

        What I think I should get is: http://news.gnome.org/, but instead, I
get garbage, because the string is not properly terminated in the code. I
fixed it doing the following change in uri.c.

in int xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash)
line 1021

        path = (char *) xmlMalloc(len + 1);
--> path[len] = '\0';

        the second problem is when giving an incomplete path:

        xmlBuildURI("http://news.gnome.org", "whatever.html");

        I get: http://news.gnome.orgwhatever.html, but I want:
http://news.gnome.org/whatever.html

        I don't know if it is the correct behavior, but what I did, is
ensure there is a '/' between the server and the path component of a URI.
So here are the changes:

in xmlBuildURI, line 1620

    /*
     * b) The reference's path component is appended to the buffer
     * string.
     */
    if (ref->path != NULL) {
        index = 0;
        /*
         * Ensure the path includes a '/'
         */
        if (res->path[0] != '/' && ref->path[index] != '/') {
            res->path[out++] = '/';
        }
        while (ref->path[index] != 0) {
            res->path[out++] = ref->path[index++];
        }
    }

Regards,
        Marc.

---------------------------------------------------------------------
 "Better the pride that resides, in a citizen of the world.
  Than the pride that divides, when a colorful rag is
  unfurled." Neil Peart
---------------------------------------------------------------------
Marc Sanfacon, Software developer Copernic.com
e-mail: sanm@copernic.com R&D Group
Tel : (418) 527-0528 ext 1212

----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Aug 22 2000 - 12:43:17 EDT