diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2000-09-05 10:42:32 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2000-09-05 10:42:32 +0000 |
commit | 90e1131a60b5db4ae851e8d1c9b339adfcf0c537 (patch) | |
tree | a10dc5af72ee89acc8b53ab921c47f41a031dcb7 /uri.c | |
parent | 98a7916ba1495b3d8e07cc782b1a677c96788696 (diff) | |
download | android_external_libxml2-90e1131a60b5db4ae851e8d1c9b339adfcf0c537.tar.gz android_external_libxml2-90e1131a60b5db4ae851e8d1c9b339adfcf0c537.tar.bz2 android_external_libxml2-90e1131a60b5db4ae851e8d1c9b339adfcf0c537.zip |
- uri.c: applied Wayne Davidson patch
- Makefile.in test/URI/uri.data result/URI/uri.data: updated URI tests
Daniel
Diffstat (limited to 'uri.c')
-rw-r--r-- | uri.c | 84 |
1 files changed, 36 insertions, 48 deletions
@@ -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: /* |