applied patch from Aleksey Sanin fixing a problem in the canonicalization
* c14n.c: applied patch from Aleksey Sanin fixing a problem in the
canonicalization algorithm
* doc/xml.html doc/index.html: added the C14N references on the
index page.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 157f4e7..f9a79be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Mar 15 08:55:55 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * c14n.c: applied patch from Aleksey Sanin fixing a problem in the
+ canonicalization algorithm
+ * doc/xml.html doc/index.html: added the C14N references on the
+ index page.
+
2002-03-13 jacob berkman <jacob@ximian.com>
* python/Makefile.am: remove LDADD and CFLAGS as this is broken
diff --git a/c14n.c b/c14n.c
index 7aab539..27e25b8 100644
--- a/c14n.c
+++ b/c14n.c
@@ -266,8 +266,9 @@
xmlNsPtr ns;
xmlListPtr list;
xmlNodePtr visible_parent;
+ xmlNodePtr node;
xmlNsPtr prev;
-
+
if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
#ifdef DEBUG_C14N
xmlGenericError(xmlGenericErrorContext,
@@ -302,6 +303,7 @@
* defined in node parents). By this we need to now walk thru
* all namespace in current node and all invisible ancesstors
*/
+ node = cur;
while (cur != visible_parent) {
for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
/*
@@ -311,6 +313,11 @@
if ((xmlC14NIsXmlNs(ns)) || (xmlListSearch(list, ns) != NULL)) {
continue;
}
+ prev = xmlSearchNs(ctx->doc, node, ns->prefix);
+ if(prev != ns) {
+ /* we already processed a namespace with this name */
+ continue;
+ }
/*
* Lookup nearest namespace after visible parent having
diff --git a/doc/index.html b/doc/index.html
index 5547e7e..4f12024 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -116,6 +116,11 @@
<li>part of SGML Open Technical Resolution TR9401:1997</li>
<li>XML Catalogs Working Draft 06 August 2001: <a href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">http://www.oasis-open.org/committees/entity/spec-2001-08-06.html</a>
</li>
+<li>Canonical XML Version 1.0: <a href="http://www.w3.org/TR/xml-c14n">http://www.w3.org/TR/xml-c14n</a>
+ and the
+ <p>Exclusive XML Canonicalization CR draft <a href="http://www.w3.org/TR/xml-exc-c14n">http://www.w3.org/TR/xml-exc-c14n</a>
+</p>
+</li>
</ul>
<p>In most cases libxml tries to implement the specifications in a relatively
strict way. As of release 2.4.16, libxml2 passes all 1800+ tests from the <a href="http://www.oasis-open.org/committees/xml-conformance/">OASIS XML Tests
diff --git a/doc/xml.html b/doc/xml.html
index 7fd713d..7e04f03 100644
--- a/doc/xml.html
+++ b/doc/xml.html
@@ -50,6 +50,12 @@
<li>part of SGML Open Technical Resolution TR9401:1997</li>
<li>XML Catalogs Working Draft 06 August 2001: <a
href="http://www.oasis-open.org/committees/entity/spec-2001-08-06.html">http://www.oasis-open.org/committees/entity/spec-2001-08-06.html</a></li>
+ <li>Canonical XML Version 1.0: <a
+ href="http://www.w3.org/TR/xml-c14n">http://www.w3.org/TR/xml-c14n</a>
+ and the
+ <p>Exclusive XML Canonicalization CR draft <a
+ href="http://www.w3.org/TR/xml-exc-c14n">http://www.w3.org/TR/xml-exc-c14n</a></p>
+ </li>
</ul>
<p>In most cases libxml tries to implement the specifications in a relatively
@@ -2545,6 +2551,7 @@
+
} </pre>
</li>
<li>And then use it to save the document:
diff --git a/doc/xmlio.html b/doc/xmlio.html
index e462338..afa9213 100644
--- a/doc/xmlio.html
+++ b/doc/xmlio.html
@@ -247,6 +247,7 @@
+
} </pre>
</li>
<li>And then use it to save the document:
diff --git a/nanohttp.c b/nanohttp.c
index 7acddca..01e4353 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -846,83 +846,90 @@
struct sockaddr *addr;
struct in_addr ia;
struct sockaddr_in sockin;
+
#ifdef SUPPORT_IP6
struct in6_addr ia6;
struct sockaddr_in6 sockin6;
#endif
int i;
int s;
-
+
#if defined(SUPPORT_IP6) && defined(RES_USE_INET6)
if (!(_res.options & RES_INIT))
- res_init();
+ res_init();
_res.options |= RES_USE_INET6;
#endif
- h=gethostbyname(host);
- if (h==NULL)
- {
- const char * h_err_txt = "";
- switch ( h_errno )
- {
- case HOST_NOT_FOUND:
- h_err_txt = "Authoritive host not found";
- break;
-
- case TRY_AGAIN:
- h_err_txt =
- "Non-authoritive host not found or server failure.";
- break;
+ h = gethostbyname(host);
+ if (h == NULL) {
+#if defined(HAVE_NETDB_H) && defined(HOST_NOT_FOUND)
+ const char *h_err_txt = "";
- case NO_RECOVERY:
- h_err_txt =
- "Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
- break;
+ switch (h_errno) {
+ case HOST_NOT_FOUND:
+ h_err_txt = "Authoritive host not found";
+ break;
- case NO_ADDRESS:
- h_err_txt = "Valid name, no data record of requested type.";
- break;
+ case TRY_AGAIN:
+ h_err_txt =
+ "Non-authoritive host not found or server failure.";
+ break;
- default:
- h_err_txt = "No error text defined.";
- break;
- }
- xmlGenericError( xmlGenericErrorContext,
- "xmlNanoHTTPConnectHost: %s '%s' - %s",
- "Failed to resolve host", host, h_err_txt );
- return(-1);
- }
-
- for(i=0; h->h_addr_list[i]; i++)
- {
- if (h->h_addrtype == AF_INET) {
- /* A records (IPv4) */
- memcpy(&ia, h->h_addr_list[i], h->h_length);
- sockin.sin_family = h->h_addrtype;
- sockin.sin_addr = ia;
- sockin.sin_port = htons(port);
- addr = (struct sockaddr *)&sockin;
-#ifdef SUPPORT_IP6
- } else if (h->h_addrtype == AF_INET6) {
- /* AAAA records (IPv6) */
- memcpy(&ia6, h->h_addr_list[i], h->h_length);
- sockin6.sin_family = h->h_addrtype;
- sockin6.sin_addr = ia6;
- sockin6.sin_port = htons(port);
- addr = (struct sockaddr *)&sockin6;
+ case NO_RECOVERY:
+ h_err_txt =
+ "Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
+ break;
+
+ case NO_ADDRESS:
+ h_err_txt =
+ "Valid name, no data record of requested type.";
+ break;
+
+ default:
+ h_err_txt = "No error text defined.";
+ break;
+ }
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNanoHTTPConnectHost: %s '%s' - %s",
+ "Failed to resolve host", host, h_err_txt);
+#else
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlNanoHTTPConnectHost: %s '%s'",
+ "Failed to resolve host", host);
#endif
- } else
- break; /* for */
-
- s = xmlNanoHTTPConnectAttempt(addr);
- if (s != -1)
- return(s);
+ return (-1);
+ }
+
+ for (i = 0; h->h_addr_list[i]; i++) {
+ if (h->h_addrtype == AF_INET) {
+ /* A records (IPv4) */
+ memcpy(&ia, h->h_addr_list[i], h->h_length);
+ sockin.sin_family = h->h_addrtype;
+ sockin.sin_addr = ia;
+ sockin.sin_port = htons(port);
+ addr = (struct sockaddr *) &sockin;
+#ifdef SUPPORT_IP6
+ } else if (h->h_addrtype == AF_INET6) {
+ /* AAAA records (IPv6) */
+ memcpy(&ia6, h->h_addr_list[i], h->h_length);
+ sockin6.sin_family = h->h_addrtype;
+ sockin6.sin_addr = ia6;
+ sockin6.sin_port = htons(port);
+ addr = (struct sockaddr *) &sockin6;
+#endif
+ } else
+ break; /* for */
+
+ s = xmlNanoHTTPConnectAttempt(addr);
+ if (s != -1)
+ return (s);
}
#ifdef DEBUG_HTTP
xmlGenericError(xmlGenericErrorContext,
- "xmlNanoHTTPConnectHost: unable to connect to '%s'.\n", host);
+ "xmlNanoHTTPConnectHost: unable to connect to '%s'.\n",
+ host);
#endif
- return(-1);
+ return (-1);
}