aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--HTMLparser.c4
-rw-r--r--parser.c38
-rw-r--r--testURI.c7
-rw-r--r--uri.c8
5 files changed, 51 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 305f71f2..9371a9f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Aug 23 00:23:41 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
+
+ * parser.c: Fixed Bug#21552: libxml fails to decode &amp;
+ * uri.c testUri.c patches, by Marc Sanfacon (1 left)
+ * parser.c HTMLparser.c: HTML/encoding push problems reportedi
+ by Wayne Davison
+
Sun Aug 20 17:03:38 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* nanoftp.c nanohttp.c: small cleanup
diff --git a/HTMLparser.c b/HTMLparser.c
index 75edb108..6bb6a970 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -4220,8 +4220,10 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
htmlParseTryOrFinish(ctxt, terminate);
- } else if (ctxt->instate != XML_PARSER_EOF)
+ } else if (ctxt->instate != XML_PARSER_EOF) {
+ xmlParserInputBufferPush(ctxt->input->buf, 0, "");
htmlParseTryOrFinish(ctxt, terminate);
+ }
if (terminate) {
if ((ctxt->instate != XML_PARSER_EOF) &&
(ctxt->instate != XML_PARSER_EPILOG) &&
diff --git a/parser.c b/parser.c
index 14aee653..ae1f5e70 100644
--- a/parser.c
+++ b/parser.c
@@ -443,6 +443,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
if (in->base == NULL) return(-1);
if (in->cur == NULL) return(-1);
if (in->buf->buffer == NULL) return(-1);
+ if (in->buf->readcallback == NULL) return(-1);
CHECK_BUFFER(in);
@@ -2484,7 +2485,15 @@ xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,
}
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
ent = xmlParseStringEntityRef(ctxt, &str);
- if ((ent != NULL) && (ent->content != NULL)) {
+ if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
+ if (ent->content != NULL) {
+ COPY_BUF(0,buffer,nbchars,ent->content[0]);
+ } else {
+ if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
+ ctxt->sax->error(ctxt->userData,
+ "internal error entity has no content\n");
+ }
+ } else if ((ent != NULL) && (ent->content != NULL)) {
xmlChar *rep;
ctxt->depth++;
@@ -2833,15 +2842,24 @@ xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
ctxt->input->buf->raw = ctxt->input->buf->buffer;
ctxt->input->buf->buffer = xmlBufferCreate();
- /*
- * convert just enough to get
- * '<?xml version="1.0" encoding="xxx"?>'
- * parsed with the autodetected encoding
- * into the parser reading buffer.
- */
- nbchars = xmlCharEncFirstLine(ctxt->input->buf->encoder,
- ctxt->input->buf->buffer,
- ctxt->input->buf->raw);
+ if (ctxt->html) {
+ /*
+ * converst as much as possbile of the buffer
+ */
+ nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,
+ ctxt->input->buf->buffer,
+ ctxt->input->buf->raw);
+ } else {
+ /*
+ * convert just enough to get
+ * '<?xml version="1.0" encoding="xxx"?>'
+ * parsed with the autodetected encoding
+ * into the parser reading buffer.
+ */
+ nbchars = xmlCharEncFirstLine(ctxt->input->buf->encoder,
+ ctxt->input->buf->buffer,
+ ctxt->input->buf->raw);
+ }
if (nbchars < 0) {
fprintf(stderr, "xmlSwitchToEncoding: encoder error\n");
return(-1);
diff --git a/testURI.c b/testURI.c
index 0cb904c9..50b508e2 100644
--- a/testURI.c
+++ b/testURI.c
@@ -27,6 +27,10 @@ int main(int argc, char **argv) {
const char *base = NULL;
xmlChar *composite;
+ if (argv[arg] == NULL) {
+ printf("Usage: %s [-base URI] URI ...\n", argv[0]);
+ exit(0);
+ }
if ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base"))) {
arg++;
base = argv[arg];
@@ -78,8 +82,7 @@ int main(int argc, char **argv) {
}
} else {
composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base);
- if (base == NULL) {
- } else {
+ if (composite != NULL) {
printf("%s\n", composite);
xmlFree(composite);
}
diff --git a/uri.c b/uri.c
index 1ed14104..28810c7c 100644
--- a/uri.c
+++ b/uri.c
@@ -1024,6 +1024,7 @@ xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) {
*str = cur;
return(-1);
}
+ path[len] = '\0';
if (uri->path != NULL)
memcpy(path, uri->path, len2);
if (slash) {
@@ -1614,6 +1615,13 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
*/
if (ref->path != NULL) {
index = 0;
+ /*
+ * Ensure the path includes a '/'
+ */
+ if (res->path[0] != '/' && ref->path[0] != 0 &&
+ ref->path[index] != '/') {
+ res->path[out++] = '/';
+ }
while (ref->path[index] != 0) {
res->path[out++] = ref->path[index++];
}