mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-19 14:50:07 +03:00
Fix building relative URIs
Examples: testURI --relative --base file:///a file:///b New correct result: b Old incorrect result: ../b testURI --relative --base file:///a file:/// New correct result: ./ Old incorrect result: ../ testURI --relative --base file:///a/b file:///a/ New correct result: ./ Old incorrect result: ../../a/
This commit is contained in:
parent
25f13e77e6
commit
b1f87c0e43
22
uri.c
22
uri.c
@ -2280,20 +2280,11 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
|
||||
* beginning of the "unique" suffix of URI
|
||||
*/
|
||||
ix = pos;
|
||||
if ((rptr[ix] == '/') && (ix > 0))
|
||||
ix--;
|
||||
else if ((rptr[ix] == 0) && (ix > 1) && (rptr[ix - 1] == '/'))
|
||||
ix -= 2;
|
||||
for (; ix > 0; ix--) {
|
||||
if (rptr[ix] == '/')
|
||||
if (rptr[ix - 1] == '/')
|
||||
break;
|
||||
}
|
||||
if (ix == 0) {
|
||||
uptr = (xmlChar *)rptr;
|
||||
} else {
|
||||
ix++;
|
||||
uptr = (xmlChar *)&rptr[ix];
|
||||
}
|
||||
uptr = (xmlChar *)&rptr[ix];
|
||||
|
||||
/*
|
||||
* In base, count the number of '/' from the differing point
|
||||
@ -2304,6 +2295,15 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
|
||||
nbslash++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* e.g: URI="foo/" base="foo/bar" -> "./"
|
||||
*/
|
||||
if (nbslash == 0 && !uptr[0]) {
|
||||
val = xmlStrdup(BAD_CAST "./");
|
||||
goto done;
|
||||
}
|
||||
|
||||
len = xmlStrlen (uptr) + 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user