mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-26 10:03:34 +03:00
URI work cleanup and regresssion tests,
- uri.c testUri.c: applied Wayne Davidson patches - test/URI/uri.data result/URI/uri.data: first set of tests/results - Makefile.in: added URItest and included thenin "make tests" Daniel
This commit is contained in:
parent
960aa53d2f
commit
98a7916ba1
@ -1,4 +1,10 @@
|
||||
Sun Sep 3 19:19:29 CEST 2000
|
||||
Mon Sep 4 13:01:45 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* uri.c testUri.c: applied Wayne Davidson patches
|
||||
* test/URI/uri.data result/URI/uri.data: first set of tests/results
|
||||
* Makefile.in: added URItest and included thenin "make tests"
|
||||
|
||||
Sun Sep 3 19:19:29 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* xmlversion.h.in: closed bug 22941
|
||||
|
||||
|
21
Makefile.am
21
Makefile.am
@ -98,7 +98,7 @@ $(libxml_la_SOURCES): $(srcdir)/libxml
|
||||
|
||||
testall : tests SVGtests SAXtests XPathtests
|
||||
|
||||
tests: XMLtests XMLenttests HTMLtests Validtests
|
||||
tests: XMLtests XMLenttests HTMLtests Validtests URItests
|
||||
|
||||
HTMLtests : testHTML
|
||||
@(rm -f .memdump ; touch .memdump)
|
||||
@ -214,6 +214,25 @@ XMLenttests : xmllint
|
||||
rm result.$$name result2.$$name ; \
|
||||
fi ; fi ; done)
|
||||
|
||||
URItests : testURI
|
||||
@(rm -f .memdump ; touch .memdump)
|
||||
@echo "##"
|
||||
@echo "## URI module regression tests"
|
||||
@echo "##"
|
||||
@(for i in $(srcdir)/test/URI/*.data ; do \
|
||||
name=`basename $$i`; \
|
||||
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 ; \
|
||||
else \
|
||||
echo Testing $$name ; \
|
||||
$(top_builddir)/testURI -base 'http://foo.com/path/to/index.html#help' < $$i > result.$$name ; \
|
||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||
diff $(srcdir)/result/URI/$$name result.$$name ; \
|
||||
rm result.$$name ; \
|
||||
fi ; fi ; done)
|
||||
|
||||
XPathtests : testXPath
|
||||
@echo "##"
|
||||
@echo "## XPath regression tests"
|
||||
|
13
result/URI/uri.data
Normal file
13
result/URI/uri.data
Normal file
@ -0,0 +1,13 @@
|
||||
http://foo.com/path/to/index.html#help
|
||||
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/index.html?baz
|
||||
http://foo.com/path/up.a.notch.html#wow
|
||||
http://foo.com/path/up.a.notch.html?wow
|
||||
http://foo.com/root.cgi#OK
|
||||
http://foo.com/root.cgi?OK
|
||||
https://elsewhere.com/#deep
|
||||
https://elsewhere.com/?deep
|
13
test/URI/uri.data
Normal file
13
test/URI/uri.data
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
.
|
||||
bar
|
||||
bar#baz
|
||||
bar?baz
|
||||
#baz
|
||||
?baz
|
||||
../up.a.notch.html#wow
|
||||
../up.a.notch.html?wow
|
||||
/root.cgi#OK
|
||||
/root.cgi?OK
|
||||
https://elsewhere.com/#deep
|
||||
https://elsewhere.com/?deep
|
25
testURI.c
25
testURI.c
@ -58,17 +58,24 @@ int main(int argc, char **argv) {
|
||||
i--;
|
||||
str[i] = 0;
|
||||
}
|
||||
if (i <= 0)
|
||||
continue;
|
||||
|
||||
ret = xmlParseURIReference(uri, str);
|
||||
if (ret != 0)
|
||||
printf("%s : error %d\n", str, ret);
|
||||
else {
|
||||
xmlPrintURI(stdout, uri);
|
||||
printf("\n");
|
||||
if (base == NULL) {
|
||||
ret = xmlParseURIReference(uri, str);
|
||||
if (ret != 0)
|
||||
printf("%s : error %d\n", str, ret);
|
||||
else {
|
||||
xmlPrintURI(stdout, uri);
|
||||
printf("\n");
|
||||
}
|
||||
} else {
|
||||
composite = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
|
||||
if (composite != NULL) {
|
||||
printf("%s\n", composite);
|
||||
xmlFree(composite);
|
||||
}
|
||||
else
|
||||
printf("::ERROR::\n");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
while (argv[arg] != NULL) {
|
||||
|
54
uri.c
54
uri.c
@ -1216,7 +1216,7 @@ xmlParseRelativeURI(xmlURIPtr uri, const char **str) {
|
||||
} else if (cur[0] == '/') {
|
||||
cur++;
|
||||
ret = xmlParseURIPathSegments(uri, &cur, 1);
|
||||
} else {
|
||||
} else if (cur[0] != '#' && cur[0] != '?') {
|
||||
ret = xmlParseURIRelSegment(uri, &cur);
|
||||
if (ret != 0)
|
||||
return(ret);
|
||||
@ -1467,7 +1467,6 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
|
||||
xmlURIPtr bas = NULL;
|
||||
xmlURIPtr res = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* 1) The URI reference is parsed into the potential four components and
|
||||
* fragment identifier, as described in Section 4.3.
|
||||
@ -1475,9 +1474,11 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
|
||||
ref = xmlCreateURI();
|
||||
if (ref == NULL)
|
||||
goto done;
|
||||
ret = xmlParseURIReference(ref, (const char *) URI);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
if (*URI) {
|
||||
ret = xmlParseURIReference(ref, (const char *) URI);
|
||||
if (ret != 0)
|
||||
goto done;
|
||||
}
|
||||
bas = xmlCreateURI();
|
||||
if (bas == NULL)
|
||||
goto done;
|
||||
@ -1488,22 +1489,29 @@ 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 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.
|
||||
* current document. However, since we need to inherit these
|
||||
* values from the base, we keep on going.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
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);
|
||||
res->fragment = xmlMemStrdup(ref->fragment);
|
||||
val = xmlSaveUri(res);
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 3) If the scheme component is defined, indicating that the reference
|
||||
@ -1517,8 +1525,6 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
|
||||
}
|
||||
if (bas->scheme != NULL)
|
||||
res->scheme = xmlMemStrdup(bas->scheme);
|
||||
else
|
||||
res->scheme = NULL;
|
||||
|
||||
/*
|
||||
* 4) If the authority component is defined, then the reference is a
|
||||
@ -1556,8 +1562,27 @@ 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) && (ref->path[0] == '/')) {
|
||||
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] == '/') {
|
||||
res->path = xmlMemStrdup(ref->path);
|
||||
if (ref->query != NULL)
|
||||
res->query = xmlMemStrdup(ref->query);
|
||||
@ -1634,6 +1659,11 @@ 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:
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user