From: Marc Sanfacon (sanm@copernic.com)
Date: Tue Aug 22 2000 - 16:55:17 EDT
Thank you...
But, I found another bug in uri.c when giving this kind of URI to
xmlParseURI
http://investor.cnet.com/?tag=st.ne.1002.dir.Investor
The bug is in function: xmlParseURIPathSegments. It calls
xmlURIUnescapeString which concatenate the content of the string in path,
but path doesn't have enough memory allocated to contain all the string.
I fixed it doing the following:
uri.c, line 1034
if (cur - *str > 0) {
xmlURIUnescapeString(*str, cur - *str, &path[len2]);
}
Regards, Marc.
-----Original Message-----
From: xml-request@rufus.w3.org [mailto:xml-request@rufus.w3.org]On
Behalf Of Daniel Veillard
Sent: August 22, 2000 16:40
To: xml@rpmfind.net
Subject: Re: [xml] Bug in uri.c
Hi Marc,
On Tue, Aug 22, 2000 at 03:29:26PM -0400, Marc Sanfacon wrote:
>
> 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';
Oops, sounds right, the memcpy function used there don't add the zero
> 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++];
> }
> }
Humm, trouble is that
xmlBuildURI("http://news.gnome.org", "");
should return
"http://news.gnome.org"
and not
"http://news.gnome.org/"
(okay it's a bit pedantic ...). Plus the test to be sure the last
fragment ends up with a / should be ref->path[out] != '/'
So I will rather use
if (res->path[0] != '/' && res->path[0] != 0 &&
ref->path[out] != '/') {
res->path[out++] = '/';
}
as the test condition for appending the '/'
Daniel
-- Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes | Today's Bookmarks : Tel : +33 476 615 257 | 655, avenue de l'Europe | Linux XML libxml WWW Fax : +33 476 615 207 | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind http://www.w3.org/People/all#veillard%40w3.org | RPM badminton Kaffe ---- Message from the list xml@xmlsoft.org Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@xmlsoft.org ---- Message from the list xml@xmlsoft.org Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@xmlsoft.org
This archive was generated by hypermail 2b29 : Tue Aug 22 2000 - 14:43:12 EDT