diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | HTMLparser.c | 4 | ||||
-rw-r--r-- | parser.c | 38 | ||||
-rw-r--r-- | testURI.c | 7 | ||||
-rw-r--r-- | uri.c | 8 |
5 files changed, 51 insertions, 13 deletions
@@ -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 & + * 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) && @@ -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); @@ -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); } @@ -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++]; } |