[LIBXML2] Update to v2.9.4. CORE-11556

svn path=/trunk/; revision=71875
This commit is contained in:
Amine Khaldi 2016-07-09 18:07:58 +00:00
parent 2647877ea8
commit 5c2ff24677
41 changed files with 665 additions and 422 deletions

View file

@ -43,7 +43,7 @@ Used Version: 1.0.6
Website: http://www.bzip.org Website: http://www.bzip.org
Title: LibXML Title: LibXML
Used Version: 2.9.3 Used Version: 2.9.4
Website: http://xmlsoft.org | ftp://xmlsoft.org/libxml2/ Website: http://xmlsoft.org | ftp://xmlsoft.org/libxml2/
Title: Libxslt Title: Libxslt

View file

@ -1,5 +1,5 @@
/* /*
* Summary: string dictionnary * Summary: string dictionary
* Description: dictionary of reusable strings, just used to avoid allocation * Description: dictionary of reusable strings, just used to avoid allocation
* and freeing operations. * and freeing operations.
* *
@ -11,6 +11,18 @@
#ifndef __XML_DICT_H__ #ifndef __XML_DICT_H__
#define __XML_DICT_H__ #define __XML_DICT_H__
#ifdef __cplusplus
#define __XML_EXTERNC extern "C"
#else
#define __XML_EXTERNC
#endif
/*
* The dictionary.
*/
__XML_EXTERNC typedef struct _xmlDict xmlDict;
__XML_EXTERNC typedef xmlDict *xmlDictPtr;
#include <limits.h> #include <limits.h>
#include <libxml/xmlversion.h> #include <libxml/xmlversion.h>
#include <libxml/tree.h> #include <libxml/tree.h>
@ -19,12 +31,6 @@
extern "C" { extern "C" {
#endif #endif
/*
* The dictionnary.
*/
typedef struct _xmlDict xmlDict;
typedef xmlDict *xmlDictPtr;
/* /*
* Initializer * Initializer
*/ */
@ -48,7 +54,7 @@ XMLPUBFUN void XMLCALL
xmlDictFree (xmlDictPtr dict); xmlDictFree (xmlDictPtr dict);
/* /*
* Lookup of entry in the dictionnary. * Lookup of entry in the dictionary.
*/ */
XMLPUBFUN const xmlChar * XMLCALL XMLPUBFUN const xmlChar * XMLCALL
xmlDictLookup (xmlDictPtr dict, xmlDictLookup (xmlDictPtr dict,

View file

@ -260,7 +260,7 @@ struct _xmlParserCtxt {
void *catalogs; /* document's own catalog */ void *catalogs; /* document's own catalog */
int recovery; /* run in recovery mode */ int recovery; /* run in recovery mode */
int progressive; /* is this a progressive parsing */ int progressive; /* is this a progressive parsing */
xmlDictPtr dict; /* dictionnary for the parser */ xmlDictPtr dict; /* dictionary for the parser */
const xmlChar * *atts; /* array for the attributes callbacks */ const xmlChar * *atts; /* array for the attributes callbacks */
int maxatts; /* the size of the array */ int maxatts; /* the size of the array */
int docdict; /* use strings from dict to build tree */ int docdict; /* use strings from dict to build tree */
@ -1099,7 +1099,7 @@ typedef enum {
XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
XML_PARSE_NONET = 1<<11,/* Forbid network access */ XML_PARSE_NONET = 1<<11,/* Forbid network access */
XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */ XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */
XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */

View file

@ -351,7 +351,7 @@ XMLPUBFUN void XMLCALL
xmlParserErrors xmlerr, xmlParserErrors xmlerr,
const char *msg, const char *msg,
const xmlChar * str1, const xmlChar * str1,
const xmlChar * str2); const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0);
#endif #endif
/** /**

View file

@ -28,52 +28,52 @@ extern "C" {
typedef enum { typedef enum {
XML_SCHEMAS_UNKNOWN = 0, XML_SCHEMAS_UNKNOWN = 0,
XML_SCHEMAS_STRING, XML_SCHEMAS_STRING = 1,
XML_SCHEMAS_NORMSTRING, XML_SCHEMAS_NORMSTRING = 2,
XML_SCHEMAS_DECIMAL, XML_SCHEMAS_DECIMAL = 3,
XML_SCHEMAS_TIME, XML_SCHEMAS_TIME = 4,
XML_SCHEMAS_GDAY, XML_SCHEMAS_GDAY = 5,
XML_SCHEMAS_GMONTH, XML_SCHEMAS_GMONTH = 6,
XML_SCHEMAS_GMONTHDAY, XML_SCHEMAS_GMONTHDAY = 7,
XML_SCHEMAS_GYEAR, XML_SCHEMAS_GYEAR = 8,
XML_SCHEMAS_GYEARMONTH, XML_SCHEMAS_GYEARMONTH = 9,
XML_SCHEMAS_DATE, XML_SCHEMAS_DATE = 10,
XML_SCHEMAS_DATETIME, XML_SCHEMAS_DATETIME = 11,
XML_SCHEMAS_DURATION, XML_SCHEMAS_DURATION = 12,
XML_SCHEMAS_FLOAT, XML_SCHEMAS_FLOAT = 13,
XML_SCHEMAS_DOUBLE, XML_SCHEMAS_DOUBLE = 14,
XML_SCHEMAS_BOOLEAN, XML_SCHEMAS_BOOLEAN = 15,
XML_SCHEMAS_TOKEN, XML_SCHEMAS_TOKEN = 16,
XML_SCHEMAS_LANGUAGE, XML_SCHEMAS_LANGUAGE = 17,
XML_SCHEMAS_NMTOKEN, XML_SCHEMAS_NMTOKEN = 18,
XML_SCHEMAS_NMTOKENS, XML_SCHEMAS_NMTOKENS = 19,
XML_SCHEMAS_NAME, XML_SCHEMAS_NAME = 20,
XML_SCHEMAS_QNAME, XML_SCHEMAS_QNAME = 21,
XML_SCHEMAS_NCNAME, XML_SCHEMAS_NCNAME = 22,
XML_SCHEMAS_ID, XML_SCHEMAS_ID = 23,
XML_SCHEMAS_IDREF, XML_SCHEMAS_IDREF = 24,
XML_SCHEMAS_IDREFS, XML_SCHEMAS_IDREFS = 25,
XML_SCHEMAS_ENTITY, XML_SCHEMAS_ENTITY = 26,
XML_SCHEMAS_ENTITIES, XML_SCHEMAS_ENTITIES = 27,
XML_SCHEMAS_NOTATION, XML_SCHEMAS_NOTATION = 28,
XML_SCHEMAS_ANYURI, XML_SCHEMAS_ANYURI = 29,
XML_SCHEMAS_INTEGER, XML_SCHEMAS_INTEGER = 30,
XML_SCHEMAS_NPINTEGER, XML_SCHEMAS_NPINTEGER = 31,
XML_SCHEMAS_NINTEGER, XML_SCHEMAS_NINTEGER = 32,
XML_SCHEMAS_NNINTEGER, XML_SCHEMAS_NNINTEGER = 33,
XML_SCHEMAS_PINTEGER, XML_SCHEMAS_PINTEGER = 34,
XML_SCHEMAS_INT, XML_SCHEMAS_INT = 35,
XML_SCHEMAS_UINT, XML_SCHEMAS_UINT = 36,
XML_SCHEMAS_LONG, XML_SCHEMAS_LONG = 37,
XML_SCHEMAS_ULONG, XML_SCHEMAS_ULONG = 38,
XML_SCHEMAS_SHORT, XML_SCHEMAS_SHORT = 39,
XML_SCHEMAS_USHORT, XML_SCHEMAS_USHORT = 40,
XML_SCHEMAS_BYTE, XML_SCHEMAS_BYTE = 41,
XML_SCHEMAS_UBYTE, XML_SCHEMAS_UBYTE = 42,
XML_SCHEMAS_HEXBINARY, XML_SCHEMAS_HEXBINARY = 43,
XML_SCHEMAS_BASE64BINARY, XML_SCHEMAS_BASE64BINARY = 44,
XML_SCHEMAS_ANYTYPE, XML_SCHEMAS_ANYTYPE = 45,
XML_SCHEMAS_ANYSIMPLETYPE XML_SCHEMAS_ANYSIMPLETYPE = 46
} xmlSchemaValType; } xmlSchemaValType;
/* /*

View file

@ -937,7 +937,7 @@ XMLPUBFUN void XMLCALL
int code, int code,
xmlNodePtr node, xmlNodePtr node,
const char *msg, const char *msg,
const char *extra); const char *extra) LIBXML_ATTR_FORMAT(4,0);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -97,13 +97,13 @@ XMLPUBFUN xmlChar * XMLCALL
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlStrPrintf (xmlChar *buf, xmlStrPrintf (xmlChar *buf,
int len, int len,
const xmlChar *msg, const char *msg,
...); ...) LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlStrVPrintf (xmlChar *buf, xmlStrVPrintf (xmlChar *buf,
int len, int len,
const xmlChar *msg, const char *msg,
va_list ap); va_list ap) LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL
xmlGetUTF8Char (const unsigned char *utf, xmlGetUTF8Char (const unsigned char *utf,

View file

@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* *
* the version string like "1.2.3" * the version string like "1.2.3"
*/ */
#define LIBXML_DOTTED_VERSION "2.9.3" #define LIBXML_DOTTED_VERSION "2.9.4"
/** /**
* LIBXML_VERSION: * LIBXML_VERSION:
* *
* the version number: 1.2.3 value is 10203 * the version number: 1.2.3 value is 10203
*/ */
#define LIBXML_VERSION 20903 #define LIBXML_VERSION 20904
/** /**
* LIBXML_VERSION_STRING: * LIBXML_VERSION_STRING:
* *
* the version number string, 1.2.3 value is "10203" * the version number string, 1.2.3 value is "10203"
*/ */
#define LIBXML_VERSION_STRING "20903" #define LIBXML_VERSION_STRING "20904"
/** /**
* LIBXML_VERSION_EXTRA: * LIBXML_VERSION_EXTRA:
* *
* extra version information, used to show a CVS compilation * extra version information, used to show a CVS compilation
*/ */
#define LIBXML_VERSION_EXTRA "-GITCVE-2015-8242" #define LIBXML_VERSION_EXTRA "-GITCVE-2016-1834-21-g502f6a6"
/** /**
* LIBXML_TEST_VERSION: * LIBXML_TEST_VERSION:
@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro to check that the libxml version in use is compatible with * Macro to check that the libxml version in use is compatible with
* the version the software has been compiled against * the version the software has been compiled against
*/ */
#define LIBXML_TEST_VERSION xmlCheckVersion(20903); #define LIBXML_TEST_VERSION xmlCheckVersion(20904);
#ifndef VMS #ifndef VMS
#if 0 #if 0

View file

@ -229,7 +229,7 @@ XMLPUBFUN void * XMLCALL
* Empties a node-set. * Empties a node-set.
*/ */
#define xmlXPathEmptyNodeSet(ns) \ #define xmlXPathEmptyNodeSet(ns) \
{ while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; } { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; }
/** /**
* CHECK_ERROR: * CHECK_ERROR:

View file

@ -593,7 +593,7 @@ Thu Apr 24 13:56:53 CEST 2008 Daniel Veillard <daniel@veillard.com>
Tue Apr 22 10:27:17 CEST 2008 Daniel Veillard <daniel@veillard.com> Tue Apr 22 10:27:17 CEST 2008 Daniel Veillard <daniel@veillard.com>
* dict.c: improvement on the hashing of the dictionnary, with visible * dict.c: improvement on the hashing of the dictionary, with visible
speed up as the number of strings in the hash increases, work from speed up as the number of strings in the hash increases, work from
Stefan Behnel Stefan Behnel
@ -5017,7 +5017,7 @@ Mon Jan 24 00:47:41 CET 2005 Daniel Veillard <daniel@veillard.com>
Sun Jan 23 23:54:39 CET 2005 Daniel Veillard <daniel@veillard.com> Sun Jan 23 23:54:39 CET 2005 Daniel Veillard <daniel@veillard.com>
* hash.c include/libxml/hash.h: added xmlHashCreateDict where * hash.c include/libxml/hash.h: added xmlHashCreateDict where
the hash reuses the dictionnary for internal strings the hash reuses the dictionary for internal strings
* entities.c valid.c parser.c: reuse that new API, leads to a decent * entities.c valid.c parser.c: reuse that new API, leads to a decent
speedup when parsing for example DocBook documents. speedup when parsing for example DocBook documents.
@ -5371,7 +5371,7 @@ Fri Nov 26 11:44:36 CET 2004 Daniel Veillard <daniel@veillard.com>
Wed Nov 24 13:41:52 CET 2004 Daniel Veillard <daniel@veillard.com> Wed Nov 24 13:41:52 CET 2004 Daniel Veillard <daniel@veillard.com>
* dict.c include/libxml/dict.h: added xmlDictExists() to the * dict.c include/libxml/dict.h: added xmlDictExists() to the
dictionnary interface. dictionary interface.
* xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces * xmlreader.c: applying xmlTextReaderHasAttributes fix for namespaces
from Rob Richards from Rob Richards
@ -5697,7 +5697,7 @@ Tue Oct 26 23:57:02 CEST 2004 Daniel Veillard <daniel@veillard.com>
Tue Oct 26 18:09:59 CEST 2004 Daniel Veillard <daniel@veillard.com> Tue Oct 26 18:09:59 CEST 2004 Daniel Veillard <daniel@veillard.com>
* debugXML.c include/libxml/xmlerror.h: added checking for names * debugXML.c include/libxml/xmlerror.h: added checking for names
values and dictionnaries generates a tons of errors values and dictionaries generates a tons of errors
* SAX2.ccatalog.c parser.c relaxng.c tree.c xinclude.c xmlwriter.c * SAX2.ccatalog.c parser.c relaxng.c tree.c xinclude.c xmlwriter.c
include/libxml/tree.h: fixing the errors in the regression tests include/libxml/tree.h: fixing the errors in the regression tests
@ -7746,14 +7746,14 @@ Fri Jan 23 14:03:21 CET 2004 Daniel Veillard <daniel@veillard.com>
make tests make tests
* xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to * xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to
compile an XPath expression within a context, currently the goal compile an XPath expression within a context, currently the goal
is to be able to reuse the XSLT stylesheet dictionnary, but this is to be able to reuse the XSLT stylesheet dictionary, but this
opens the door to others possible optimizations. opens the door to others possible optimizations.
* dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows * dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows
to build a new dictionnary based on another read-only dictionnary. to build a new dictionary based on another read-only dictionary.
This is needed for XSLT to keep the stylesheet dictionnary read-only This is needed for XSLT to keep the stylesheet dictionary read-only
while being able to reuse the strings for the transformation while being able to reuse the strings for the transformation
dictionnary. dictionary.
* xinclude.c: fixed a dictionnar reference counting problem occuring * xinclude.c: fixed a dictionary reference counting problem occuring
when document parsing failed. when document parsing failed.
* testSAX.c: adding option --repeat for timing 100times the parsing * testSAX.c: adding option --repeat for timing 100times the parsing
* doc/* : rebuilt all the docs * doc/* : rebuilt all the docs
@ -7806,7 +7806,7 @@ Mon Jan 12 17:22:57 CET 2004 Daniel Veillard <daniel@veillard.com>
Thu Jan 8 17:57:50 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Jan 8 17:57:50 CET 2004 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c: removed a memory leak remaining from the switch * xmlschemas.c: removed a memory leak remaining from the switch
to a dictionnary for string allocations c.f. #130891 to a dictionary for string allocations c.f. #130891
Thu Jan 8 17:48:46 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Jan 8 17:48:46 CET 2004 Daniel Veillard <daniel@veillard.com>
@ -7928,7 +7928,7 @@ Fri Jan 2 22:58:29 HKT 2004 William Brack <wbrack@mmm.com.hk>
Fri Jan 2 11:40:06 CET 2004 Daniel Veillard <daniel@veillard.com> Fri Jan 2 11:40:06 CET 2004 Daniel Veillard <daniel@veillard.com>
* SAX2.c: found and fixed a bug misallocating some non * SAX2.c: found and fixed a bug misallocating some non
blank text node strings from the dictionnary. blank text node strings from the dictionary.
* xmlmemory.c: fixed a problem with the memory debug mutex * xmlmemory.c: fixed a problem with the memory debug mutex
release. release.
@ -9386,7 +9386,7 @@ Sat Sep 27 01:25:39 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: William's change allowed to spot a nasty bug in xmlDoRead * parser.c: William's change allowed to spot a nasty bug in xmlDoRead
if the result is not well formed that ctxt->myDoc is not NULL if the result is not well formed that ctxt->myDoc is not NULL
and uses the context dictionnary. and uses the context dictionary.
Fri Sep 26 21:09:34 CEST 2003 Daniel Veillard <daniel@veillard.com> Fri Sep 26 21:09:34 CEST 2003 Daniel Veillard <daniel@veillard.com>

View file

@ -105,7 +105,7 @@ htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {
@ -132,7 +132,7 @@ htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, int val) const char *msg, int val)
{ {
@ -303,6 +303,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
#define UPP(val) (toupper(ctxt->input->cur[(val)])) #define UPP(val) (toupper(ctxt->input->cur[(val)]))
#define CUR_PTR ctxt->input->cur #define CUR_PTR ctxt->input->cur
#define BASE_PTR ctxt->input->base
#define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \ #define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \ (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
@ -2471,6 +2472,10 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
(*in == '_') || (*in == '-') || (*in == '_') || (*in == '-') ||
(*in == ':') || (*in == '.')) (*in == ':') || (*in == '.'))
in++; in++;
if (in == ctxt->input->end)
return(NULL);
if ((*in > 0) && (*in < 0x80)) { if ((*in > 0) && (*in < 0x80)) {
count = in - ctxt->input->cur; count = in - ctxt->input->cur;
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
@ -2488,6 +2493,7 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
int len = 0, l; int len = 0, l;
int c; int c;
int count = 0; int count = 0;
const xmlChar *base = ctxt->input->base;
/* /*
* Handler for more complex cases * Handler for more complex cases
@ -2513,7 +2519,18 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
len += l; len += l;
NEXTL(l); NEXTL(l);
c = CUR_CHAR(l); c = CUR_CHAR(l);
if (ctxt->input->base != base) {
/*
* We changed encoding from an unknown encoding
* Input buffer changed location, so we better start again
*/
return(htmlParseNameComplex(ctxt));
}
} }
if (ctxt->input->base > ctxt->input->cur - len)
return(NULL);
return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len)); return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
} }
@ -2765,31 +2782,43 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) {
static xmlChar * static xmlChar *
htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q; size_t len = 0, startPosition = 0;
xmlChar *ret = NULL; xmlChar *ret = NULL;
if (CUR == '"') { if (CUR == '"') {
NEXT; NEXT;
q = CUR_PTR;
while ((IS_CHAR_CH(CUR)) && (CUR != '"')) if (CUR_PTR < BASE_PTR)
return(ret);
startPosition = CUR_PTR - BASE_PTR;
while ((IS_CHAR_CH(CUR)) && (CUR != '"')) {
NEXT; NEXT;
len++;
}
if (!IS_CHAR_CH(CUR)) { if (!IS_CHAR_CH(CUR)) {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
"Unfinished SystemLiteral\n", NULL, NULL); "Unfinished SystemLiteral\n", NULL, NULL);
} else { } else {
ret = xmlStrndup(q, CUR_PTR - q); ret = xmlStrndup((BASE_PTR+startPosition), len);
NEXT; NEXT;
} }
} else if (CUR == '\'') { } else if (CUR == '\'') {
NEXT; NEXT;
q = CUR_PTR;
while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) if (CUR_PTR < BASE_PTR)
return(ret);
startPosition = CUR_PTR - BASE_PTR;
while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) {
NEXT; NEXT;
len++;
}
if (!IS_CHAR_CH(CUR)) { if (!IS_CHAR_CH(CUR)) {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
"Unfinished SystemLiteral\n", NULL, NULL); "Unfinished SystemLiteral\n", NULL, NULL);
} else { } else {
ret = xmlStrndup(q, CUR_PTR - q); ret = xmlStrndup((BASE_PTR+startPosition), len);
NEXT; NEXT;
} }
} else { } else {
@ -2813,32 +2842,47 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
static xmlChar * static xmlChar *
htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q; size_t len = 0, startPosition = 0;
xmlChar *ret = NULL; xmlChar *ret = NULL;
/* /*
* Name ::= (Letter | '_') (NameChar)* * Name ::= (Letter | '_') (NameChar)*
*/ */
if (CUR == '"') { if (CUR == '"') {
NEXT; NEXT;
q = CUR_PTR;
while (IS_PUBIDCHAR_CH(CUR)) NEXT; if (CUR_PTR < BASE_PTR)
return(ret);
startPosition = CUR_PTR - BASE_PTR;
while (IS_PUBIDCHAR_CH(CUR)) {
len++;
NEXT;
}
if (CUR != '"') { if (CUR != '"') {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
"Unfinished PubidLiteral\n", NULL, NULL); "Unfinished PubidLiteral\n", NULL, NULL);
} else { } else {
ret = xmlStrndup(q, CUR_PTR - q); ret = xmlStrndup((BASE_PTR + startPosition), len);
NEXT; NEXT;
} }
} else if (CUR == '\'') { } else if (CUR == '\'') {
NEXT; NEXT;
q = CUR_PTR;
while ((IS_PUBIDCHAR_CH(CUR)) && (CUR != '\'')) if (CUR_PTR < BASE_PTR)
NEXT; return(ret);
startPosition = CUR_PTR - BASE_PTR;
while ((IS_PUBIDCHAR_CH(CUR)) && (CUR != '\'')){
len++;
NEXT;
}
if (CUR != '\'') { if (CUR != '\'') {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED,
"Unfinished PubidLiteral\n", NULL, NULL); "Unfinished PubidLiteral\n", NULL, NULL);
} else { } else {
ret = xmlStrndup(q, CUR_PTR - q); ret = xmlStrndup((BASE_PTR + startPosition), len);
NEXT; NEXT;
} }
} else { } else {
@ -6537,7 +6581,7 @@ htmlNodeStatus(const htmlNodePtr node, int legacy) {
* DICT_FREE: * DICT_FREE:
* @str: a string * @str: a string
* *
* Free a string if it is not owned by the "dict" dictionnary in the * Free a string if it is not owned by the "dict" dictionary in the
* current scope * current scope
*/ */
#define DICT_FREE(str) \ #define DICT_FREE(str) \

View file

@ -845,7 +845,7 @@ Gansterer),
- Improvement: switch parser to XML-1.0 5th edition, add parsing flags - Improvement: switch parser to XML-1.0 5th edition, add parsing flags
for old versions, switch URI parsing to RFC 3986, for old versions, switch URI parsing to RFC 3986,
add xmlSchemaValidCtxtGetParserCtxt (Holger Kaelberer), add xmlSchemaValidCtxtGetParserCtxt (Holger Kaelberer),
new hashing functions for dictionnaries (based on Stefan Behnel work), new hashing functions for dictionaries (based on Stefan Behnel work),
improve handling of misplaced html/head/body in HTML parser, better improve handling of misplaced html/head/body in HTML parser, better
regression test tools and code coverage display, better algorithms regression test tools and code coverage display, better algorithms
to detect various versions of the billion laughts attacks, make to detect various versions of the billion laughts attacks, make
@ -1231,7 +1231,7 @@ Do not use or package 2.6.25
Bakefile support (Francesco Montorsi), Windows compilation (Joel Reed), Bakefile support (Francesco Montorsi), Windows compilation (Joel Reed),
some gcc4 fixes, HP-UX portability fixes (Rick Jones). some gcc4 fixes, HP-UX portability fixes (Rick Jones).
- bug fixes: xmlSchemaElementDump namespace (Kasimier Buchcik), push and - bug fixes: xmlSchemaElementDump namespace (Kasimier Buchcik), push and
xmlreader stopping on non-fatal errors, thread support for dictionnaries xmlreader stopping on non-fatal errors, thread support for dictionaries
reference counting (Gary Coady), internal subset and push problem, URL reference counting (Gary Coady), internal subset and push problem, URL
saved in xmlCopyDoc, various schemas bug fixes (Kasimier), Python paths saved in xmlCopyDoc, various schemas bug fixes (Kasimier), Python paths
fixup (Stephane Bidoul), xmlGetNodePath and namespaces, xmlSetNsProp fix fixup (Stephane Bidoul), xmlGetNodePath and namespaces, xmlSetNsProp fix
@ -1244,7 +1244,7 @@ Do not use or package 2.6.25
Hendricks), aliasing bug exposed by gcc4 on s390, xmlTextReaderNext bug Hendricks), aliasing bug exposed by gcc4 on s390, xmlTextReaderNext bug
(Rob Richards), Schemas decimal type fixes (William Brack), (Rob Richards), Schemas decimal type fixes (William Brack),
xmlByteConsumed static buffer (Ben Maurer). xmlByteConsumed static buffer (Ben Maurer).
- improvement: speedup parsing comments and DTDs, dictionnary support for - improvement: speedup parsing comments and DTDs, dictionary support for
hash tables, Schemas Identity constraints (Kasimier), streaming XPath hash tables, Schemas Identity constraints (Kasimier), streaming XPath
subset, xmlTextReaderReadString added (Bjorn Reese), Schemas canonical subset, xmlTextReaderReadString added (Bjorn Reese), Schemas canonical
values handling (Kasimier), add xmlTextReaderByteConsumed (Aron values handling (Kasimier), add xmlTextReaderByteConsumed (Aron
@ -1454,7 +1454,7 @@ Do not use or package 2.6.25
URI on SYSTEM lookup failure, XInclude parse flags inheritance (William), URI on SYSTEM lookup failure, XInclude parse flags inheritance (William),
XInclude and XPointer fixes for entities (William), XML parser bug XInclude and XPointer fixes for entities (William), XML parser bug
reported by Holger Rauch, nanohttp fd leak (William), regexps char reported by Holger Rauch, nanohttp fd leak (William), regexps char
groups '-' handling (William), dictionnary reference counting problems, groups '-' handling (William), dictionary reference counting problems,
do not close stderr. do not close stderr.
- performance patches from Petr Pajas - performance patches from Petr Pajas
- Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey) - Documentation fixes: XML_CATALOG_FILES in man pages (Mike Hommey)
@ -1482,7 +1482,7 @@ Do not use or package 2.6.25
William) reported by Yuuichi Teranishi William) reported by Yuuichi Teranishi
- bugfixes: make test and path issues, xmlWriter attribute serialization - bugfixes: make test and path issues, xmlWriter attribute serialization
(William Brack), xmlWriter indentation (William), schemas validation (William Brack), xmlWriter indentation (William), schemas validation
(Eric Haszlakiewicz), XInclude dictionnaries issues (William and Oleg (Eric Haszlakiewicz), XInclude dictionaries issues (William and Oleg
Paraschenko), XInclude empty fallback (William), HTML warnings (William), Paraschenko), XInclude empty fallback (William), HTML warnings (William),
XPointer in XInclude (William), Python namespace serialization, XPointer in XInclude (William), Python namespace serialization,
isolat1ToUTF8 bound error (Alfred Mickautsch), output of parameter isolat1ToUTF8 bound error (Alfred Mickautsch), output of parameter
@ -1503,7 +1503,7 @@ Do not use or package 2.6.25
2.6.5: Jan 25 2004: 2.6.5: Jan 25 2004:
- Bugfixes: dictionnaries for schemas (William Brack), regexp segfault - Bugfixes: dictionaries for schemas (William Brack), regexp segfault
(William), xs:all problem (William), a number of XPointer bugfixes (William), xs:all problem (William), a number of XPointer bugfixes
(William), xmllint error go to stderr, DTD validation problem with (William), xmllint error go to stderr, DTD validation problem with
namespace, memory leak (William), SAX1 cleanup and minimal options fixes namespace, memory leak (William), SAX1 cleanup and minimal options fixes
@ -1515,14 +1515,14 @@ Do not use or package 2.6.25
Fleck), doc (Sven Zimmerman), I/O example. Fleck), doc (Sven Zimmerman), I/O example.
- Python bindings: fixes (William), enum support (Stéphane Bidoul), - Python bindings: fixes (William), enum support (Stéphane Bidoul),
structured error reporting (Stéphane Bidoul) structured error reporting (Stéphane Bidoul)
- XInclude: various fixes for conformance, problem related to dictionnary - XInclude: various fixes for conformance, problem related to dictionary
references (William & me), recursion (William) references (William & me), recursion (William)
- xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred - xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred
Mickautsch), Mickautsch),
- xmlSchemas: normalizedString datatype (John Belmonte) - xmlSchemas: normalizedString datatype (John Belmonte)
- code cleanup for strings functions (William) - code cleanup for strings functions (William)
- Windows: compiler patches (Mark Vakoc) - Windows: compiler patches (Mark Vakoc)
- Parser optimizations, a few new XPath and dictionnary APIs for future - Parser optimizations, a few new XPath and dictionary APIs for future
XSLT optimizations. XSLT optimizations.
@ -1617,8 +1617,8 @@ Do not use or package 2.6.25
of change of change
- Increased the library modularity, far more options can be stripped out, - Increased the library modularity, far more options can be stripped out,
a --with-minimum configuration will weight around 160KBytes a --with-minimum configuration will weight around 160KBytes
- Use per parser and per document dictionnary, allocate names and small - Use per parser and per document dictionary, allocate names and small
text nodes from the dictionnary text nodes from the dictionary
- Switch to a SAX2 like parser rewrote most of the XML parser core, - Switch to a SAX2 like parser rewrote most of the XML parser core,
provides namespace resolution and defaulted attributes, minimize memory provides namespace resolution and defaulted attributes, minimize memory
allocations and copies, namespace checking and specific error handling, allocations and copies, namespace checking and specific error handling,
@ -1665,7 +1665,7 @@ Do not use or package 2.6.25
(William), xmlCleanupParser (Marc Liyanage), CDATA output (William), HTTP (William), xmlCleanupParser (Marc Liyanage), CDATA output (William), HTTP
error handling. error handling.
- xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for compat - xmllint options: --dtdvalidfpi for Tobias Reif, --sax1 for compat
testing, --nodict for building without tree dictionnary, --nocdata to testing, --nodict for building without tree dictionary, --nocdata to
replace CDATA by text, --nsclean to remove surperfluous namespace replace CDATA by text, --nsclean to remove surperfluous namespace
declarations declarations
- added xml2-config --libtool-libs option from Kevin P. Fleming - added xml2-config --libtool-libs option from Kevin P. Fleming

View file

@ -55,7 +55,7 @@
* @ctxt: an XML validation parser context * @ctxt: an XML validation parser context
* @msg: a string to accompany the error message * @msg: a string to accompany the error message
*/ */
static void static void LIBXML_ATTR_FORMAT(2,0)
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) { xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
xmlStructuredErrorFunc schannel = NULL; xmlStructuredErrorFunc schannel = NULL;
const char *str1 = "out of memory\n"; const char *str1 = "out of memory\n";
@ -93,7 +93,7 @@ xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
* *
* Handle a validation error * Handle a validation error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const char *str1, const char *str2) const char *msg, const char *str1, const char *str2)
{ {
@ -133,7 +133,7 @@ xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {
@ -164,7 +164,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a parser warning * Handle a parser warning
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1) const char *msg, const xmlChar *str1)
{ {
@ -189,7 +189,7 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a namespace error * Handle a namespace error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {
@ -213,7 +213,7 @@ xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a namespace warning * Handle a namespace warning
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {

View file

@ -47,9 +47,9 @@
#define MAX_CATAL_DEPTH 50 #define MAX_CATAL_DEPTH 50
#ifdef _WIN32 #ifdef _WIN32
# define PATH_SEAPARATOR ';' # define PATH_SEPARATOR ';'
#else #else
# define PATH_SEAPARATOR ':' # define PATH_SEPARATOR ':'
#endif #endif
/** /**
@ -238,7 +238,7 @@ xmlCatalogErrMemory(const char *extra)
* *
* Handle a catalog error * Handle a catalog error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error, xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error,
const char *msg, const xmlChar *str1, const xmlChar *str2, const char *msg, const xmlChar *str1, const xmlChar *str2,
const xmlChar *str3) const xmlChar *str3)
@ -3247,7 +3247,7 @@ xmlLoadCatalogs(const char *pathss) {
while (xmlIsBlank_ch(*cur)) cur++; while (xmlIsBlank_ch(*cur)) cur++;
if (*cur != 0) { if (*cur != 0) {
paths = cur; paths = cur;
while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*cur))) while ((*cur != 0) && (*cur != PATH_SEPARATOR) && (!xmlIsBlank_ch(*cur)))
cur++; cur++;
path = xmlStrndup((const xmlChar *)paths, cur - paths); path = xmlStrndup((const xmlChar *)paths, cur - paths);
#ifdef _WIN32 #ifdef _WIN32
@ -3263,7 +3263,7 @@ xmlLoadCatalogs(const char *pathss) {
xmlFree(path); xmlFree(path);
} }
} }
while (*cur == PATH_SEAPARATOR) while (*cur == PATH_SEPARATOR)
cur++; cur++;
} }
} }

View file

@ -44,10 +44,10 @@ struct _xmlDebugCtxt {
int depth; /* current depth */ int depth; /* current depth */
xmlDocPtr doc; /* current document */ xmlDocPtr doc; /* current document */
xmlNodePtr node; /* current node */ xmlNodePtr node; /* current node */
xmlDictPtr dict; /* the doc dictionnary */ xmlDictPtr dict; /* the doc dictionary */
int check; /* do just checkings */ int check; /* do just checkings */
int errors; /* number of errors found */ int errors; /* number of errors found */
int nodict; /* if the document has no dictionnary */ int nodict; /* if the document has no dictionary */
int options; /* options */ int options; /* options */
}; };
@ -164,7 +164,7 @@ xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg)
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, 0, 0,
"%s", msg); "%s", msg);
} }
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
{ {
ctxt->errors++; ctxt->errors++;
@ -174,7 +174,7 @@ xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, 0, 0,
msg, extra); msg, extra);
} }
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra) xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra)
{ {
ctxt->errors++; ctxt->errors++;
@ -243,7 +243,7 @@ xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str)
* @ctxt: the debug context * @ctxt: the debug context
* @name: the name * @name: the name
* *
* Do debugging on the name, for example the dictionnary status and * Do debugging on the name, for example the dictionary status and
* conformance to the Name production. * conformance to the Name production.
*/ */
static void static void
@ -265,7 +265,7 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
((ctxt->doc == NULL) || ((ctxt->doc == NULL) ||
((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) { ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT, xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
"Name is not from the document dictionnary '%s'", "Name is not from the document dictionary '%s'",
(const char *) name); (const char *) name);
} }
} }
@ -292,7 +292,7 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
/* desactivated right now as it raises too many errors */ /* desactivated right now as it raises too many errors */
if (doc->type == XML_DOCUMENT_NODE) if (doc->type == XML_DOCUMENT_NODE)
xmlDebugErr(ctxt, XML_CHECK_NO_DICT, xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
"Document has no dictionnary\n"); "Document has no dictionary\n");
#endif #endif
ctxt->nodict = 1; ctxt->nodict = 1;
} }

View file

@ -87,7 +87,7 @@ typedef unsigned __int32 uint32_t;
#endif /* WITH_BIG_KEY */ #endif /* WITH_BIG_KEY */
/* /*
* An entry in the dictionnary * An entry in the dictionary
*/ */
typedef struct _xmlDictEntry xmlDictEntry; typedef struct _xmlDictEntry xmlDictEntry;
typedef xmlDictEntry *xmlDictEntryPtr; typedef xmlDictEntry *xmlDictEntryPtr;
@ -110,7 +110,7 @@ struct _xmlDictStrings {
xmlChar array[1]; xmlChar array[1];
}; };
/* /*
* The entire dictionnary * The entire dictionary
*/ */
struct _xmlDict { struct _xmlDict {
int ref_counter; int ref_counter;
@ -229,7 +229,7 @@ xmlDictCleanup(void) {
/* /*
* xmlDictAddString: * xmlDictAddString:
* @dict: the dictionnary * @dict: the dictionary
* @name: the name of the userdata * @name: the name of the userdata
* @len: the length of the name * @len: the length of the name
* *
@ -291,7 +291,7 @@ found_pool:
/* /*
* xmlDictAddQString: * xmlDictAddQString:
* @dict: the dictionnary * @dict: the dictionary
* @prefix: the prefix of the userdata * @prefix: the prefix of the userdata
* @plen: the prefix length * @plen: the prefix length
* @name: the name of the userdata * @name: the name of the userdata
@ -533,7 +533,7 @@ xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
* *
* Create a new dictionary * Create a new dictionary
* *
* Returns the newly created dictionnary, or NULL if an error occured. * Returns the newly created dictionary, or NULL if an error occured.
*/ */
xmlDictPtr xmlDictPtr
xmlDictCreate(void) { xmlDictCreate(void) {
@ -573,14 +573,14 @@ xmlDictCreate(void) {
/** /**
* xmlDictCreateSub: * xmlDictCreateSub:
* @sub: an existing dictionnary * @sub: an existing dictionary
* *
* Create a new dictionary, inheriting strings from the read-only * Create a new dictionary, inheriting strings from the read-only
* dictionnary @sub. On lookup, strings are first searched in the * dictionary @sub. On lookup, strings are first searched in the
* new dictionnary, then in @sub, and if not found are created in the * new dictionary, then in @sub, and if not found are created in the
* new dictionnary. * new dictionary.
* *
* Returns the newly created dictionnary, or NULL if an error occured. * Returns the newly created dictionary, or NULL if an error occured.
*/ */
xmlDictPtr xmlDictPtr
xmlDictCreateSub(xmlDictPtr sub) { xmlDictCreateSub(xmlDictPtr sub) {
@ -599,7 +599,7 @@ xmlDictCreateSub(xmlDictPtr sub) {
/** /**
* xmlDictReference: * xmlDictReference:
* @dict: the dictionnary * @dict: the dictionary
* *
* Increment the reference counter of a dictionary * Increment the reference counter of a dictionary
* *
@ -620,10 +620,10 @@ xmlDictReference(xmlDictPtr dict) {
/** /**
* xmlDictGrow: * xmlDictGrow:
* @dict: the dictionnary * @dict: the dictionary
* @size: the new size of the dictionnary * @size: the new size of the dictionary
* *
* resize the dictionnary * resize the dictionary
* *
* Returns 0 in case of success, -1 in case of failure * Returns 0 in case of success, -1 in case of failure
*/ */
@ -755,7 +755,7 @@ xmlDictGrow(xmlDictPtr dict, size_t size) {
/** /**
* xmlDictFree: * xmlDictFree:
* @dict: the dictionnary * @dict: the dictionary
* *
* Free the hash @dict and its contents. The userdata is * Free the hash @dict and its contents. The userdata is
* deallocated with @f if provided. * deallocated with @f if provided.
@ -817,11 +817,11 @@ xmlDictFree(xmlDictPtr dict) {
/** /**
* xmlDictLookup: * xmlDictLookup:
* @dict: the dictionnary * @dict: the dictionary
* @name: the name of the userdata * @name: the name of the userdata
* @len: the length of the name, if -1 it is recomputed * @len: the length of the name, if -1 it is recomputed
* *
* Add the @name to the dictionnary @dict if not present. * Add the @name to the dictionary @dict if not present.
* *
* Returns the internal copy of the name or NULL in case of internal error * Returns the internal copy of the name or NULL in case of internal error
*/ */
@ -957,11 +957,11 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
/** /**
* xmlDictExists: * xmlDictExists:
* @dict: the dictionnary * @dict: the dictionary
* @name: the name of the userdata * @name: the name of the userdata
* @len: the length of the name, if -1 it is recomputed * @len: the length of the name, if -1 it is recomputed
* *
* Check if the @name exists in the dictionnary @dict. * Check if the @name exists in the dictionary @dict.
* *
* Returns the internal copy of the name or NULL if not found. * Returns the internal copy of the name or NULL if not found.
*/ */
@ -1065,7 +1065,7 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
/** /**
* xmlDictQLookup: * xmlDictQLookup:
* @dict: the dictionnary * @dict: the dictionary
* @prefix: the prefix * @prefix: the prefix
* @name: the name * @name: the name
* *
@ -1170,7 +1170,7 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
/** /**
* xmlDictOwns: * xmlDictOwns:
* @dict: the dictionnary * @dict: the dictionary
* @str: the string * @str: the string
* *
* check if a string is owned by the disctionary * check if a string is owned by the disctionary
@ -1197,11 +1197,11 @@ xmlDictOwns(xmlDictPtr dict, const xmlChar *str) {
/** /**
* xmlDictSize: * xmlDictSize:
* @dict: the dictionnary * @dict: the dictionary
* *
* Query the number of elements installed in the hash @dict. * Query the number of elements installed in the hash @dict.
* *
* Returns the number of elements in the dictionnary or * Returns the number of elements in the dictionary or
* -1 in case of error * -1 in case of error
*/ */
int int
@ -1215,7 +1215,7 @@ xmlDictSize(xmlDictPtr dict) {
/** /**
* xmlDictSetLimit: * xmlDictSetLimit:
* @dict: the dictionnary * @dict: the dictionary
* @limit: the limit in bytes * @limit: the limit in bytes
* *
* Set a size limit for the dictionary * Set a size limit for the dictionary
@ -1236,7 +1236,7 @@ xmlDictSetLimit(xmlDictPtr dict, size_t limit) {
/** /**
* xmlDictGetUsage: * xmlDictGetUsage:
* @dict: the dictionnary * @dict: the dictionary
* *
* Get how much memory is used by a dictionary for strings * Get how much memory is used by a dictionary for strings
* Added in 2.9.0 * Added in 2.9.0

View file

@ -93,7 +93,7 @@ xmlEncodingErrMemory(const char *extra)
* *
* n encoding error * n encoding error
*/ */
static void static void LIBXML_ATTR_FORMAT(2,0)
xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val) xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
{ {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,

View file

@ -83,7 +83,7 @@ xmlEntitiesErrMemory(const char *extra)
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
static void static void LIBXML_ATTR_FORMAT(2,0)
xmlEntitiesErr(xmlParserErrors code, const char *msg) xmlEntitiesErr(xmlParserErrors code, const char *msg)
{ {
__xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL); __xmlSimpleError(XML_FROM_TREE, code, NULL, msg, NULL);

View file

@ -18,7 +18,7 @@
void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
const char *msg, const char *msg,
...); ...) LIBXML_ATTR_FORMAT(2,3);
#define XML_GET_VAR_STR(msg, str) { \ #define XML_GET_VAR_STR(msg, str) { \
int size, prev_size = -1; \ int size, prev_size = -1; \
@ -177,8 +177,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
xmlChar content[81]; /* space for 80 chars + line terminator */ xmlChar content[81]; /* space for 80 chars + line terminator */
xmlChar *ctnt; xmlChar *ctnt;
if ((input == NULL) || (input->cur == NULL) || if ((input == NULL) || (input->cur == NULL))
(*input->cur == 0)) return; return;
cur = input->cur; cur = input->cur;
base = input->base; base = input->base;

View file

@ -9,6 +9,8 @@
#ifndef __XML_LIBXML_H__ #ifndef __XML_LIBXML_H__
#define __XML_LIBXML_H__ #define __XML_LIBXML_H__
#include <libxml/xmlstring.h>
#ifndef NO_LARGEFILE_SOURCE #ifndef NO_LARGEFILE_SOURCE
#ifndef _LARGEFILE_SOURCE #ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE
@ -68,7 +70,7 @@ extern int __xmlRegisterCallbacks;
* internal error reporting routines, shared but not partof the API. * internal error reporting routines, shared but not partof the API.
*/ */
void __xmlIOErr(int domain, int code, const char *extra); void __xmlIOErr(int domain, int code, const char *extra);
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename); void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0);
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
/* /*
* internal function of HTML parser needed for xmlParseInNodeContext * internal function of HTML parser needed for xmlParseInNodeContext
@ -93,6 +95,7 @@ int __xmlInitializeDict(void);
int __xmlRandom(void); int __xmlRandom(void);
#endif #endif
XMLPUBFUN xmlChar * XMLCALL xmlEscapeFormatString(xmlChar **msg);
int xmlNop(void); int xmlNop(void);
#ifdef IN_LIBXML #ifdef IN_LIBXML

View file

@ -138,14 +138,20 @@ xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
* entities problems * entities problems
*/ */
if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(ent->content != NULL) && (ent->checked == 0)) { (ent->content != NULL) && (ent->checked == 0) &&
(ctxt->errNo != XML_ERR_ENTITY_LOOP)) {
unsigned long oldnbent = ctxt->nbentities; unsigned long oldnbent = ctxt->nbentities;
xmlChar *rep; xmlChar *rep;
ent->checked = 1; ent->checked = 1;
++ctxt->depth;
rep = xmlStringDecodeEntities(ctxt, ent->content, rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, 0, 0, 0); XML_SUBSTITUTE_REF, 0, 0, 0);
--ctxt->depth;
if (ctxt->errNo == XML_ERR_ENTITY_LOOP) {
ent->content[0] = 0;
}
ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
if (rep != NULL) { if (rep != NULL) {
@ -344,7 +350,6 @@ static void
xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info) xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
{ {
const char *errmsg; const char *errmsg;
char errstr[129] = "";
if ((ctxt != NULL) && (ctxt->disableSAX != 0) && if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF)) (ctxt->instate == XML_PARSER_EOF))
@ -531,15 +536,17 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
default: default:
errmsg = "Unregistered error message"; errmsg = "Unregistered error message";
} }
if (info == NULL)
snprintf(errstr, 128, "%s\n", errmsg);
else
snprintf(errstr, 128, "%s: %%s\n", errmsg);
if (ctxt != NULL) if (ctxt != NULL)
ctxt->errNo = error; ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, if (info == NULL) {
XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, &errstr[0], __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
info); XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
errmsg);
} else {
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
errmsg, info);
}
if (ctxt != NULL) { if (ctxt != NULL) {
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
if (ctxt->recovery == 0) if (ctxt->recovery == 0)
@ -555,7 +562,7 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg) const char *msg)
{ {
@ -583,7 +590,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a warning. * Handle a warning.
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {
@ -621,7 +628,7 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a validity error. * Handle a validity error.
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2) const char *msg, const xmlChar *str1, const xmlChar *str2)
{ {
@ -661,7 +668,7 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, int val) const char *msg, int val)
{ {
@ -691,7 +698,7 @@ xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, int val, const char *msg, const xmlChar *str1, int val,
const xmlChar *str2) const xmlChar *str2)
@ -721,7 +728,7 @@ xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar * val) const char *msg, const xmlChar * val)
{ {
@ -750,7 +757,7 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a non fatal parser error * Handle a non fatal parser error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar * val) const char *msg, const xmlChar * val)
{ {
@ -775,7 +782,7 @@ xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a fatal parser error, i.e. violating Well-Formedness constraints * Handle a fatal parser error, i.e. violating Well-Formedness constraints
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const char *msg,
const xmlChar * info1, const xmlChar * info2, const xmlChar * info1, const xmlChar * info2,
@ -804,7 +811,7 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a namespace warning error * Handle a namespace warning error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const char *msg,
const xmlChar * info1, const xmlChar * info2, const xmlChar * info1, const xmlChar * info2,
@ -2008,6 +2015,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
#define CUR (*ctxt->input->cur) #define CUR (*ctxt->input->cur)
#define NXT(val) ctxt->input->cur[(val)] #define NXT(val) ctxt->input->cur[(val)]
#define CUR_PTR ctxt->input->cur #define CUR_PTR ctxt->input->cur
#define BASE_PTR ctxt->input->base
#define CMP4( s, c1, c2, c3, c4 ) \ #define CMP4( s, c1, c2, c3, c4 ) \
( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \ ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \
@ -2858,7 +2866,21 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
ctxt->nbentities += ent->checked / 2; ctxt->nbentities += ent->checked / 2;
if (ent != NULL) { if (ent != NULL) {
if (ent->content == NULL) { if (ent->content == NULL) {
xmlLoadEntityContent(ctxt, ent); /*
* Note: external parsed entities will not be loaded,
* it is not required for a non-validating parser to
* complete external PEreferences coming from the
* internal subset
*/
if (((ctxt->options & XML_PARSE_NOENT) != 0) ||
((ctxt->options & XML_PARSE_DTDVALID) != 0) ||
(ctxt->validate != 0)) {
xmlLoadEntityContent(ctxt, ent);
} else {
xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
"not validating will not read content for PE entity %s\n",
ent->name, NULL);
}
} }
ctxt->depth++; ctxt->depth++;
rep = xmlStringDecodeEntities(ctxt, ent->content, what, rep = xmlStringDecodeEntities(ctxt, ent->content, what,
@ -3470,7 +3492,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
int len = 0, l; int len = 0, l;
int c; int c;
int count = 0; int count = 0;
const xmlChar *end; /* needed because CUR_CHAR() can move cur on \r\n */ size_t startPosition = 0;
#ifdef DEBUG #ifdef DEBUG
nbParseNCNameComplex++; nbParseNCNameComplex++;
@ -3480,7 +3502,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
* Handler for more complex cases * Handler for more complex cases
*/ */
GROW; GROW;
end = ctxt->input->cur; startPosition = CUR_PTR - BASE_PTR;
c = CUR_CHAR(l); c = CUR_CHAR(l);
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
(!xmlIsNameStartChar(ctxt, c) || (c == ':'))) { (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {
@ -3502,7 +3524,6 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
} }
len += l; len += l;
NEXTL(l); NEXTL(l);
end = ctxt->input->cur;
c = CUR_CHAR(l); c = CUR_CHAR(l);
if (c == 0) { if (c == 0) {
count = 0; count = 0;
@ -3516,7 +3537,6 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
ctxt->input->cur += l; ctxt->input->cur += l;
if (ctxt->instate == XML_PARSER_EOF) if (ctxt->instate == XML_PARSER_EOF)
return(NULL); return(NULL);
end = ctxt->input->cur;
c = CUR_CHAR(l); c = CUR_CHAR(l);
} }
} }
@ -3525,7 +3545,7 @@ xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName"); xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
return(NULL); return(NULL);
} }
return(xmlDictLookup(ctxt->dict, end - len, len)); return(xmlDictLookup(ctxt->dict, (BASE_PTR + startPosition), len));
} }
/** /**
@ -3625,7 +3645,7 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) {
} }
/* failure (or end of input buffer), check with full function */ /* failure (or end of input buffer), check with full function */
ret = xmlParseName (ctxt); ret = xmlParseName (ctxt);
/* strings coming from the dictionnary direct compare possible */ /* strings coming from the dictionary direct compare possible */
if (ret == other) { if (ret == other) {
return (const xmlChar*) 1; return (const xmlChar*) 1;
} }
@ -3966,8 +3986,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
* an entity declaration, it is bypassed and left as is. * an entity declaration, it is bypassed and left as is.
* so XML_SUBSTITUTE_REF is not set here. * so XML_SUBSTITUTE_REF is not set here.
*/ */
++ctxt->depth;
ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF, ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
0, 0, 0); 0, 0, 0);
--ctxt->depth;
if (orig != NULL) if (orig != NULL)
*orig = buf; *orig = buf;
else else
@ -4092,9 +4114,11 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
} else if ((ent != NULL) && } else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) { (ctxt->replaceEntities != 0)) {
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) { if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
++ctxt->depth;
rep = xmlStringDecodeEntities(ctxt, ent->content, rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, XML_SUBSTITUTE_REF,
0, 0, 0); 0, 0, 0);
--ctxt->depth;
if (rep != NULL) { if (rep != NULL) {
current = rep; current = rep;
while (*current != 0) { /* non input consuming */ while (*current != 0) { /* non input consuming */
@ -4130,8 +4154,10 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
(ent->content != NULL) && (ent->checked == 0)) { (ent->content != NULL) && (ent->checked == 0)) {
unsigned long oldnbent = ctxt->nbentities; unsigned long oldnbent = ctxt->nbentities;
++ctxt->depth;
rep = xmlStringDecodeEntities(ctxt, ent->content, rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, 0, 0, 0); XML_SUBSTITUTE_REF, 0, 0, 0);
--ctxt->depth;
ent->checked = (ctxt->nbentities - oldnbent + 1) * 2; ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
if (rep != NULL) { if (rep != NULL) {
@ -5501,7 +5527,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
skipped = SKIP_BLANKS; skipped = SKIP_BLANKS;
if (skipped == 0) { if (skipped == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after '%'\n"); "Space required after '%%'\n");
} }
isParameter = 1; isParameter = 1;
} }
@ -6686,6 +6712,7 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
if (!IS_BLANK_CH(CUR)) { if (!IS_BLANK_CH(CUR)) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after 'ELEMENT'\n"); "Space required after 'ELEMENT'\n");
return(-1);
} }
SKIP_BLANKS; SKIP_BLANKS;
name = xmlParseName(ctxt); name = xmlParseName(ctxt);
@ -6837,6 +6864,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) { if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL); xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
xmlHaltParser(ctxt);
break; break;
} }
} }
@ -8468,6 +8496,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
*/ */
if (RAW != '>') { if (RAW != '>') {
xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL); xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL);
return;
} }
NEXT; NEXT;
} }
@ -8818,7 +8847,7 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
* @prefix: the prefix to lookup * @prefix: the prefix to lookup
* *
* Lookup the namespace name for the @prefix (which ca be NULL) * Lookup the namespace name for the @prefix (which ca be NULL)
* The prefix must come from the @ctxt->dict dictionnary * The prefix must come from the @ctxt->dict dictionary
* *
* Returns the namespace name or NULL if not bound * Returns the namespace name or NULL if not bound
*/ */
@ -9465,7 +9494,10 @@ reparse:
else else
if (nsPush(ctxt, NULL, URL) > 0) nbNs++; if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
skip_default_ns: skip_default_ns:
if (alloc != 0) xmlFree(attvalue); if ((attvalue != NULL) && (alloc != 0)) {
xmlFree(attvalue);
attvalue = NULL;
}
if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
break; break;
if (!IS_BLANK_CH(RAW)) { if (!IS_BLANK_CH(RAW)) {
@ -9474,6 +9506,8 @@ skip_default_ns:
break; break;
} }
SKIP_BLANKS; SKIP_BLANKS;
if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
goto base_changed;
continue; continue;
} }
if (aprefix == ctxt->str_xmlns) { if (aprefix == ctxt->str_xmlns) {
@ -9545,7 +9579,10 @@ skip_default_ns:
else else
if (nsPush(ctxt, attname, URL) > 0) nbNs++; if (nsPush(ctxt, attname, URL) > 0) nbNs++;
skip_ns: skip_ns:
if (alloc != 0) xmlFree(attvalue); if ((attvalue != NULL) && (alloc != 0)) {
xmlFree(attvalue);
attvalue = NULL;
}
if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>')))) if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
break; break;
if (!IS_BLANK_CH(RAW)) { if (!IS_BLANK_CH(RAW)) {
@ -9816,6 +9853,7 @@ static void
xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
const xmlChar *URI, int line, int nsNr, int tlen) { const xmlChar *URI, int line, int nsNr, int tlen) {
const xmlChar *name; const xmlChar *name;
size_t curLength;
GROW; GROW;
if ((RAW != '<') || (NXT(1) != '/')) { if ((RAW != '<') || (NXT(1) != '/')) {
@ -9824,8 +9862,11 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
} }
SKIP(2); SKIP(2);
if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) { curLength = ctxt->input->end - ctxt->input->cur;
if (ctxt->input->cur[tlen] == '>') { if ((tlen > 0) && (curLength >= (size_t)tlen) &&
(xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
if ((curLength >= (size_t)(tlen + 1)) &&
(ctxt->input->cur[tlen] == '>')) {
ctxt->input->cur += tlen + 1; ctxt->input->cur += tlen + 1;
ctxt->input->col += tlen + 1; ctxt->input->col += tlen + 1;
goto done; goto done;
@ -11209,8 +11250,9 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt,
} }
/** /**
* xmlCheckCdataPush: * xmlCheckCdataPush:
* @cur: pointer to the bock of characters * @cur: pointer to the block of characters
* @len: length of the block in bytes * @len: length of the block in bytes
* @complete: 1 if complete CDATA block is passed in, 0 if partial block
* *
* Check that the block of characters is okay as SCdata content [20] * Check that the block of characters is okay as SCdata content [20]
* *
@ -11218,7 +11260,7 @@ xmlParseGetLasts(xmlParserCtxtPtr ctxt, const xmlChar **lastlt,
* UTF-8 error occured otherwise * UTF-8 error occured otherwise
*/ */
static int static int
xmlCheckCdataPush(const xmlChar *utf, int len) { xmlCheckCdataPush(const xmlChar *utf, int len, int complete) {
int ix; int ix;
unsigned char c; unsigned char c;
int codepoint; int codepoint;
@ -11236,7 +11278,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
else else
return(-ix); return(-ix);
} else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */ } else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */
if (ix + 2 > len) return(-ix); if (ix + 2 > len) return(complete ? -ix : ix);
if ((utf[ix+1] & 0xc0 ) != 0x80) if ((utf[ix+1] & 0xc0 ) != 0x80)
return(-ix); return(-ix);
codepoint = (utf[ix] & 0x1f) << 6; codepoint = (utf[ix] & 0x1f) << 6;
@ -11245,7 +11287,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
return(-ix); return(-ix);
ix += 2; ix += 2;
} else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */ } else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */
if (ix + 3 > len) return(-ix); if (ix + 3 > len) return(complete ? -ix : ix);
if (((utf[ix+1] & 0xc0) != 0x80) || if (((utf[ix+1] & 0xc0) != 0x80) ||
((utf[ix+2] & 0xc0) != 0x80)) ((utf[ix+2] & 0xc0) != 0x80))
return(-ix); return(-ix);
@ -11256,7 +11298,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
return(-ix); return(-ix);
ix += 3; ix += 3;
} else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */ } else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */
if (ix + 4 > len) return(-ix); if (ix + 4 > len) return(complete ? -ix : ix);
if (((utf[ix+1] & 0xc0) != 0x80) || if (((utf[ix+1] & 0xc0) != 0x80) ||
((utf[ix+2] & 0xc0) != 0x80) || ((utf[ix+2] & 0xc0) != 0x80) ||
((utf[ix+3] & 0xc0) != 0x80)) ((utf[ix+3] & 0xc0) != 0x80))
@ -11771,7 +11813,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
int tmp; int tmp;
tmp = xmlCheckCdataPush(ctxt->input->cur, tmp = xmlCheckCdataPush(ctxt->input->cur,
XML_PARSER_BIG_BUFFER_SIZE); XML_PARSER_BIG_BUFFER_SIZE, 0);
if (tmp < 0) { if (tmp < 0) {
tmp = -tmp; tmp = -tmp;
ctxt->input->cur += tmp; ctxt->input->cur += tmp;
@ -11794,7 +11836,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
} else { } else {
int tmp; int tmp;
tmp = xmlCheckCdataPush(ctxt->input->cur, base); tmp = xmlCheckCdataPush(ctxt->input->cur, base, 1);
if ((tmp < 0) || (tmp != base)) { if ((tmp < 0) || (tmp != base)) {
tmp = -tmp; tmp = -tmp;
ctxt->input->cur += tmp; ctxt->input->cur += tmp;
@ -14989,7 +15031,7 @@ xmlCleanupParser(void) {
* DICT_FREE: * DICT_FREE:
* @str: a string * @str: a string
* *
* Free a string if it is not owned by the "dict" dictionnary in the * Free a string if it is not owned by the "dict" dictionary in the
* current scope * current scope
*/ */
#define DICT_FREE(str) \ #define DICT_FREE(str) \

View file

@ -55,6 +55,10 @@
#include <libxml/globals.h> #include <libxml/globals.h>
#include <libxml/chvalid.h> #include <libxml/chvalid.h>
#define CUR(ctxt) ctxt->input->cur
#define END(ctxt) ctxt->input->end
#define VALID_CTXT(ctxt) (CUR(ctxt) <= END(ctxt))
#include "buf.h" #include "buf.h"
#include "enc.h" #include "enc.h"
@ -165,7 +169,7 @@ __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
* *
* Handle an internal error * Handle an internal error
*/ */
static void static void LIBXML_ATTR_FORMAT(2,0)
xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str) xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
{ {
if ((ctxt != NULL) && (ctxt->disableSAX != 0) && if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
@ -193,7 +197,7 @@ xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
* *
* n encoding error * n encoding error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, int val) const char *msg, int val)
{ {
@ -294,7 +298,7 @@ xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUS
*/ */
int int
xmlParserInputGrow(xmlParserInputPtr in, int len) { xmlParserInputGrow(xmlParserInputPtr in, int len) {
size_t ret; int ret;
size_t indx; size_t indx;
const xmlChar *content; const xmlChar *content;
@ -422,103 +426,105 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
(ctxt->input == NULL)) (ctxt->input == NULL))
return; return;
if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { if (!(VALID_CTXT(ctxt))) {
if ((*ctxt->input->cur == 0) && xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0) && ctxt->errNo = XML_ERR_INTERNAL_ERROR;
(ctxt->instate != XML_PARSER_COMMENT)) { xmlStopParser(ctxt);
/* return;
* If we are at the end of the current entity and }
* the context allows it, we pop consumed entities
* automatically. if ((*ctxt->input->cur == 0) &&
* the auto closing should be blocked in other cases (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
*/ if ((ctxt->instate != XML_PARSER_COMMENT))
xmlPopInput(ctxt); xmlPopInput(ctxt);
} else { return;
const unsigned char *cur; }
unsigned char c;
/* if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
* 2.11 End-of-Line Handling const unsigned char *cur;
* the literal two-character sequence "#xD#xA" or a standalone unsigned char c;
* literal #xD, an XML processor must pass to the application
* the single character #xA.
*/
if (*(ctxt->input->cur) == '\n') {
ctxt->input->line++; ctxt->input->col = 1;
} else
ctxt->input->col++;
/* /*
* We are supposed to handle UTF8, check it's valid * 2.11 End-of-Line Handling
* From rfc2044: encoding of the Unicode values on UTF-8: * the literal two-character sequence "#xD#xA" or a standalone
* * literal #xD, an XML processor must pass to the application
* UCS-4 range (hex.) UTF-8 octet sequence (binary) * the single character #xA.
* 0000 0000-0000 007F 0xxxxxxx */
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx if (*(ctxt->input->cur) == '\n') {
* 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx ctxt->input->line++; ctxt->input->col = 1;
* } else
* Check for the 0x110000 limit too ctxt->input->col++;
*/
cur = ctxt->input->cur;
c = *cur; /*
if (c & 0x80) { * We are supposed to handle UTF8, check it's valid
if (c == 0xC0) * From rfc2044: encoding of the Unicode values on UTF-8:
goto encoding_error; *
if (cur[1] == 0) { * UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
* 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
cur = ctxt->input->cur;
c = *cur;
if (c & 0x80) {
if (c == 0xC0)
goto encoding_error;
if (cur[1] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
cur = ctxt->input->cur;
}
if ((cur[1] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xe0) == 0xe0) {
unsigned int val;
if (cur[2] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
cur = ctxt->input->cur; cur = ctxt->input->cur;
} }
if ((cur[1] & 0xc0) != 0x80) if ((cur[2] & 0xc0) != 0x80)
goto encoding_error; goto encoding_error;
if ((c & 0xe0) == 0xe0) { if ((c & 0xf0) == 0xf0) {
unsigned int val; if (cur[3] == 0) {
if (cur[2] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
cur = ctxt->input->cur; cur = ctxt->input->cur;
} }
if ((cur[2] & 0xc0) != 0x80) if (((c & 0xf8) != 0xf0) ||
((cur[3] & 0xc0) != 0x80))
goto encoding_error; goto encoding_error;
if ((c & 0xf0) == 0xf0) { /* 4-byte code */
if (cur[3] == 0) { ctxt->input->cur += 4;
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); val = (cur[0] & 0x7) << 18;
cur = ctxt->input->cur; val |= (cur[1] & 0x3f) << 12;
} val |= (cur[2] & 0x3f) << 6;
if (((c & 0xf8) != 0xf0) || val |= cur[3] & 0x3f;
((cur[3] & 0xc0) != 0x80)) } else {
goto encoding_error; /* 3-byte code */
/* 4-byte code */ ctxt->input->cur += 3;
ctxt->input->cur += 4; val = (cur[0] & 0xf) << 12;
val = (cur[0] & 0x7) << 18; val |= (cur[1] & 0x3f) << 6;
val |= (cur[1] & 0x3f) << 12; val |= cur[2] & 0x3f;
val |= (cur[2] & 0x3f) << 6; }
val |= cur[3] & 0x3f; if (((val > 0xd7ff) && (val < 0xe000)) ||
} else { ((val > 0xfffd) && (val < 0x10000)) ||
/* 3-byte code */ (val >= 0x110000)) {
ctxt->input->cur += 3; xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
val = (cur[0] & 0xf) << 12; "Char 0x%X out of allowed range\n",
val |= (cur[1] & 0x3f) << 6; val);
val |= cur[2] & 0x3f; }
}
if (((val > 0xd7ff) && (val < 0xe000)) ||
((val > 0xfffd) && (val < 0x10000)) ||
(val >= 0x110000)) {
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x%X out of allowed range\n",
val);
}
} else
/* 2-byte code */
ctxt->input->cur += 2;
} else } else
/* 1-byte code */ /* 2-byte code */
ctxt->input->cur++; ctxt->input->cur += 2;
} else
/* 1-byte code */
ctxt->input->cur++;
ctxt->nbChars++; ctxt->nbChars++;
if (*ctxt->input->cur == 0) if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
}
} else { } else {
/* /*
* Assume it's a fixed length encoding (1) with * Assume it's a fixed length encoding (1) with

View file

@ -507,7 +507,7 @@ xmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra)
* *
* Handle a Relax NG Parsing error * Handle a Relax NG Parsing error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error, xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar * str1, const xmlChar * str2) const char *msg, const xmlChar * str1, const xmlChar * str2)
{ {
@ -541,7 +541,7 @@ xmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error,
* *
* Handle a Relax NG Validation error * Handle a Relax NG Validation error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error, xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar * str1, const xmlChar * str2) const char *msg, const xmlChar * str1, const xmlChar * str2)
{ {
@ -2215,7 +2215,8 @@ xmlRelaxNGGetErrorString(xmlRelaxNGValidErr err, const xmlChar * arg1,
snprintf(msg, 1000, "Unknown error code %d\n", err); snprintf(msg, 1000, "Unknown error code %d\n", err);
} }
msg[1000 - 1] = 0; msg[1000 - 1] = 0;
return (xmlStrdup((xmlChar *) msg)); xmlChar *result = xmlCharStrdup(msg);
return (xmlEscapeFormatString(&result));
} }
/** /**

View file

@ -133,7 +133,7 @@ struct _xmlSchematron {
int flags; /* specific to this schematron */ int flags; /* specific to this schematron */
void *_private; /* unused by the library */ void *_private; /* unused by the library */
xmlDictPtr dict; /* the dictionnary used internally */ xmlDictPtr dict; /* the dictionary used internally */
const xmlChar *title; /* the title if any */ const xmlChar *title; /* the title if any */
@ -186,7 +186,7 @@ struct _xmlSchematronParserCtxt {
const char *buffer; const char *buffer;
int size; int size;
xmlDictPtr dict; /* dictionnary for interned string names */ xmlDictPtr dict; /* dictionary for interned string names */
int nberrors; int nberrors;
int err; int err;
@ -245,7 +245,7 @@ xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
* *
* Handle a parser error * Handle a parser error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error, xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar * str1, const xmlChar * str2) const char *msg, const xmlChar * str1, const xmlChar * str2)
{ {

View file

@ -1044,7 +1044,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* DICT_FREE: * DICT_FREE:
* @str: a string * @str: a string
* *
* Free a string if it is not owned by the "dict" dictionnary in the * Free a string if it is not owned by the "dict" dictionary in the
* current scope * current scope
*/ */
#define DICT_FREE(str) \ #define DICT_FREE(str) \
@ -1057,7 +1057,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* DICT_COPY: * DICT_COPY:
* @str: a string * @str: a string
* *
* Copy a string using a "dict" dictionnary in the current scope, * Copy a string using a "dict" dictionary in the current scope,
* if availabe. * if availabe.
*/ */
#define DICT_COPY(str, cpy) \ #define DICT_COPY(str, cpy) \
@ -1074,7 +1074,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* DICT_CONST_COPY: * DICT_CONST_COPY:
* @str: a string * @str: a string
* *
* Copy a string using a "dict" dictionnary in the current scope, * Copy a string using a "dict" dictionary in the current scope,
* if availabe. * if availabe.
*/ */
#define DICT_CONST_COPY(str, cpy) \ #define DICT_CONST_COPY(str, cpy) \
@ -1593,6 +1593,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
else if ((ent != NULL) && (ent->children == NULL)) { else if ((ent != NULL) && (ent->children == NULL)) {
xmlNodePtr temp; xmlNodePtr temp;
ent->children = (xmlNodePtr) -1;
ent->children = xmlStringGetNodeList(doc, ent->children = xmlStringGetNodeList(doc,
(const xmlChar*)node->content); (const xmlChar*)node->content);
ent->owner = 1; ent->owner = 1;
@ -2270,7 +2271,7 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
if (cur == NULL) { if (cur == NULL) {
xmlTreeErrMemory("building node"); xmlTreeErrMemory("building node");
/* we can't check here that name comes from the doc dictionnary */ /* we can't check here that name comes from the doc dictionary */
return(NULL); return(NULL);
} }
memset(cur, 0, sizeof(xmlNode)); memset(cur, 0, sizeof(xmlNode));
@ -2350,7 +2351,7 @@ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
UPDATE_LAST_CHILD_AND_PARENT(cur) UPDATE_LAST_CHILD_AND_PARENT(cur)
} }
} else { } else {
/* if name don't come from the doc dictionnary free it here */ /* if name don't come from the doc dictionary free it here */
if ((name != NULL) && (doc != NULL) && if ((name != NULL) && (doc != NULL) &&
(!(xmlDictOwns(doc->dict, name)))) (!(xmlDictOwns(doc->dict, name))))
xmlFree(name); xmlFree(name);
@ -3701,7 +3702,7 @@ xmlFreeNodeList(xmlNodePtr cur) {
* When a node is a text node or a comment, it uses a global static * When a node is a text node or a comment, it uses a global static
* variable for the name of the node. * variable for the name of the node.
* Otherwise the node name might come from the document's * Otherwise the node name might come from the document's
* dictionnary * dictionary
*/ */
if ((cur->name != NULL) && if ((cur->name != NULL) &&
(cur->type != XML_TEXT_NODE) && (cur->type != XML_TEXT_NODE) &&
@ -3770,7 +3771,7 @@ xmlFreeNode(xmlNodePtr cur) {
/* /*
* When a node is a text node or a comment, it uses a global static * When a node is a text node or a comment, it uses a global static
* variable for the name of the node. * variable for the name of the node.
* Otherwise the node name might come from the document's dictionnary * Otherwise the node name might come from the document's dictionary
*/ */
if ((cur->name != NULL) && if ((cur->name != NULL) &&
(cur->type != XML_TEXT_NODE) && (cur->type != XML_TEXT_NODE) &&

View file

@ -314,7 +314,7 @@ xmlParse3986Query(xmlURIPtr uri, const char **str)
* @uri: pointer to an URI structure * @uri: pointer to an URI structure
* @str: the string to analyze * @str: the string to analyze
* *
* Parse a port part and fills in the appropriate fields * Parse a port part and fills in the appropriate fields
* of the @uri structure * of the @uri structure
* *
* port = *DIGIT * port = *DIGIT
@ -325,15 +325,16 @@ static int
xmlParse3986Port(xmlURIPtr uri, const char **str) xmlParse3986Port(xmlURIPtr uri, const char **str)
{ {
const char *cur = *str; const char *cur = *str;
unsigned port = 0; /* unsigned for defined overflow behavior */
if (ISA_DIGIT(cur)) { if (ISA_DIGIT(cur)) {
if (uri != NULL)
uri->port = 0;
while (ISA_DIGIT(cur)) { while (ISA_DIGIT(cur)) {
if (uri != NULL) port = port * 10 + (*cur - '0');
uri->port = uri->port * 10 + (*cur - '0');
cur++; cur++;
} }
if (uri != NULL)
uri->port = port & INT_MAX; /* port value modulo INT_MAX+1 */
*str = cur; *str = cur;
return(0); return(0);
} }

View file

@ -93,7 +93,7 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
* *
* Handle a validation error * Handle a validation error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error, xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const char *extra) const char *msg, const char *extra)
{ {
@ -137,7 +137,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
* *
* Handle a validation error, provide contextual informations * Handle a validation error, provide contextual informations
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlErrValidNode(xmlValidCtxtPtr ctxt, xmlErrValidNode(xmlValidCtxtPtr ctxt,
xmlNodePtr node, xmlParserErrors error, xmlNodePtr node, xmlParserErrors error,
const char *msg, const xmlChar * str1, const char *msg, const xmlChar * str1,
@ -180,7 +180,7 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt,
* *
* Handle a validation error, provide contextual informations * Handle a validation error, provide contextual informations
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlErrValidNodeNr(xmlValidCtxtPtr ctxt, xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
xmlNodePtr node, xmlParserErrors error, xmlNodePtr node, xmlParserErrors error,
const char *msg, const xmlChar * str1, const char *msg, const xmlChar * str1,
@ -221,7 +221,7 @@ xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
* *
* Handle a validation error, provide contextual information * Handle a validation error, provide contextual information
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlErrValidWarning(xmlValidCtxtPtr ctxt, xmlErrValidWarning(xmlValidCtxtPtr ctxt,
xmlNodePtr node, xmlParserErrors error, xmlNodePtr node, xmlParserErrors error,
const char *msg, const xmlChar * str1, const char *msg, const xmlChar * str1,
@ -2532,7 +2532,7 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
* DICT_FREE: * DICT_FREE:
* @str: a string * @str: a string
* *
* Free a string if it is not owned by the "dict" dictionnary in the * Free a string if it is not owned by the "dict" dictionary in the
* current scope * current scope
*/ */
#define DICT_FREE(str) \ #define DICT_FREE(str) \

View file

@ -125,7 +125,7 @@ xmlXIncludeErrMemory(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node,
* *
* Handle an XInclude error * Handle an XInclude error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar *extra) const char *msg, const xmlChar *extra)
{ {
@ -147,7 +147,7 @@ xmlXIncludeErr(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
* *
* Emit an XInclude warning. * Emit an XInclude warning.
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlXIncludeWarn(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error, xmlXIncludeWarn(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar *extra) const char *msg, const xmlChar *extra)
{ {

View file

@ -1605,7 +1605,7 @@ xmlCreateZMemBuff( int compression ) {
xmlFreeZMemBuff( buff ); xmlFreeZMemBuff( buff );
buff = NULL; buff = NULL;
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlCreateZMemBuff: %s %d\n", "xmlCreateZMemBuff: %s %d\n",
"Error initializing compression context. ZLIB error:", "Error initializing compression context. ZLIB error:",
z_err ); z_err );
xmlIOErr(XML_IO_WRITE, (const char *) msg); xmlIOErr(XML_IO_WRITE, (const char *) msg);
@ -1673,7 +1673,7 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
else { else {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlZMemBuffExtend: %s %lu bytes.\n", "xmlZMemBuffExtend: %s %lu bytes.\n",
"Allocation failure extending output buffer to", "Allocation failure extending output buffer to",
new_size ); new_size );
xmlIOErr(XML_IO_WRITE, (const char *) msg); xmlIOErr(XML_IO_WRITE, (const char *) msg);
@ -1719,7 +1719,7 @@ xmlZMemBuffAppend( xmlZMemBuffPtr buff, const char * src, int len ) {
if ( z_err != Z_OK ) { if ( z_err != Z_OK ) {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlZMemBuffAppend: %s %d %s - %d", "xmlZMemBuffAppend: %s %d %s - %d",
"Compression error while appending", "Compression error while appending",
len, "bytes to buffer. ZLIB error", z_err ); len, "bytes to buffer. ZLIB error", z_err );
xmlIOErr(XML_IO_WRITE, (const char *) msg); xmlIOErr(XML_IO_WRITE, (const char *) msg);
@ -1792,7 +1792,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
else { else {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlZMemBuffGetContent: %s - %d\n", "xmlZMemBuffGetContent: %s - %d\n",
"Error flushing zlib buffers. Error code", z_err ); "Error flushing zlib buffers. Error code", z_err );
xmlIOErr(XML_IO_WRITE, (const char *) msg); xmlIOErr(XML_IO_WRITE, (const char *) msg);
} }
@ -1997,7 +1997,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
if ( len < 0 ) { if ( len < 0 ) {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlIOHTTPWrite: %s\n%s '%s'.\n", "xmlIOHTTPWrite: %s\n%s '%s'.\n",
"Error appending to internal buffer.", "Error appending to internal buffer.",
"Error sending document to URI", "Error sending document to URI",
ctxt->uri ); ctxt->uri );
@ -2069,7 +2069,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
if ( http_content == NULL ) { if ( http_content == NULL ) {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n", "xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n",
"Error retrieving content.\nUnable to", "Error retrieving content.\nUnable to",
http_mthd, "data to URI", ctxt->uri ); http_mthd, "data to URI", ctxt->uri );
xmlIOErr(XML_IO_WRITE, (const char *) msg); xmlIOErr(XML_IO_WRITE, (const char *) msg);
@ -2141,7 +2141,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
else { else {
xmlChar msg[500]; xmlChar msg[500];
xmlStrPrintf(msg, 500, xmlStrPrintf(msg, 500,
(const xmlChar *) "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n", "xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
http_mthd, content_lgth, http_mthd, content_lgth,
"bytes to URI", ctxt->uri, "bytes to URI", ctxt->uri,
"failed. HTTP return code:", http_rtn ); "failed. HTTP return code:", http_rtn );

View file

@ -80,6 +80,7 @@ xmlShellReadline(const char *prompt) {
if (prompt != NULL) if (prompt != NULL)
fprintf(stdout, "%s", prompt); fprintf(stdout, "%s", prompt);
fflush(stdout);
if (!fgets(line_read, 500, stdin)) if (!fgets(line_read, 500, stdin))
return(NULL); return(NULL);
line_read[500] = 0; line_read[500] = 0;

View file

@ -449,7 +449,7 @@ startTimer(void)
* message about the timing performed; format is a printf * message about the timing performed; format is a printf
* type argument * type argument
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
endTimer(const char *fmt, ...) endTimer(const char *fmt, ...)
{ {
long msec; long msec;
@ -485,7 +485,7 @@ startTimer(void)
{ {
begin = clock(); begin = clock();
} }
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
endTimer(const char *fmt, ...) endTimer(const char *fmt, ...)
{ {
long msec; long msec;
@ -514,7 +514,7 @@ startTimer(void)
* Do nothing * Do nothing
*/ */
} }
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(1,2)
endTimer(char *format, ...) endTimer(char *format, ...)
{ {
/* /*
@ -634,7 +634,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
* Display and format an error messages, gives file, line, position and * Display and format an error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlHTMLError(void *ctx, const char *msg, ...) xmlHTMLError(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -671,7 +671,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlHTMLWarning(void *ctx, const char *msg, ...) xmlHTMLWarning(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -709,7 +709,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
* Display and format an validity error messages, gives file, * Display and format an validity error messages, gives file,
* line, position and extra parameters. * line, position and extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlHTMLValidityError(void *ctx, const char *msg, ...) xmlHTMLValidityError(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -746,7 +746,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
* Display and format a validity warning messages, gives file, line, * Display and format a validity warning messages, gives file, line,
* position and extra parameters. * position and extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlHTMLValidityWarning(void *ctx, const char *msg, ...) xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -809,6 +809,7 @@ xmlShellReadline(char *prompt) {
if (prompt != NULL) if (prompt != NULL)
fprintf(stdout, "%s", prompt); fprintf(stdout, "%s", prompt);
fflush(stdout);
if (!fgets(line_read, 500, stdin)) if (!fgets(line_read, 500, stdin))
return(NULL); return(NULL);
line_read[500] = 0; line_read[500] = 0;
@ -1410,7 +1411,7 @@ commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -1433,7 +1434,7 @@ warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
* Display and format a error messages, gives file, line, position and * Display and format a error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -1456,7 +1457,7 @@ errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
* Display and format a fatalError messages, gives file, line, position and * Display and format a fatalError messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -2001,6 +2002,12 @@ static void walkDoc(xmlDocPtr doc) {
xmlNsPtr ns; xmlNsPtr ns;
root = xmlDocGetRootElement(doc); root = xmlDocGetRootElement(doc);
if (root == NULL ) {
xmlGenericError(xmlGenericErrorContext,
"Document does not have a root element");
progresult = XMLLINT_ERR_UNCLASS;
return;
}
for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) { for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) {
namespaces[i++] = ns->href; namespaces[i++] = ns->href;
namespaces[i++] = ns->prefix; namespaces[i++] = ns->prefix;
@ -2967,6 +2974,7 @@ static void showVersion(const char *name) {
if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer "); if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer ");
if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude "); if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude ");
if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv "); if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv ");
if (xmlHasFeature(XML_WITH_ICU)) fprintf(stderr, "ICU ");
if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X "); if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X ");
if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode "); if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode ");
if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps "); if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");

View file

@ -109,6 +109,7 @@ typedef struct memnod {
#define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \ #define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \
/ ALIGN_SIZE ) * ALIGN_SIZE) / ALIGN_SIZE ) * ALIGN_SIZE)
#define MAX_SIZE_T ((size_t)-1)
#define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE)) #define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE))
#define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE)) #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE))
@ -217,7 +218,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
/** /**
* xmlMallocAtomicLoc: * xmlMallocAtomicLoc:
* @size: an int specifying the size in byte to allocate. * @size: an unsigned int specifying the size in byte to allocate.
* @file: the file name or NULL * @file: the file name or NULL
* @line: the line number * @line: the line number
* *
@ -240,11 +241,18 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
TEST_POINT TEST_POINT
if (size > (MAX_SIZE_T - RESERVE_SIZE)) {
xmlGenericError(xmlGenericErrorContext,
"xmlMallocAtomicLoc : Unsigned overflow prevented\n");
xmlMemoryDump();
return(NULL);
}
p = (MEMHDR *) malloc(RESERVE_SIZE+size); p = (MEMHDR *) malloc(RESERVE_SIZE+size);
if (!p) { if (!p) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"xmlMallocLoc : Out of free space\n"); "xmlMallocAtomicLoc : Out of free space\n");
xmlMemoryDump(); xmlMemoryDump();
return(NULL); return(NULL);
} }

View file

@ -142,7 +142,7 @@ struct _xmlTextReader {
xmlNodePtr faketext;/* fake xmlNs chld */ xmlNodePtr faketext;/* fake xmlNs chld */
int preserve;/* preserve the resulting document */ int preserve;/* preserve the resulting document */
xmlBufPtr buffer; /* used to return const xmlChar * */ xmlBufPtr buffer; /* used to return const xmlChar * */
xmlDictPtr dict; /* the context dictionnary */ xmlDictPtr dict; /* the context dictionary */
/* entity stack when traversing entities content */ /* entity stack when traversing entities content */
xmlNodePtr ent; /* Current Entity Ref Node */ xmlNodePtr ent; /* Current Entity Ref Node */
@ -210,7 +210,7 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader);
* DICT_FREE: * DICT_FREE:
* @str: a string * @str: a string
* *
* Free a string if it is not owned by the "dict" dictionnary in the * Free a string if it is not owned by the "dict" dictionary in the
* current scope * current scope
*/ */
#define DICT_FREE(str) \ #define DICT_FREE(str) \
@ -2158,7 +2158,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
ret->ctxt->dictNames = 1; ret->ctxt->dictNames = 1;
ret->allocs = XML_TEXTREADER_CTXT; ret->allocs = XML_TEXTREADER_CTXT;
/* /*
* use the parser dictionnary to allocate all elements and attributes names * use the parser dictionary to allocate all elements and attributes names
*/ */
ret->ctxt->docdict = 1; ret->ctxt->docdict = 1;
ret->dict = ret->ctxt->dict; ret->dict = ret->ctxt->dict;
@ -4050,13 +4050,19 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
} }
#ifdef LIBXML_SCHEMAS_ENABLED #ifdef LIBXML_SCHEMAS_ENABLED
static char *xmlTextReaderBuildMessage(const char *msg, va_list ap); static char *xmlTextReaderBuildMessage(const char *msg, va_list ap) LIBXML_ATTR_FORMAT(1,0);
static void XMLCDECL static void XMLCDECL
xmlTextReaderValidityError(void *ctxt, const char *msg, ...); xmlTextReaderValidityError(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
static void XMLCDECL static void XMLCDECL
xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...); xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
static void XMLCDECL
xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
static void XMLCDECL
xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
static void XMLCDECL static void XMLCDECL
xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...) xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
@ -4850,7 +4856,7 @@ xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
} }
} }
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlTextReaderError(void *ctxt, const char *msg, ...) xmlTextReaderError(void *ctxt, const char *msg, ...)
{ {
va_list ap; va_list ap;
@ -4863,7 +4869,7 @@ xmlTextReaderError(void *ctxt, const char *msg, ...)
} }
static void XMLCDECL static void XMLCDECL LIBXML_ATTR_FORMAT(2,3)
xmlTextReaderWarning(void *ctxt, const char *msg, ...) xmlTextReaderWarning(void *ctxt, const char *msg, ...)
{ {
va_list ap; va_list ap;
@ -5249,7 +5255,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
reader->ctxt->linenumbers = 1; reader->ctxt->linenumbers = 1;
reader->ctxt->dictNames = 1; reader->ctxt->dictNames = 1;
/* /*
* use the parser dictionnary to allocate all elements and attributes names * use the parser dictionary to allocate all elements and attributes names
*/ */
reader->ctxt->docdict = 1; reader->ctxt->docdict = 1;
reader->ctxt->parseMode = XML_PARSE_READER; reader->ctxt->parseMode = XML_PARSE_READER;

View file

@ -1544,6 +1544,7 @@ static int
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from, xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStatePtr to, xmlRegAtomPtr atom) { xmlRegStatePtr to, xmlRegAtomPtr atom) {
xmlRegStatePtr end; xmlRegStatePtr end;
int nullable = 0;
if (atom == NULL) { if (atom == NULL) {
ERROR("genrate transition: atom == NULL"); ERROR("genrate transition: atom == NULL");
@ -1730,6 +1731,13 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
if (xmlRegAtomPush(ctxt, atom) < 0) { if (xmlRegAtomPush(ctxt, atom) < 0) {
return(-1); return(-1);
} }
if ((atom->quant == XML_REGEXP_QUANT_RANGE) &&
(atom->min == 0) && (atom->max > 0)) {
nullable = 1;
atom->min = 1;
if (atom->max == 1)
atom->quant = XML_REGEXP_QUANT_OPT;
}
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1); xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
ctxt->state = end; ctxt->state = end;
switch (atom->quant) { switch (atom->quant) {
@ -1747,11 +1755,8 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1); xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
break; break;
case XML_REGEXP_QUANT_RANGE: case XML_REGEXP_QUANT_RANGE:
#if DV_test if (nullable)
if (atom->min == 0) {
xmlFAGenerateEpsilonTransition(ctxt, from, to); xmlFAGenerateEpsilonTransition(ctxt, from, to);
}
#endif
break; break;
default: default:
break; break;
@ -5052,11 +5057,12 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
ERROR("Expecting the end of a char range"); ERROR("Expecting the end of a char range");
return; return;
} }
NEXTL(len);
/* TODO check that the values are acceptable character ranges for XML */ /* TODO check that the values are acceptable character ranges for XML */
if (end < start) { if (end < start) {
ERROR("End of range is before start of range"); ERROR("End of range is before start of range");
} else { } else {
NEXTL(len);
xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg, xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
XML_REGEXP_CHARVAL, start, end, NULL); XML_REGEXP_CHARVAL, start, end, NULL);
} }
@ -6345,7 +6351,7 @@ struct _xmlExpCtxt {
/** /**
* xmlExpNewCtxt: * xmlExpNewCtxt:
* @maxNodes: the maximum number of nodes * @maxNodes: the maximum number of nodes
* @dict: optional dictionnary to use internally * @dict: optional dictionary to use internally
* *
* Creates a new context for manipulating expressions * Creates a new context for manipulating expressions
* *
@ -7204,7 +7210,7 @@ xmlExpStringDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
return(NULL); return(NULL);
} }
/* /*
* check the string is in the dictionnary, if yes use an interned * check the string is in the dictionary, if yes use an interned
* copy, otherwise we know it's not an acceptable input * copy, otherwise we know it's not an acceptable input
*/ */
input = xmlDictExists(ctxt->dict, str, len); input = xmlDictExists(ctxt->dict, str, len);

View file

@ -2097,8 +2097,8 @@ xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
xmlBufAdd(buf, BAD_CAST "&amp;", 5); xmlBufAdd(buf, BAD_CAST "&amp;", 5);
cur++; cur++;
base = cur; base = cur;
} else if ((*cur >= 0x80) && ((doc == NULL) || } else if ((*cur >= 0x80) && (cur[1] != 0) &&
(doc->encoding == NULL))) { ((doc == NULL) || (doc->encoding == NULL))) {
/* /*
* We assume we have UTF-8 content. * We assume we have UTF-8 content.
*/ */
@ -2121,14 +2121,14 @@ xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
val <<= 6; val <<= 6;
val |= (cur[1]) & 0x3F; val |= (cur[1]) & 0x3F;
l = 2; l = 2;
} else if (*cur < 0xF0) { } else if ((*cur < 0xF0) && (cur [2] != 0)) {
val = (cur[0]) & 0x0F; val = (cur[0]) & 0x0F;
val <<= 6; val <<= 6;
val |= (cur[1]) & 0x3F; val |= (cur[1]) & 0x3F;
val <<= 6; val <<= 6;
val |= (cur[2]) & 0x3F; val |= (cur[2]) & 0x3F;
l = 3; l = 3;
} else if (*cur < 0xF8) { } else if ((*cur < 0xF8) && (cur [2] != 0) && (cur[3] != 0)) {
val = (cur[0]) & 0x07; val = (cur[0]) & 0x07;
val <<= 6; val <<= 6;
val |= (cur[1]) & 0x3F; val |= (cur[1]) & 0x3F;

View file

@ -617,7 +617,7 @@ struct _xmlSchemaParserCtxt {
xmlAutomataStatePtr end; xmlAutomataStatePtr end;
xmlAutomataStatePtr state; xmlAutomataStatePtr state;
xmlDictPtr dict; /* dictionnary for interned string names */ xmlDictPtr dict; /* dictionary for interned string names */
xmlSchemaTypePtr ctxtType; /* The current context simple/complex type */ xmlSchemaTypePtr ctxtType; /* The current context simple/complex type */
int options; int options;
xmlSchemaValidCtxtPtr vctxt; xmlSchemaValidCtxtPtr vctxt;
@ -1085,7 +1085,7 @@ xmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type);
static void static void
xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
const char *funcName, const char *funcName,
const char *message); const char *message) LIBXML_ATTR_FORMAT(3,0);
static int static int
xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr ctxt, xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr ctxt,
xmlSchemaTypePtr type, xmlSchemaTypePtr type,
@ -1769,7 +1769,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
} }
FREE_AND_NULL(str) FREE_AND_NULL(str)
return (*buf); return (xmlEscapeFormatString(buf));
} }
/** /**
@ -1889,7 +1889,7 @@ xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt,
* *
* Handle a parser error * Handle a parser error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
const char *msg, const xmlChar * str1, const xmlChar * str2) const char *msg, const xmlChar * str1, const xmlChar * str2)
{ {
@ -1922,7 +1922,7 @@ xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
* *
* Handle a parser error * Handle a parser error
*/ */
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
xmlNodePtr child, int error, xmlNodePtr child, int error,
const char *msg, const xmlChar * str1, const xmlChar * str2) const char *msg, const xmlChar * str1, const xmlChar * str2)
@ -1951,7 +1951,7 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
* *
* Handle a parser error * Handle a parser error
*/ */
static void static void LIBXML_ATTR_FORMAT(7,0)
xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
const xmlChar * strData1, const xmlChar * strData2, const xmlChar * strData1, const xmlChar * strData2,
const xmlChar * strData3, const char *msg, const xmlChar * str1, const xmlChar * strData3, const char *msg, const xmlChar * str1,
@ -2002,7 +2002,7 @@ xmlSchemaVErrMemory(xmlSchemaValidCtxtPtr ctxt,
extra); extra);
} }
static void static void LIBXML_ATTR_FORMAT(2,0)
xmlSchemaPSimpleInternalErr(xmlNodePtr node, xmlSchemaPSimpleInternalErr(xmlNodePtr node,
const char *msg, const xmlChar *str) const char *msg, const xmlChar *str)
{ {
@ -2013,18 +2013,21 @@ xmlSchemaPSimpleInternalErr(xmlNodePtr node,
#define WXS_ERROR_TYPE_ERROR 1 #define WXS_ERROR_TYPE_ERROR 1
#define WXS_ERROR_TYPE_WARNING 2 #define WXS_ERROR_TYPE_WARNING 2
/** /**
* xmlSchemaErr3: * xmlSchemaErr4Line:
* @ctxt: the validation context * @ctxt: the validation context
* @node: the context node * @errorLevel: the error level
* @error: the error code * @error: the error code
* @node: the context node
* @line: the line number
* @msg: the error message * @msg: the error message
* @str1: extra data * @str1: extra data
* @str2: extra data * @str2: extra data
* @str3: extra data * @str3: extra data
* @str4: extra data
* *
* Handle a validation error * Handle a validation error
*/ */
static void static void LIBXML_ATTR_FORMAT(6,0)
xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
xmlErrorLevel errorLevel, xmlErrorLevel errorLevel,
int error, xmlNodePtr node, int line, const char *msg, int error, xmlNodePtr node, int line, const char *msg,
@ -2139,7 +2142,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
* *
* Handle a validation error * Handle a validation error
*/ */
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
int error, xmlNodePtr node, const char *msg, int error, xmlNodePtr node, const char *msg,
const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) const xmlChar *str1, const xmlChar *str2, const xmlChar *str3)
@ -2148,7 +2151,7 @@ xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
msg, str1, str2, str3, NULL); msg, str1, str2, str3, NULL);
} }
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
int error, xmlNodePtr node, const char *msg, int error, xmlNodePtr node, const char *msg,
const xmlChar *str1, const xmlChar *str2, const xmlChar *str1, const xmlChar *str2,
@ -2158,7 +2161,7 @@ xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
msg, str1, str2, str3, str4); msg, str1, str2, str3, str4);
} }
static void static void LIBXML_ATTR_FORMAT(4,0)
xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt,
int error, xmlNodePtr node, const char *msg, int error, xmlNodePtr node, const char *msg,
const xmlChar *str1, const xmlChar *str2) const xmlChar *str1, const xmlChar *str2)
@ -2181,7 +2184,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
/* /*
* Don't try to format other nodes than element and * Don't try to format other nodes than element and
* attribute nodes. * attribute nodes.
* Play save and return an empty string. * Play safe and return an empty string.
*/ */
*msg = xmlStrdup(BAD_CAST ""); *msg = xmlStrdup(BAD_CAST "");
return(*msg); return(*msg);
@ -2246,6 +2249,13 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
TODO TODO
return (NULL); return (NULL);
} }
/*
* xmlSchemaFormatItemForReport() also returns an escaped format
* string, so do this before calling it below (in the future).
*/
xmlEscapeFormatString(msg);
/* /*
* VAL TODO: The output of the given schema component is currently * VAL TODO: The output of the given schema component is currently
* disabled. * disabled.
@ -2262,7 +2272,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
return (*msg); return (*msg);
} }
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
const char *funcName, const char *funcName,
const char *message, const char *message,
@ -2273,24 +2283,21 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
if (actxt == NULL) if (actxt == NULL)
return; return;
msg = xmlStrdup(BAD_CAST "Internal error: "); msg = xmlStrdup(BAD_CAST "Internal error: %s, ");
msg = xmlStrcat(msg, BAD_CAST funcName);
msg = xmlStrcat(msg, BAD_CAST ", ");
msg = xmlStrcat(msg, BAD_CAST message); msg = xmlStrcat(msg, BAD_CAST message);
msg = xmlStrcat(msg, BAD_CAST ".\n"); msg = xmlStrcat(msg, BAD_CAST ".\n");
if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR)
xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL, xmlSchemaErr3(actxt, XML_SCHEMAV_INTERNAL, NULL,
(const char *) msg, str1, str2); (const char *) msg, (const xmlChar *) funcName, str1, str2);
else if (actxt->type == XML_SCHEMA_CTXT_PARSER) else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL, xmlSchemaErr3(actxt, XML_SCHEMAP_INTERNAL, NULL,
(const char *) msg, str1, str2); (const char *) msg, (const xmlChar *) funcName, str1, str2);
FREE_AND_NULL(msg) FREE_AND_NULL(msg)
} }
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
const char *funcName, const char *funcName,
const char *message) const char *message)
@ -2299,7 +2306,7 @@ xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt,
} }
#if 0 #if 0
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt,
const char *funcName, const char *funcName,
const char *message, const char *message,
@ -2311,7 +2318,7 @@ xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt,
} }
#endif #endif
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -2336,7 +2343,7 @@ xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt,
FREE_AND_NULL(msg) FREE_AND_NULL(msg)
} }
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -2351,7 +2358,7 @@ xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -2376,7 +2383,7 @@ xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt, xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt,
xmlParserErrors error, xmlParserErrors error,
xmlSchemaPSVIIDCNodePtr idcNode, xmlSchemaPSVIIDCNodePtr idcNode,
@ -2476,11 +2483,13 @@ xmlSchemaSimpleTypeErr(xmlSchemaAbstractCtxtPtr actxt,
msg = xmlStrcat(msg, BAD_CAST " '"); msg = xmlStrcat(msg, BAD_CAST " '");
if (type->builtInType != 0) { if (type->builtInType != 0) {
msg = xmlStrcat(msg, BAD_CAST "xs:"); msg = xmlStrcat(msg, BAD_CAST "xs:");
msg = xmlStrcat(msg, type->name); str = xmlStrdup(type->name);
} else } else {
msg = xmlStrcat(msg, const xmlChar *qName = xmlSchemaFormatQName(&str, type->targetNamespace, type->name);
xmlSchemaFormatQName(&str, if (!str)
type->targetNamespace, type->name)); str = xmlStrdup(qName);
}
msg = xmlStrcat(msg, xmlEscapeFormatString(&str));
msg = xmlStrcat(msg, BAD_CAST "'"); msg = xmlStrcat(msg, BAD_CAST "'");
FREE_AND_NULL(str); FREE_AND_NULL(str);
} }
@ -2525,7 +2534,7 @@ xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt,
FREE_AND_NULL(msg) FREE_AND_NULL(msg)
} }
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -2617,7 +2626,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
str = xmlStrcat(str, BAD_CAST ", "); str = xmlStrcat(str, BAD_CAST ", ");
} }
str = xmlStrcat(str, BAD_CAST " ).\n"); str = xmlStrcat(str, BAD_CAST " ).\n");
msg = xmlStrcat(msg, BAD_CAST str); msg = xmlStrcat(msg, xmlEscapeFormatString(&str));
FREE_AND_NULL(str) FREE_AND_NULL(str)
} else } else
msg = xmlStrcat(msg, BAD_CAST "\n"); msg = xmlStrcat(msg, BAD_CAST "\n");
@ -2625,7 +2634,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
xmlFree(msg); xmlFree(msg);
} }
static void static void LIBXML_ATTR_FORMAT(8,0)
xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -2916,7 +2925,7 @@ xmlSchemaPIllegalAttrErr(xmlSchemaParserCtxtPtr ctxt,
* *
* Reports an error during parsing. * Reports an error during parsing.
*/ */
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt,
xmlParserErrors error, xmlParserErrors error,
xmlSchemaBasicItemPtr item, xmlSchemaBasicItemPtr item,
@ -2952,7 +2961,7 @@ xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt,
* *
* Reports an error during parsing. * Reports an error during parsing.
*/ */
static void static void LIBXML_ATTR_FORMAT(5,0)
xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt,
xmlParserErrors error, xmlParserErrors error,
xmlSchemaBasicItemPtr item, xmlSchemaBasicItemPtr item,
@ -2977,7 +2986,7 @@ xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt,
* *
* Reports an attribute use error during parsing. * Reports an attribute use error during parsing.
*/ */
static void static void LIBXML_ATTR_FORMAT(6,0)
xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt,
xmlParserErrors error, xmlParserErrors error,
xmlNodePtr node, xmlNodePtr node,
@ -3099,7 +3108,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt,
* Reports a simple type validation error. * Reports a simple type validation error.
* TODO: Should this report the value of an element as well? * TODO: Should this report the value of an element as well?
*/ */
static void static void LIBXML_ATTR_FORMAT(8,0)
xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
xmlParserErrors error, xmlParserErrors error,
xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED, xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED,
@ -3141,11 +3150,13 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
msg = xmlStrcat(msg, BAD_CAST " '"); msg = xmlStrcat(msg, BAD_CAST " '");
if (type->builtInType != 0) { if (type->builtInType != 0) {
msg = xmlStrcat(msg, BAD_CAST "xs:"); msg = xmlStrcat(msg, BAD_CAST "xs:");
msg = xmlStrcat(msg, type->name); str = xmlStrdup(type->name);
} else } else {
msg = xmlStrcat(msg, const xmlChar *qName = xmlSchemaFormatQName(&str, type->targetNamespace, type->name);
xmlSchemaFormatQName(&str, if (!str)
type->targetNamespace, type->name)); str = xmlStrdup(qName);
}
msg = xmlStrcat(msg, xmlEscapeFormatString(&str));
msg = xmlStrcat(msg, BAD_CAST "'."); msg = xmlStrcat(msg, BAD_CAST "'.");
FREE_AND_NULL(str); FREE_AND_NULL(str);
} }
@ -3158,7 +3169,9 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
} }
if (expected) { if (expected) {
msg = xmlStrcat(msg, BAD_CAST " Expected is '"); msg = xmlStrcat(msg, BAD_CAST " Expected is '");
msg = xmlStrcat(msg, BAD_CAST expected); xmlChar *expectedEscaped = xmlCharStrdup(expected);
msg = xmlStrcat(msg, xmlEscapeFormatString(&expectedEscaped));
FREE_AND_NULL(expectedEscaped);
msg = xmlStrcat(msg, BAD_CAST "'.\n"); msg = xmlStrcat(msg, BAD_CAST "'.\n");
} else } else
msg = xmlStrcat(msg, BAD_CAST "\n"); msg = xmlStrcat(msg, BAD_CAST "\n");
@ -27382,10 +27395,17 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
for (j = 0, i = 0; i < nb_attributes; i++, j += 5) { for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
/* /*
* Duplicate the value. * Duplicate the value, changing any &#38; to a literal ampersand.
*
* libxml2 differs from normal SAX here in that it escapes all ampersands
* as &#38; instead of delivering the raw converted string. Changing the
* behavior at this point would break applications that use this API, so
* we are forced to work around it. There is no danger of accidentally
* decoding some entity other than &#38; in this step because without
* unescaped ampersands there can be no other entities in the string.
*/ */
value = xmlStrndup(attributes[j+3], value = xmlStringLenDecodeEntities(vctxt->parserCtxt, attributes[j+3],
attributes[j+4] - attributes[j+3]); attributes[j+4] - attributes[j+3], XML_SUBSTITUTE_REF, 0, 0, 0);
/* /*
* TODO: Set the node line. * TODO: Set the node line.
*/ */

View file

@ -62,7 +62,7 @@ struct _xmlSchemaValDate {
long year; long year;
unsigned int mon :4; /* 1 <= mon <= 12 */ unsigned int mon :4; /* 1 <= mon <= 12 */
unsigned int day :5; /* 1 <= day <= 31 */ unsigned int day :5; /* 1 <= day <= 31 */
unsigned int hour :5; /* 0 <= hour <= 23 */ unsigned int hour :5; /* 0 <= hour <= 24 */
unsigned int min :6; /* 0 <= min <= 59 */ unsigned int min :6; /* 0 <= min <= 59 */
double sec; double sec;
unsigned int tz_flag :1; /* is tzo explicitely set? */ unsigned int tz_flag :1; /* is tzo explicitely set? */
@ -1139,9 +1139,13 @@ static const unsigned int daysInMonthLeap[12] =
#define VALID_DATE(dt) \ #define VALID_DATE(dt) \
(VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt)) (VALID_YEAR(dt->year) && VALID_MONTH(dt->mon) && VALID_MDAY(dt))
#define VALID_END_OF_DAY(dt) \
((dt)->hour == 24 && (dt)->min == 0 && (dt)->sec == 0)
#define VALID_TIME(dt) \ #define VALID_TIME(dt) \
(VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \ (((VALID_HOUR(dt->hour) && VALID_MIN(dt->min) && \
VALID_SEC(dt->sec) && VALID_TZO(dt->tzo)) VALID_SEC(dt->sec)) || VALID_END_OF_DAY(dt)) && \
VALID_TZO(dt->tzo))
#define VALID_DATETIME(dt) \ #define VALID_DATETIME(dt) \
(VALID_DATE(dt) && VALID_TIME(dt)) (VALID_DATE(dt) && VALID_TIME(dt))
@ -1355,7 +1359,7 @@ _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) {
return ret; return ret;
if (*cur != ':') if (*cur != ':')
return 1; return 1;
if (!VALID_HOUR(value)) if (!VALID_HOUR(value) && value != 24 /* Allow end-of-day hour */)
return 2; return 2;
cur++; cur++;
@ -1377,7 +1381,7 @@ _xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) {
if (ret != 0) if (ret != 0)
return ret; return ret;
if ((!VALID_SEC(dt->sec)) || (!VALID_TZO(dt->tzo))) if (!VALID_TIME(dt))
return 2; return 2;
*str = cur; *str = cur;
@ -5303,6 +5307,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType ws) xmlSchemaWhitespaceValueType ws)
{ {
int ret; int ret;
int stringType;
if (facet == NULL) if (facet == NULL)
return(-1); return(-1);
@ -5315,7 +5320,15 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
*/ */
if (value == NULL) if (value == NULL)
return(-1); return(-1);
ret = xmlRegexpExec(facet->regexp, value); /*
* If string-derived type, regexp must be tested on the value space of
* the datatype.
* See https://www.w3.org/TR/xmlschema-2/#rf-pattern
*/
stringType = val && ((val->type >= XML_SCHEMAS_STRING && val->type <= XML_SCHEMAS_NORMSTRING)
|| (val->type >= XML_SCHEMAS_TOKEN && val->type <= XML_SCHEMAS_NCNAME));
ret = xmlRegexpExec(facet->regexp,
(stringType && val->value.str) ? val->value.str : value);
if (ret == 1) if (ret == 1)
return(0); return(0);
if (ret == 0) if (ret == 0)

View file

@ -457,6 +457,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
return(xmlStrndup(add, len)); return(xmlStrndup(add, len));
size = xmlStrlen(cur); size = xmlStrlen(cur);
if (size < 0)
return(NULL);
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar)); ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
if (ret == NULL) { if (ret == NULL) {
xmlErrMemory(NULL, NULL); xmlErrMemory(NULL, NULL);
@ -484,14 +486,19 @@ xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
int size; int size;
xmlChar *ret; xmlChar *ret;
if (len < 0) if (len < 0) {
len = xmlStrlen(str2); len = xmlStrlen(str2);
if (len < 0)
return(NULL);
}
if ((str2 == NULL) || (len == 0)) if ((str2 == NULL) || (len == 0))
return(xmlStrdup(str1)); return(xmlStrdup(str1));
if (str1 == NULL) if (str1 == NULL)
return(xmlStrndup(str2, len)); return(xmlStrndup(str2, len));
size = xmlStrlen(str1); size = xmlStrlen(str1);
if (size < 0)
return(NULL);
ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar)); ret = (xmlChar *) xmlMalloc((size + len + 1) * sizeof(xmlChar));
if (ret == NULL) { if (ret == NULL) {
xmlErrMemory(NULL, NULL); xmlErrMemory(NULL, NULL);
@ -538,7 +545,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
* Returns the number of characters written to @buf or -1 if an error occurs. * Returns the number of characters written to @buf or -1 if an error occurs.
*/ */
int XMLCDECL int XMLCDECL
xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) { xmlStrPrintf(xmlChar *buf, int len, const char *msg, ...) {
va_list args; va_list args;
int ret; int ret;
@ -566,7 +573,7 @@ xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
* Returns the number of characters written to @buf or -1 if an error occurs. * Returns the number of characters written to @buf or -1 if an error occurs.
*/ */
int int
xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) { xmlStrVPrintf(xmlChar *buf, int len, const char *msg, va_list ap) {
int ret; int ret;
if((buf == NULL) || (msg == NULL)) { if((buf == NULL) || (msg == NULL)) {
@ -837,8 +844,8 @@ xmlUTF8Strsize(const xmlChar *utf, int len) {
break; break;
if ( (ch = *ptr++) & 0x80) if ( (ch = *ptr++) & 0x80)
while ((ch<<=1) & 0x80 ) { while ((ch<<=1) & 0x80 ) {
ptr++;
if (*ptr == 0) break; if (*ptr == 0) break;
ptr++;
} }
} }
return (ptr - utf); return (ptr - utf);
@ -980,5 +987,60 @@ xmlUTF8Strsub(const xmlChar *utf, int start, int len) {
return(xmlUTF8Strndup(utf, len)); return(xmlUTF8Strndup(utf, len));
} }
/**
* xmlEscapeFormatString:
* @msg: a pointer to the string in which to escape '%' characters.
* Must be a heap-allocated buffer created by libxml2 that may be
* returned, or that may be freed and replaced.
*
* Replaces the string pointed to by 'msg' with an escaped string.
* Returns the same string with all '%' characters escaped.
*/
xmlChar *
xmlEscapeFormatString(xmlChar **msg)
{
xmlChar *msgPtr = NULL;
xmlChar *result = NULL;
xmlChar *resultPtr = NULL;
size_t count = 0;
size_t msgLen = 0;
size_t resultLen = 0;
if (!msg || !*msg)
return(NULL);
for (msgPtr = *msg; *msgPtr != '\0'; ++msgPtr) {
++msgLen;
if (*msgPtr == '%')
++count;
}
if (count == 0)
return(*msg);
resultLen = msgLen + count + 1;
result = (xmlChar *) xmlMallocAtomic(resultLen * sizeof(xmlChar));
if (result == NULL) {
/* Clear *msg to prevent format string vulnerabilities in
out-of-memory situations. */
xmlFree(*msg);
*msg = NULL;
xmlErrMemory(NULL, NULL);
return(NULL);
}
for (msgPtr = *msg, resultPtr = result; *msgPtr != '\0'; ++msgPtr, ++resultPtr) {
*resultPtr = *msgPtr;
if (*msgPtr == '%')
*(++resultPtr) = '%';
}
result[resultLen - 1] = '\0';
xmlFree(*msg);
*msg = result;
return *msg;
}
#define bottom_xmlstring #define bottom_xmlstring
#include "elfgcchack.h" #include "elfgcchack.h"

View file

@ -113,7 +113,7 @@ static int xmlTextWriterWriteDocCallback(void *context,
const xmlChar * str, int len); const xmlChar * str, int len);
static int xmlTextWriterCloseDocCallback(void *context); static int xmlTextWriterCloseDocCallback(void *context);
static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr); static xmlChar *xmlTextWriterVSprintf(const char *format, va_list argptr) LIBXML_ATTR_FORMAT(1,0);
static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len, static int xmlOutputBufferWriteBase64(xmlOutputBufferPtr out, int len,
const unsigned char *data); const unsigned char *data);
static void xmlTextWriterStartDocumentCallback(void *ctx); static void xmlTextWriterStartDocumentCallback(void *ctx);
@ -153,7 +153,7 @@ xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error,
* *
* Handle a writer error * Handle a writer error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error, xmlWriterErrMsgInt(xmlTextWriterPtr ctxt, xmlParserErrors error,
const char *msg, int val) const char *msg, int val)
{ {

View file

@ -639,7 +639,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
xmlChar buf[200]; xmlChar buf[200];
xmlStrPrintf(buf, 200, xmlStrPrintf(buf, 200,
BAD_CAST "Memory allocation failed : %s\n", "Memory allocation failed : %s\n",
extra); extra);
ctxt->lastError.message = (char *) xmlStrdup(buf); ctxt->lastError.message = (char *) xmlStrdup(buf);
} else { } else {
@ -945,7 +945,7 @@ struct _xmlXPathCompExpr {
xmlXPathStepOp *steps; /* ops for computation of this expression */ xmlXPathStepOp *steps; /* ops for computation of this expression */
int last; /* index of last step in expression */ int last; /* index of last step in expression */
xmlChar *expr; /* the expression being computed */ xmlChar *expr; /* the expression being computed */
xmlDictPtr dict; /* the dictionnary to use if any */ xmlDictPtr dict; /* the dictionary to use if any */
#ifdef DEBUG_EVAL_COUNTS #ifdef DEBUG_EVAL_COUNTS
int nb; int nb;
xmlChar *string; xmlChar *string;
@ -3706,7 +3706,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
/* @@ with_ns to check whether namespace nodes should be looked at @@ */ /* @@ with_ns to check whether namespace nodes should be looked at @@ */
/* /*
* prevent duplcates * prevent duplicates
*/ */
for (i = 0;i < cur->nodeNr;i++) for (i = 0;i < cur->nodeNr;i++)
if (cur->nodeTab[i] == val) return(0); if (cur->nodeTab[i] == val) return(0);
@ -8390,7 +8390,7 @@ xmlNodePtr
xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) { xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL); if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL); if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL);
if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) { if (cur == NULL) {
if (ctxt->context->tmpNsList != NULL) if (ctxt->context->tmpNsList != NULL)
xmlFree(ctxt->context->tmpNsList); xmlFree(ctxt->context->tmpNsList);
ctxt->context->tmpNsList = ctxt->context->tmpNsList =
@ -9996,7 +9996,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
(c == '[') || (c == ']') || (c == '@') || /* accelerators */ (c == '[') || (c == ']') || (c == '@') || /* accelerators */
(c == '*') || /* accelerators */ (c == '*') || /* accelerators */
(!IS_LETTER(c) && (c != '_') && (!IS_LETTER(c) && (c != '_') &&
((qualified) && (c != ':')))) { ((!qualified) || (c != ':')))) {
return(NULL); return(NULL);
} }
@ -12379,11 +12379,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
STRANGE STRANGE
goto error; goto error;
case NODE_TEST_TYPE: case NODE_TEST_TYPE:
/*
* TODO: Don't we need to use
* xmlXPathNodeSetAddNs() for namespace nodes here?
* Surprisingly, some c14n tests fail, if we do this.
*/
if (type == NODE_TYPE_NODE) { if (type == NODE_TYPE_NODE) {
switch (cur->type) { switch (cur->type) {
case XML_DOCUMENT_NODE: case XML_DOCUMENT_NODE:
@ -12397,9 +12392,17 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
case XML_COMMENT_NODE: case XML_COMMENT_NODE:
case XML_CDATA_SECTION_NODE: case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE: case XML_TEXT_NODE:
case XML_NAMESPACE_DECL:
XP_TEST_HIT XP_TEST_HIT
break; break;
case XML_NAMESPACE_DECL: {
if (axis == AXIS_NAMESPACE) {
XP_TEST_HIT_NS
} else {
hasNsNodes = 1;
XP_TEST_HIT
}
break;
}
default: default:
break; break;
} }
@ -12691,6 +12694,14 @@ error:
* Reset the context node. * Reset the context node.
*/ */
xpctxt->node = oldContextNode; xpctxt->node = oldContextNode;
/*
* When traversing the namespace axis in "toBool" mode, it's
* possible that tmpNsList wasn't freed.
*/
if (xpctxt->tmpNsList != NULL) {
xmlFree(xpctxt->tmpNsList);
xpctxt->tmpNsList = NULL;
}
#ifdef DEBUG_STEP #ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -14784,6 +14795,10 @@ xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
} }
} }
/* OP_VALUE has invalid ch1. */
if (op->op == XPATH_OP_VALUE)
return;
/* Recurse */ /* Recurse */
if (op->ch1 != -1) if (op->ch1 != -1)
xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]); xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]);

View file

@ -85,7 +85,7 @@ xmlXPtrErrMemory(const char *extra)
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
static void static void LIBXML_ATTR_FORMAT(3,0)
xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error, xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
const char * msg, const xmlChar *extra) const char * msg, const xmlChar *extra)
{ {