Commit ac21d779 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot

Merge topic 'update-libxml2'

fe7c27ce libxml2: update version number
b4e4538f Merge branch 'upstream-libxml2' into update-libxml2
98ad0d70 libxml2 2019-06-06 (cec0331e)
7e09a527 libxml2: update to 2.9.9
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !5636
parents 60f34aac fe7c27ce
vtk_module_third_party(
INTERNAL
LICENSE_FILES "vtklibxml2/Copyright"
VERSION "2.9.8"
VERSION "2.9.9"
STANDARD_INCLUDE_DIRS
EXTERNAL
PACKAGE LibXml2
......
......@@ -8,7 +8,7 @@ readonly name="libxml2"
readonly ownership="libxml2 Upstream <kwrobot@kitware.com>"
readonly subtree="ThirdParty/$name/vtk$name"
readonly repo="https://gitlab.kitware.com/third-party/libxml2.git"
readonly tag="for/vtk-20190401-2.9.8"
readonly tag="for/vtk-20190606-2.9.9"
readonly paths="
include/libxml/*.h
include/libxml/xmlversion.h.in
......
......@@ -1084,7 +1084,7 @@ static const char * const htmlStartClose[] = {
"menu", "p", "head", "ul", NULL,
"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", FONTSTYLE, NULL,
"div", "p", "head", NULL,
"noscript", "p", NULL,
"noscript", "script", NULL,
"center", "font", "b", "i", "p", "head", NULL,
"a", "a", "head", NULL,
"caption", "p", NULL,
......@@ -3635,13 +3635,13 @@ htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
*/
processed = ctxt->input->cur - ctxt->input->base;
xmlBufShrink(ctxt->input->buf->buffer, processed);
nbchars = xmlCharEncInput(ctxt->input->buf, 0);
nbchars = xmlCharEncInput(ctxt->input->buf, 1);
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"htmlCheckEncoding: encoder error\n",
NULL, NULL);
}
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
}
}
}
......
......@@ -502,16 +502,16 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
/*
* save the content to a temp buffer.
*/
......@@ -570,33 +570,22 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (enc != cur->charset) {
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
/*
* Not supported yet
*/
*mem = NULL;
*size = 0;
return;
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
buf = xmlAllocOutputBufferInternal(handler);
if (buf == NULL) {
*mem = NULL;
......@@ -1101,30 +1090,21 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (enc != cur->charset) {
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
/*
* Not supported yet
*/
return(-1);
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
buf = xmlOutputBufferCreateFile(f, handler);
if (buf == NULL) return(-1);
htmlDocContentDumpOutput(buf, cur, NULL);
......@@ -1160,28 +1140,21 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (enc != cur->charset) {
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
/*
* Not supported yet
*/
return(-1);
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
} else {
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
/*
* save the content to a temp buffer.
*/
......@@ -1221,14 +1194,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (enc != cur->charset) {
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
/*
* Not supported yet
*/
return(-1);
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
......@@ -1236,15 +1202,15 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
} else {
htmlSetMetaEncoding(cur, (const xmlChar *) "UTF-8");
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
if (handler == NULL)
handler = xmlFindCharEncodingHandler("HTML");
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
}
/*
* save the content to a temp buffer.
......
......@@ -1665,7 +1665,11 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
#ifdef DEBUG_SAX_TREE
xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
#endif
nodePush(ctxt, ret);
if (nodePush(ctxt, ret) < 0) {
xmlUnlinkNode(ret);
xmlFreeNode(ret);
return;
}
/*
* Link the child element
......@@ -2257,6 +2261,7 @@ xmlSAX2StartElementNs(void *ctx,
ctxt->freeElems = ret->next;
ctxt->freeElemsNr--;
memset(ret, 0, sizeof(xmlNode));
ret->doc = ctxt->myDoc;
ret->type = XML_ELEMENT_NODE;
if (ctxt->dictNames)
......@@ -2336,7 +2341,11 @@ xmlSAX2StartElementNs(void *ctx,
/*
* We are parsing a new node.
*/
nodePush(ctxt, ret);
if (nodePush(ctxt, ret) < 0) {
xmlUnlinkNode(ret);
xmlFreeNode(ret);
return;
}
/*
* Link the child element
......
......@@ -1797,15 +1797,6 @@ xmlC14NNewCtx(xmlDocPtr doc,
return (NULL);
}
/*
* Validate the XML document encoding value, if provided.
*/
if (doc->charset != XML_CHAR_ENCODING_UTF8) {
xmlC14NErr(ctx, (xmlNodePtr) doc, XML_C14N_REQUIRES_UTF8,
"xmlC14NNewCtx: source document not in UTF8\n");
return (NULL);
}
/*
* Allocate a new xmlC14NCtxPtr and fill the fields.
*/
......
......@@ -2460,8 +2460,6 @@ retry:
ret = -3;
}
if (ret >= 0) output += ret;
/*
* Attempt to handle error cases
*/
......
......@@ -17,7 +17,6 @@
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/SAX.h>
#include <libxml/SAX2.h>
#include <libxml/xmlmemory.h>
......
......@@ -575,7 +575,7 @@ struct _xmlDoc {
void *ids; /* Hash table for ID attributes if any */
void *refs; /* Hash table for IDREFs attributes if any */
const xmlChar *URL; /* The URI for that document */
int charset; /* encoding of the in-memory content
int charset; /* Internal flag for charset handling,
actually an xmlCharEncoding */
struct _xmlDict *dict; /* dict used to allocate names or NULL */
void *psvi; /* for type/PSVI informations */
......
......@@ -133,8 +133,8 @@
#endif
#endif
/* Cygwin platform, GNU compiler */
#if defined(_WIN32) && defined(__CYGWIN__)
/* Cygwin platform (does not define _WIN32), GNU compiler */
#if defined(__CYGWIN__)
#undef XMLPUBFUN
#undef XMLPUBVAR
#undef XMLCALL
......@@ -147,7 +147,7 @@
#if !defined(LIBXML_STATIC)
#define XMLPUBVAR __declspec(dllimport) extern
#else
#define XMLPUBVAR
#define XMLPUBVAR extern
#endif
#endif
#define XMLCALL __cdecl
......
......@@ -12462,7 +12462,12 @@ xmlHaltParser(xmlParserCtxtPtr ctxt) {
ctxt->input->free((xmlChar *) ctxt->input->base);
ctxt->input->free = NULL;
}
if (ctxt->input->buf != NULL) {
xmlFreeParserInputBuffer(ctxt->input->buf);
ctxt->input->buf = NULL;
}
ctxt->input->cur = BAD_CAST"";
ctxt->input->length = 0;
ctxt->input->base = ctxt->input->cur;
ctxt->input->end = ctxt->input->cur;
}
......
......@@ -1214,7 +1214,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
/*
* convert as much as possible of the buffer
*/
nbchars = xmlCharEncInput(input->buf, 0);
nbchars = xmlCharEncInput(input->buf, 1);
} else {
/*
* convert just enough to get
......@@ -1240,8 +1240,18 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* size to be able to convert the buffer.
*/
xmlErrInternal(ctxt, "switching encoding : no input\n", NULL);
/*
* Callers assume that the input buffer takes ownership of the
* encoding handler. xmlCharEncCloseFunc frees unregistered
* handlers and avoids a memory leak.
*/
xmlCharEncCloseFunc(handler);
return (-1);
}
/*
* We should actually raise an error here, see issue #34.
*/
xmlCharEncCloseFunc(handler);
return (0);
}
......
......@@ -1573,6 +1573,9 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
#endif
}
}
if (xmlRelaxNGRemoveRedefine(ctxt, URL, tmp->children, name) == 1) {
found = 1;
}
}
tmp = tmp2;
}
......@@ -1739,7 +1742,18 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
xmlFree(name);
}
}
cur = cur->next;
if (IS_RELAXNG(cur, "div") && cur->children != NULL) {
cur = cur->children;
} else {
if (cur->next != NULL) {
cur = cur->next;
} else {
while (cur->parent != node && cur->parent->next == NULL) {
cur = cur->parent;
}
cur = cur->parent != node ? cur->parent->next : NULL;
}
}
}
......@@ -3979,7 +3993,7 @@ xmlRelaxNGGenerateAttributes(xmlRelaxNGParserCtxtPtr ctxt,
* xmlRelaxNGGetElements:
* @ctxt: a Relax-NG parser context
* @def: the definition definition
* @eora: gather elements (0) or attributes (1)
* @eora: gather elements (0), attributes (1) or elements and text (2)
*
* Compute the list of top elements a definition can generate
*
......@@ -4005,7 +4019,12 @@ xmlRelaxNGGetElements(xmlRelaxNGParserCtxtPtr ctxt,
while (cur != NULL) {
if (((eora == 0) && ((cur->type == XML_RELAXNG_ELEMENT) ||
(cur->type == XML_RELAXNG_TEXT))) ||
((eora == 1) && (cur->type == XML_RELAXNG_ATTRIBUTE))) {
((eora == 1) && (cur->type == XML_RELAXNG_ATTRIBUTE)) ||
((eora == 2) && ((cur->type == XML_RELAXNG_DATATYPE) ||
(cur->type == XML_RELAXNG_ELEMENT) ||
(cur->type == XML_RELAXNG_LIST) ||
(cur->type == XML_RELAXNG_TEXT) ||
(cur->type == XML_RELAXNG_VALUE)))) {
if (ret == NULL) {
max = 10;
ret = (xmlRelaxNGDefinePtr *)
......@@ -4360,7 +4379,7 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
if (cur->type == XML_RELAXNG_TEXT)
is_mixed++;
groups[nbgroups]->rule = cur;
groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 0);
groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 2);
groups[nbgroups]->attrs = xmlRelaxNGGetElements(ctxt, cur, 1);
nbgroups++;
cur = cur->next;
......@@ -5347,11 +5366,15 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node,
xmlNodePtr child;
xmlRelaxNGDefinePtr last = NULL;
ret = xmlRelaxNGNewDefine(ctxt, node);
if (ret == NULL)
return (NULL);
ret->parent = def;
ret->type = XML_RELAXNG_CHOICE;
if (def->type == XML_RELAXNG_CHOICE) {
ret = def;
} else {
ret = xmlRelaxNGNewDefine(ctxt, node);
if (ret == NULL)
return (NULL);
ret->parent = def;
ret->type = XML_RELAXNG_CHOICE;
}
if (node->children == NULL) {
xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_EMPTY,
......@@ -5363,7 +5386,7 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node,
tmp = xmlRelaxNGParseNameClass(ctxt, child, ret);
if (tmp != NULL) {
if (last == NULL) {
last = ret->nameClass = tmp;
last = tmp;
} else {
last->next = tmp;
last = tmp;
......@@ -9262,7 +9285,10 @@ xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr * list)
return (1);
} else if (((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) &&
(cur->type == XML_RELAXNG_TEXT)) {
((cur->type == XML_RELAXNG_DATATYPE) ||
(cur->type == XML_RELAXNG_LIST) ||
(cur->type == XML_RELAXNG_TEXT) ||
(cur->type == XML_RELAXNG_VALUE))) {
return (1);
}
cur = list[i++];
......
......@@ -2236,25 +2236,8 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
* First we take care of the special case where either of the
* two path components may be missing (bug 316224)
*/
if (bas->path == NULL) {
if (ref->path != NULL) {
uptr = (xmlChar *) ref->path;
if (*uptr == '/')
uptr++;
/* exception characters from xmlSaveUri */
val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,");
}
goto done;
}
bptr = (xmlChar *)bas->path;
if (ref->path == NULL) {
for (ix = 0; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
uptr = NULL;
len = 1; /* this is for a string terminator only */
} else {
{
xmlChar *rptr = (xmlChar *) ref->path;
int pos = 0;
......@@ -2280,30 +2263,28 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
* beginning of the "unique" suffix of URI
*/
ix = pos;
if ((rptr[ix] == '/') && (ix > 0))
ix--;
else if ((rptr[ix] == 0) && (ix > 1) && (rptr[ix - 1] == '/'))
ix -= 2;
for (; ix > 0; ix--) {
if (rptr[ix] == '/')
if (rptr[ix - 1] == '/')
break;
}
if (ix == 0) {
uptr = (xmlChar *)rptr;
} else {
ix++;
uptr = (xmlChar *)&rptr[ix];
}
uptr = (xmlChar *)&rptr[ix];
/*
* In base, count the number of '/' from the differing point
*/
if (bptr[pos] != rptr[pos]) {/* check for trivial URI == base */
for (; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
for (; bptr[ix] != 0; ix++) {
if (bptr[ix] == '/')
nbslash++;
}
/*
* e.g: URI="foo/" base="foo/bar" -> "./"
*/
if (nbslash == 0 && !uptr[0]) {
val = xmlStrdup(BAD_CAST "./");
goto done;
}
len = xmlStrlen (uptr) + 1;
}
......
......@@ -3157,7 +3157,7 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
* convert as much as possible to the parser reading buffer.
*/
use = xmlBufUse(in->raw);
nbchars = xmlCharEncInput(in, 0);
nbchars = xmlCharEncInput(in, 1);
if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER;
......@@ -3273,7 +3273,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
* convert as much as possible to the parser reading buffer.
*/
use = xmlBufUse(in->raw);
nbchars = xmlCharEncInput(in, 0);
nbchars = xmlCharEncInput(in, 1);
if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER;
......
......@@ -1711,10 +1711,11 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
if (xmlTextReaderExpand(reader) == NULL) {
return NULL;
}
doc = reader->doc;
doc = reader->node->doc;
buff = xmlBufferCreate();
for (cur_node = reader->node->children; cur_node != NULL;
cur_node = cur_node->next) {
/* XXX: Why is the node copied? */
node = xmlDocCopyNode(cur_node, doc, 1);
buff2 = xmlBufferCreate();
if (xmlNodeDump(buff2, doc, node, 0, 0) == -1) {
......@@ -1755,10 +1756,11 @@ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
xmlDocPtr doc;
node = reader->node;
doc = reader->doc;
doc = node->doc;
if (xmlTextReaderExpand(reader) == NULL) {
return NULL;
}
/* XXX: Why is the node copied? */
if (node->type == XML_DTD_NODE) {
node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node);
} else {
......@@ -1917,12 +1919,9 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
/* if reader->node->next is NULL mean no subtree for current node,
so need to move to sibling of parent node if present */
if ((reader->node->type == XML_ELEMENT_NODE) ||
(reader->node->type == XML_ATTRIBUTE_NODE)) {
reader->state = XML_TEXTREADER_BACKTRACK;
/* This will move to parent if present */
xmlTextReaderRead(reader);
}
reader->state = XML_TEXTREADER_BACKTRACK;
/* This will move to parent if present */
xmlTextReaderRead(reader);
}
if (reader->node->next != 0) {
......@@ -3006,7 +3005,7 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
* Reference:
* http://www.gnu.org/software/dotgnu/pnetlib-doc/System/Xml/XmlNodeType.html
*
* Returns the xmlNodeType of the current node or -1 in case of error
* Returns the xmlReaderTypes of the current node or -1 in case of error
*/
int
xmlTextReaderNodeType(xmlTextReaderPtr reader) {
......
......@@ -1123,9 +1123,6 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
cur->encoding = BAD_CAST ctxt->encoding;
} else if (cur->encoding != NULL) {
encoding = cur->encoding;
} else if (cur->charset != XML_CHAR_ENCODING_UTF8) {
encoding = (const xmlChar *)
xmlGetCharEncodingName((xmlCharEncoding) cur->charset);
}
if (((cur->type == XML_HTML_DOCUMENT_NODE) &&
......
......@@ -27653,6 +27653,17 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
vctxt->nbIdcNodes = 0;
vctxt->sizeIdcNodes = 0;
}
if (vctxt->idcKeys != NULL) {
int i;
for (i = 0; i < vctxt->nbIdcKeys; i++)
xmlSchemaIDCFreeKey(vctxt->idcKeys[i]);
xmlFree(vctxt->idcKeys);
vctxt->idcKeys = NULL;
vctxt->nbIdcKeys = 0;
vctxt->sizeIdcKeys = 0;
}
/*
* Note that we won't delete the XPath state pool here.
*/
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment