- uri.c: applied Wayne Davidson patch

- Makefile.in test/URI/uri.data result/URI/uri.data: updated URI tests
Daniel
This commit is contained in:
Daniel Veillard 2000-09-05 10:42:32 +00:00
parent 98a7916ba1
commit 90e1131a60
5 changed files with 59 additions and 56 deletions

View File

@ -1,3 +1,8 @@
Tue Sep 5 12:41:15 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* uri.c: applied Wayne Davidson patch
* Makefile.in test/URI/uri.data result/URI/uri.data: updated URI tests
Mon Sep 4 13:01:45 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* uri.c testUri.c: applied Wayne Davidson patches

View File

@ -224,10 +224,10 @@ URItests : testURI
if [ ! -d $$i ] ; then \
if [ ! -f $(srcdir)/result/URI/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/testURI -base 'http://foo.com/path/to/index.html#help' < $$i > $(srcdir)/result/URI/$$name ; \
$(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i > $(srcdir)/result/URI/$$name ; \
else \
echo Testing $$name ; \
$(top_builddir)/testURI -base 'http://foo.com/path/to/index.html#help' < $$i > result.$$name ; \
$(top_builddir)/testURI -base 'http://foo.com/path/to/index.html?orig#help' < $$i > result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/URI/$$name result.$$name ; \
rm result.$$name ; \

View File

@ -1,13 +1,18 @@
http://foo.com/path/to/index.html#help
http://foo.com/path/to/index.html?orig
http://foo.com/path/to/
http://foo.com/path/to/bar
http://foo.com/path/to/bar#baz
http://foo.com/path/to/bar?baz
http://foo.com/path/to/index.html#baz
http://foo.com/path/to/bar?baz#baz2
http://foo.com/path/to/index.html?orig#baz
http://foo.com/path/to/index.html?baz
http://foo.com/path/to/index.html?baz#baz2
http://foo.com/path/up.a.notch.html#wow
http://foo.com/path/up.a.notch.html?wow
http://foo.com/path/up.a.notch.html?wow#wow2
http://foo.com/root.cgi#OK
http://foo.com/root.cgi?OK
https://elsewhere.com/#deep
https://elsewhere.com/?deep
http://foo.com/root.cgi?OK#OK2
http://elsewhere.com/#deep
http://elsewhere.com/?deep
http://elsewhere.com/?deep#deep2

View File

@ -3,11 +3,16 @@
bar
bar#baz
bar?baz
bar?baz#baz2
#baz
?baz
?baz#baz2
../up.a.notch.html#wow
../up.a.notch.html?wow
../up.a.notch.html?wow#wow2
/root.cgi#OK
/root.cgi?OK
https://elsewhere.com/#deep
https://elsewhere.com/?deep
/root.cgi?OK#OK2
http://elsewhere.com/#deep
http://elsewhere.com/?deep
http://elsewhere.com/?deep#deep2

84
uri.c
View File

@ -1470,6 +1470,10 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
/*
* 1) The URI reference is parsed into the potential four components and
* fragment identifier, as described in Section 4.3.
*
* NOTE that a completely empty URI is treated by modern browsers
* as a reference to "." rather than as a synonym for the current
* URI. Should we do that here?
*/
ref = xmlCreateURI();
if (ref == NULL)
@ -1489,29 +1493,45 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
/*
* 2) If the path component is empty and the scheme, authority, and
* query components are undefined, then it is a reference to the
* current document. However, since we need to inherit these
* values from the base, we keep on going.
* current document and we are done. Otherwise, the reference URI's
* query and fragment components are defined as found (or not found)
* within the URI reference and not inherited from the base URI.
*
* NOTE: this is a divergence from the RFC which says:
* current document and we are done. Otherwise, the reference URI's
* query and fragment components are defined as found (or not found)
* within the URI reference and not inherited from the base URI.
* NOTE that in modern browsers, the parsing differs from the above
* in the following aspect: the query component is allowed to be
* defined while still treating this as a reference to the current
* document.
*/
res = xmlCreateURI();
if (res == NULL)
goto done;
#if 0
if ((ref->scheme == NULL) && (ref->path == NULL) &&
((ref->authority == NULL) && (ref->server == NULL)) &&
(ref->query == NULL)) {
if (ref->fragment == NULL)
goto done;
res->fragment = xmlMemStrdup(ref->fragment);
val = xmlSaveUri(res);
goto done;
((ref->authority == NULL) && (ref->server == NULL))) {
if (bas->scheme != NULL)
res->scheme = xmlMemStrdup(bas->scheme);
if (bas->authority != NULL)
res->authority = xmlMemStrdup(bas->authority);
else if (bas->server != NULL) {
res->server = xmlMemStrdup(bas->server);
if (bas->user != NULL)
res->user = xmlMemStrdup(bas->user);
res->port = bas->port;
}
if (bas->path != NULL)
res->path = xmlMemStrdup(bas->path);
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
else if (bas->query != NULL)
res->query = xmlMemStrdup(bas->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
goto step_7;
}
#endif
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
/*
* 3) If the scheme component is defined, indicating that the reference
@ -1544,10 +1564,6 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
}
if (ref->path != NULL)
res->path = xmlMemStrdup(ref->path);
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
goto step_7;
}
if (bas->authority != NULL)
@ -1562,32 +1578,9 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
/*
* 5) If the path component begins with a slash character ("/"), then
* the reference is an absolute-path and we skip to step 7.
*
* If it is not defined, inherit the whole path from the base.
* The query and the fragment are inherited too, unless specified
* in the reference.
*/
if (ref->path == NULL) {
res->path = xmlMemStrdup(bas->path);
if (ref->query == NULL && ref->fragment == NULL) {
if (bas->query != NULL)
res->query = xmlMemStrdup(bas->query);
if (bas->fragment != NULL)
res->fragment = xmlMemStrdup(bas->fragment);
} else {
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
}
goto step_7;
}
if (ref->path[0] == '/') {
if ((ref->path != NULL) && (ref->path[0] == '/')) {
res->path = xmlMemStrdup(ref->path);
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
goto step_7;
}
@ -1659,11 +1652,6 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
*/
xmlNormalizeURIPath(res->path);
if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
step_7:
/*