1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +03:00

bug fixes, bugfixes, bugfixes ...

- 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
Daniel
This commit is contained in:
Daniel Veillard
2000-08-22 23:36:12 +00:00
parent af7fc34f22
commit 52402ce7eb
5 changed files with 51 additions and 13 deletions

View File

@ -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> Sun Aug 20 17:03:38 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* nanoftp.c nanohttp.c: small cleanup * nanoftp.c nanohttp.c: small cleanup

View File

@ -4220,8 +4220,10 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
if ((terminate) || (ctxt->input->buf->buffer->use > 80)) if ((terminate) || (ctxt->input->buf->buffer->use > 80))
htmlParseTryOrFinish(ctxt, terminate); 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); htmlParseTryOrFinish(ctxt, terminate);
}
if (terminate) { if (terminate) {
if ((ctxt->instate != XML_PARSER_EOF) && if ((ctxt->instate != XML_PARSER_EOF) &&
(ctxt->instate != XML_PARSER_EPILOG) && (ctxt->instate != XML_PARSER_EPILOG) &&

View File

@ -443,6 +443,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
if (in->base == NULL) return(-1); if (in->base == NULL) return(-1);
if (in->cur == NULL) return(-1); if (in->cur == NULL) return(-1);
if (in->buf->buffer == NULL) return(-1); if (in->buf->buffer == NULL) return(-1);
if (in->buf->readcallback == NULL) return(-1);
CHECK_BUFFER(in); CHECK_BUFFER(in);
@ -2484,7 +2485,15 @@ xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,
} }
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
ent = xmlParseStringEntityRef(ctxt, &str); 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; xmlChar *rep;
ctxt->depth++; ctxt->depth++;
@ -2833,15 +2842,24 @@ xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
ctxt->input->buf->raw = ctxt->input->buf->buffer; ctxt->input->buf->raw = ctxt->input->buf->buffer;
ctxt->input->buf->buffer = xmlBufferCreate(); ctxt->input->buf->buffer = xmlBufferCreate();
/* if (ctxt->html) {
* convert just enough to get /*
* '<?xml version="1.0" encoding="xxx"?>' * converst as much as possbile of the buffer
* parsed with the autodetected encoding */
* into the parser reading buffer. nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,
*/ ctxt->input->buf->buffer,
nbchars = xmlCharEncFirstLine(ctxt->input->buf->encoder, ctxt->input->buf->raw);
ctxt->input->buf->buffer, } else {
ctxt->input->buf->raw); /*
* 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) { if (nbchars < 0) {
fprintf(stderr, "xmlSwitchToEncoding: encoder error\n"); fprintf(stderr, "xmlSwitchToEncoding: encoder error\n");
return(-1); return(-1);

View File

@ -27,6 +27,10 @@ int main(int argc, char **argv) {
const char *base = NULL; const char *base = NULL;
xmlChar *composite; 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"))) { if ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base"))) {
arg++; arg++;
base = argv[arg]; base = argv[arg];
@ -78,8 +82,7 @@ int main(int argc, char **argv) {
} }
} else { } else {
composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base); composite = xmlBuildURI((xmlChar *)argv[arg], (xmlChar *) base);
if (base == NULL) { if (composite != NULL) {
} else {
printf("%s\n", composite); printf("%s\n", composite);
xmlFree(composite); xmlFree(composite);
} }

8
uri.c
View File

@ -1024,6 +1024,7 @@ xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) {
*str = cur; *str = cur;
return(-1); return(-1);
} }
path[len] = '\0';
if (uri->path != NULL) if (uri->path != NULL)
memcpy(path, uri->path, len2); memcpy(path, uri->path, len2);
if (slash) { if (slash) {
@ -1614,6 +1615,13 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
*/ */
if (ref->path != NULL) { if (ref->path != NULL) {
index = 0; 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) { while (ref->path[index] != 0) {
res->path[out++] = ref->path[index++]; res->path[out++] = ref->path[index++];
} }