[LIBXML2] Update to version 2.9.12. CORE-17766

This commit is contained in:
Thomas Faber 2021-09-12 13:24:24 -04:00
parent 271556e6f8
commit 40ee59d609
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
60 changed files with 3385 additions and 2832 deletions

View file

@ -233,7 +233,7 @@ URL: https://github.com/win-iconv/win-iconv
Title: LibXML Title: LibXML
Path: sdk/lib/libxml2 Path: sdk/lib/libxml2
Used Version: 2.9.10 Used Version: 2.9.12
License: MIT (https://spdx.org/licenses/MIT.htmlf) License: MIT (https://spdx.org/licenses/MIT.htmlf)
URL: http://xmlsoft.org, ftp://xmlsoft.org/libxml2/ URL: http://xmlsoft.org, ftp://xmlsoft.org/libxml2/

View file

@ -16,17 +16,19 @@
*/ */
#ifndef __XML_C14N_H__ #ifndef __XML_C14N_H__
#define __XML_C14N_H__ #define __XML_C14N_H__
#include <libxml/xmlversion.h>
#ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
#include <libxml/tree.h>
#include <libxml/xpath.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
/* /*
* XML Canonicalization * XML Canonicalization
* http://www.w3.org/TR/xml-c14n * http://www.w3.org/TR/xml-c14n

View file

@ -79,7 +79,7 @@ struct _xmlParserInput {
/** /**
* xmlParserNodeInfo: * xmlParserNodeInfo:
* *
* The parser can be asked to collect Node informations, i.e. at what * The parser can be asked to collect Node information, i.e. at what
* place in the file they were detected. * place in the file they were detected.
* NOTE: This is off by default and not very well tested. * NOTE: This is off by default and not very well tested.
*/ */
@ -169,6 +169,8 @@ typedef enum {
XML_PARSE_READER = 5 XML_PARSE_READER = 5
} xmlParserMode; } xmlParserMode;
typedef struct _xmlStartTag xmlStartTag;
/** /**
* xmlParserCtxt: * xmlParserCtxt:
* *
@ -231,7 +233,7 @@ struct _xmlParserCtxt {
int nameMax; /* Max depth of the parsing stack */ int nameMax; /* Max depth of the parsing stack */
const xmlChar * *nameTab; /* array of nodes */ const xmlChar * *nameTab; /* array of nodes */
long nbChars; /* number of xmlChar processed */ long nbChars; /* unused */
long checkIndex; /* used by progressive parsing lookup */ long checkIndex; /* used by progressive parsing lookup */
int keepBlanks; /* ugly but ... */ int keepBlanks; /* ugly but ... */
int disableSAX; /* SAX callbacks are disabled */ int disableSAX; /* SAX callbacks are disabled */
@ -280,7 +282,7 @@ struct _xmlParserCtxt {
int nsMax; /* the size of the arrays */ int nsMax; /* the size of the arrays */
const xmlChar * *nsTab; /* the array of prefix/namespace name */ const xmlChar * *nsTab; /* the array of prefix/namespace name */
int *attallocs; /* which attribute were allocated */ int *attallocs; /* which attribute were allocated */
void * *pushTab; /* array of data for push */ xmlStartTag *pushTab; /* array of data for push */
xmlHashTablePtr attsDefault; /* defaulted attributes if any */ xmlHashTablePtr attsDefault; /* defaulted attributes if any */
xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
int nsWellFormed; /* is the document XML Namespace okay */ int nsWellFormed; /* is the document XML Namespace okay */
@ -296,7 +298,7 @@ struct _xmlParserCtxt {
xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
/* /*
* the complete error informations for the last error. * the complete error information for the last error.
*/ */
xmlError lastError; xmlError lastError;
xmlParserMode parseMode; /* the parser mode */ xmlParserMode parseMode; /* the parser mode */
@ -329,7 +331,7 @@ struct _xmlSAXLocator {
* xmlSAXHandler: * xmlSAXHandler:
* *
* A SAX handler is bunch of callbacks called by the parser when processing * A SAX handler is bunch of callbacks called by the parser when processing
* of the input generate data or structure informations. * of the input generate data or structure information.
*/ */
/** /**
@ -685,7 +687,7 @@ typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
* attribute values. * attribute values.
* *
* SAX2 callback when an element start has been detected by the parser. * SAX2 callback when an element start has been detected by the parser.
* It provides the namespace informations for the element, as well as * It provides the namespace information for the element, as well as
* the new namespace declarations on the element. * the new namespace declarations on the element.
*/ */
@ -707,7 +709,7 @@ typedef void (*startElementNsSAX2Func) (void *ctx,
* @URI: the element namespace name if available * @URI: the element namespace name if available
* *
* SAX2 callback when an element end has been detected by the parser. * SAX2 callback when an element end has been detected by the parser.
* It provides the namespace informations for the element. * It provides the namespace information for the element.
*/ */
typedef void (*endElementNsSAX2Func) (void *ctx, typedef void (*endElementNsSAX2Func) (void *ctx,

View file

@ -443,7 +443,7 @@ struct _xmlAttr {
struct _xmlDoc *doc; /* the containing document */ struct _xmlDoc *doc; /* the containing document */
xmlNs *ns; /* pointer to the associated namespace */ xmlNs *ns; /* pointer to the associated namespace */
xmlAttributeType atype; /* the attribute type if validating */ xmlAttributeType atype; /* the attribute type if validating */
void *psvi; /* for type/PSVI informations */ void *psvi; /* for type/PSVI information */
}; };
/** /**
@ -502,7 +502,7 @@ struct _xmlNode {
xmlChar *content; /* the content */ xmlChar *content; /* the content */
struct _xmlAttr *properties;/* properties list */ struct _xmlAttr *properties;/* properties list */
xmlNs *nsDef; /* namespace definitions on this node */ xmlNs *nsDef; /* namespace definitions on this node */
void *psvi; /* for type/PSVI informations */ void *psvi; /* for type/PSVI information */
unsigned short line; /* line number */ unsigned short line; /* line number */
unsigned short extra; /* extra data for XPath/XSLT */ unsigned short extra; /* extra data for XPath/XSLT */
}; };
@ -578,7 +578,7 @@ struct _xmlDoc {
int charset; /* Internal flag for charset handling, int charset; /* Internal flag for charset handling,
actually an xmlCharEncoding */ actually an xmlCharEncoding */
struct _xmlDict *dict; /* dict used to allocate names or NULL */ struct _xmlDict *dict; /* dict used to allocate names or NULL */
void *psvi; /* for type/PSVI informations */ void *psvi; /* for type/PSVI information */
int parseFlags; /* set of xmlParserOption used to parse the int parseFlags; /* set of xmlParserOption used to parse the
document */ document */
int properties; /* set of xmlDocProperties for this document int properties; /* set of xmlDocProperties for this document

View file

@ -217,6 +217,8 @@ xmlParserInputBufferPtr
*/ */
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlCleanupOutputCallbacks (void); xmlCleanupOutputCallbacks (void);
XMLPUBFUN int XMLCALL
xmlPopOutputCallbacks (void);
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlRegisterDefaultOutputCallbacks(void); xmlRegisterDefaultOutputCallbacks(void);
XMLPUBFUN xmlOutputBufferPtr XMLCALL XMLPUBFUN xmlOutputBufferPtr XMLCALL

View file

@ -3,43 +3,46 @@
* Description: macros for marking symbols as exportable/importable. * Description: macros for marking symbols as exportable/importable.
* *
* Copy: See Copyright for the status of this software. * Copy: See Copyright for the status of this software.
*
* Author: Igor Zlatovic <igor@zlatkovic.com>
*/ */
#ifndef __XML_EXPORTS_H__ #ifndef __XML_EXPORTS_H__
#define __XML_EXPORTS_H__ #define __XML_EXPORTS_H__
/** #if defined(_WIN32) || defined(__CYGWIN__)
* XMLPUBFUN, XMLPUBVAR, XMLCALL /** DOC_DISABLE */
*
* Macros which declare an exportable function, an exportable variable and #ifdef LIBXML_STATIC
* the calling convention used for functions. #define XMLPUBLIC
* #elif defined(IN_LIBXML)
* Please use an extra block for every platform/compiler combination when #define XMLPUBLIC __declspec(dllexport)
* modifying this, rather than overlong #ifdef lines. This helps #else
* readability as well as the fact that different compilers on the same #define XMLPUBLIC __declspec(dllimport)
* platform might need different definitions. #endif
*/
#if defined(LIBXML_FASTCALL)
#define XMLCALL __fastcall
#else
#define XMLCALL __cdecl
#endif
#define XMLCDECL __cdecl
/** DOC_ENABLE */
#else /* not Windows */
/** /**
* XMLPUBFUN: * XMLPUBLIC:
* *
* Macros which declare an exportable function * Macro which declares a public symbol
*/ */
#define XMLPUBFUN #define XMLPUBLIC
/**
* XMLPUBVAR:
*
* Macros which declare an exportable variable
*/
#define XMLPUBVAR extern
/** /**
* XMLCALL: * XMLCALL:
* *
* Macros which declare the called convention for exported functions * Macro which declares the calling convention for exported functions
*/ */
#define XMLCALL #define XMLCALL
/** /**
* XMLCDECL: * XMLCDECL:
* *
@ -48,100 +51,21 @@
*/ */
#define XMLCDECL #define XMLCDECL
/** DOC_DISABLE */ #endif /* platform switch */
/* Windows platform with MS compiler */ /*
#if defined(_WIN32) && defined(_MSC_VER) * XMLPUBFUN:
#undef XMLPUBFUN *
#undef XMLPUBVAR * Macro which declares an exportable function
#undef XMLCALL */
#undef XMLCDECL #define XMLPUBFUN XMLPUBLIC
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
#define XMLPUBVAR __declspec(dllexport)
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
#define XMLPUBVAR __declspec(dllimport) extern
#else
#define XMLPUBVAR extern
#endif
#endif
#if defined(LIBXML_FASTCALL)
#define XMLCALL __fastcall
#else
#define XMLCALL __cdecl
#endif
#define XMLCDECL __cdecl
#endif
/* Windows platform with Borland compiler */ /**
#if defined(_WIN32) && defined(__BORLANDC__) * XMLPUBVAR:
#undef XMLPUBFUN *
#undef XMLPUBVAR * Macro which declares an exportable variable
#undef XMLCALL */
#undef XMLCDECL #define XMLPUBVAR XMLPUBLIC extern
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
#define XMLPUBVAR __declspec(dllexport) extern
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
#define XMLPUBVAR __declspec(dllimport) extern
#else
#define XMLPUBVAR extern
#endif
#endif
#define XMLCALL __cdecl
#define XMLCDECL __cdecl
#endif
/* Windows platform with GNU compiler (Mingw) */
#if defined(_WIN32) && defined(__MINGW32__)
#undef XMLPUBFUN
#undef XMLPUBVAR
#undef XMLCALL
#undef XMLCDECL
/*
* if defined(IN_LIBXML) this raises problems on mingw with msys
* _imp__xmlFree listed as missing. Try to workaround the problem
* by also making that declaration when compiling client code.
*/
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
#define XMLPUBVAR __declspec(dllexport) extern
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
#define XMLPUBVAR __declspec(dllimport) extern
#else
#define XMLPUBVAR extern
#endif
#endif
#define XMLCALL __cdecl
#define XMLCDECL __cdecl
#endif
/* Cygwin platform (does not define _WIN32), GNU compiler */
#if defined(__CYGWIN__)
#undef XMLPUBFUN
#undef XMLPUBVAR
#undef XMLCALL
#undef XMLCDECL
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
#define XMLPUBVAR __declspec(dllexport)
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
#define XMLPUBVAR __declspec(dllimport) extern
#else
#define XMLPUBVAR extern
#endif
#endif
#define XMLCALL __cdecl
#define XMLCDECL __cdecl
#endif
/* Compatibility */ /* Compatibility */
#if !defined(LIBXML_DLL_IMPORT) #if !defined(LIBXML_DLL_IMPORT)

View file

@ -122,7 +122,7 @@ typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
* @line: returned line information * @line: returned line information
* *
* A schemas validation locator, a callback called by the validator. * A schemas validation locator, a callback called by the validator.
* This is used when file or node informations are not available * This is used when file or node information are not available
* to find out what file and line number are affected * to find out what file and line number are affected
* *
* Returns: 0 in case of success and -1 in case of error * Returns: 0 in case of success and -1 in case of error

View file

@ -1,6 +1,6 @@
/* /*
* Summary: compile-time version informations * Summary: compile-time version information
* Description: compile-time version informations for the XML library * Description: compile-time version information for the XML library
* *
* Copy: See Copyright for the status of this software. * Copy: See Copyright for the status of this software.
* *
@ -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.10" #define LIBXML_DOTTED_VERSION "2.9.12"
/** /**
* 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 20910 #define LIBXML_VERSION 20912
/** /**
* 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 "20910" #define LIBXML_VERSION_STRING "20912"
/** /**
* 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 "-GITv2.9.10-rc1-2-ga5bb6aaa2" #define LIBXML_VERSION_EXTRA "-GITv2.9.11"
/** /**
* 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(20910); #define LIBXML_TEST_VERSION xmlCheckVersion(20912);
#ifndef VMS #ifndef VMS
#if 0 #if 0

View file

@ -1,6 +1,6 @@
/* /*
* Summary: compile-time version informations * Summary: compile-time version information
* Description: compile-time version informations for the XML library * Description: compile-time version information for the XML library
* *
* Copy: See Copyright for the status of this software. * Copy: See Copyright for the status of this software.
* *

View file

@ -359,8 +359,6 @@ struct _xmlXPathContext {
unsigned long opLimit; unsigned long opLimit;
unsigned long opCount; unsigned long opCount;
int depth; int depth;
int maxDepth;
int maxParserDepth;
}; };
/* /*
@ -373,7 +371,7 @@ typedef xmlXPathCompExpr *xmlXPathCompExprPtr;
/** /**
* xmlXPathParserContext: * xmlXPathParserContext:
* *
* An XPath parser context. It contains pure parsing informations, * An XPath parser context. It contains pure parsing information,
* an xmlXPathContext, and the stack of objects. * an xmlXPathContext, and the stack of objects.
*/ */
struct _xmlXPathParserContext { struct _xmlXPathParserContext {

View file

@ -379,7 +379,7 @@ Tue Aug 26 09:42:08 CEST 2008 Daniel Veillard <daniel@veillard.com>
* test/schemas/regexp-char-ref_0.xml test/schemas/regexp-char-ref_0.xsd * test/schemas/regexp-char-ref_0.xml test/schemas/regexp-char-ref_0.xsd
test/schemas/regexp-char-ref_1.xsd result/schemas/regexp-char-ref_0_0 test/schemas/regexp-char-ref_1.xsd result/schemas/regexp-char-ref_0_0
result/schemas/regexp-char-ref_1_0: Volker Grabsch also provided result/schemas/regexp-char-ref_1_0: Volker Grabsch also provided
regession tests for this regression tests for this
Tue Aug 26 09:25:39 CEST 2008 Daniel Veillard <daniel@veillard.com> Tue Aug 26 09:25:39 CEST 2008 Daniel Veillard <daniel@veillard.com>
@ -475,7 +475,7 @@ Thu Jul 31 10:15:53 CEST 2008 Daniel Veillard <daniel@veillard.com>
* include/libxml/xmlerror.h parser.c: clean up namespace errors * include/libxml/xmlerror.h parser.c: clean up namespace errors
checking and reporting, errors when a document is labelled checking and reporting, errors when a document is labelled
as UTF-16 while it is parsed as UTF-8 and no encoding was given as UTF-16 while it is parsed as UTF-8 and no encoding was given
explicitely. explicitly.
* result/errors/webdav.xml.*: some warnings are no recategorized * result/errors/webdav.xml.*: some warnings are no recategorized
as Namespace errors as Namespace errors
@ -663,7 +663,7 @@ Thu Apr 3 11:44:57 CEST 2008 Daniel Veillard <daniel@veillard.com>
Thu Apr 3 11:02:02 CEST 2008 Daniel Veillard <daniel@veillard.com> Thu Apr 3 11:02:02 CEST 2008 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: apparently it's okay to forget the semicolumn after * HTMLparser.c: apparently it's okay to forget the semicolon after
entity refs in HTML, fixing char refs parsing accordingly based on entity refs in HTML, fixing char refs parsing accordingly based on
T. Manske patch, this should fix #517653 T. Manske patch, this should fix #517653
@ -787,7 +787,7 @@ Wed Mar 12 18:56:22 CET 2008 Daniel Veillard <daniel@veillard.com>
Wed Mar 12 10:22:01 CET 2008 Daniel Veillard <daniel@veillard.com> Wed Mar 12 10:22:01 CET 2008 Daniel Veillard <daniel@veillard.com>
* python/types.c: fix a memory errro when using namespace nodes * python/types.c: fix a memory error when using namespace nodes
returned from XPath queries, should fix #521699 returned from XPath queries, should fix #521699
* python/tests/Makefile.am python/tests/xpathns.py: add a specific * python/tests/Makefile.am python/tests/xpathns.py: add a specific
regression test for it regression test for it
@ -917,7 +917,7 @@ Fri Jan 25 20:01:42 CET 2007 Rob Richards <rrichards@ctindustries.net>
Thu Jan 24 15:37:04 CET 2008 Daniel Veillard <daniel@veillard.com> Thu Jan 24 15:37:04 CET 2008 Daniel Veillard <daniel@veillard.com>
* parser.c: fix a memeory leak in internal subset parsing with * parser.c: fix a memory leak in internal subset parsing with
a fix from Ashwin a fix from Ashwin
* test/errors/content1.xml result/errors/content1.xml*: * test/errors/content1.xml result/errors/content1.xml*:
add test to regressions add test to regressions
@ -1230,7 +1230,7 @@ Thu May 10 01:52:42 CEST 2007 Daniel Veillard <daniel@veillard.com>
* list.c: applied patch to fix xmlListAppend() from * list.c: applied patch to fix xmlListAppend() from
Georges-André SILBER Georges-André SILBER
* valid.c: also fix the place wher it was called. * valid.c: also fix the place where it was called.
Wed May 2 18:47:33 CEST 2007 Daniel Veillard <daniel@veillard.com> Wed May 2 18:47:33 CEST 2007 Daniel Veillard <daniel@veillard.com>
@ -1424,7 +1424,7 @@ Thu Jan 4 18:27:49 CET 2007 Daniel Veillard <daniel@veillard.com>
test/relaxng/empty1_0.xml test/relaxng/comps.rng test/relaxng/empty1_0.xml test/relaxng/comps.rng
test/relaxng/empty0.rng test/relaxng/empty0_0.xml test/relaxng/empty0.rng test/relaxng/empty0_0.xml
test/relaxng/empty1_1.xml: tests which were apparently test/relaxng/empty1_1.xml: tests which were apparently
never commited to CVS never committed to CVS
Wed Jan 3 16:05:21 PST 2007 Aleksey Sanin <aleksey@aleksey.com> Wed Jan 3 16:05:21 PST 2007 Aleksey Sanin <aleksey@aleksey.com>
@ -1531,7 +1531,7 @@ Tue Oct 17 18:12:34 CEST 2006 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: fixing HTML minimized attribute values to be generated * HTMLparser.c: fixing HTML minimized attribute values to be generated
internally if not present, fixes bug #332124 internally if not present, fixes bug #332124
* result/HTML/doc2.htm.sax result/HTML/doc3.htm.sax * result/HTML/doc2.htm.sax result/HTML/doc3.htm.sax
result/HTML/wired.html.sax: this affects the SAX event strem for result/HTML/wired.html.sax: this affects the SAX event stream for
a few test cases a few test cases
Tue Oct 17 17:56:31 CEST 2006 Daniel Veillard <daniel@veillard.com> Tue Oct 17 17:56:31 CEST 2006 Daniel Veillard <daniel@veillard.com>
@ -1627,7 +1627,7 @@ Wed Oct 11 23:11:58 CEST 2006 Daniel Veillard <daniel@veillard.com>
Wed Oct 11 18:40:00 CEST 2006 Daniel Veillard <daniel@veillard.com> Wed Oct 11 18:40:00 CEST 2006 Daniel Veillard <daniel@veillard.com>
* valid.c: fixed a weird error where validity context whould not * valid.c: fixed a weird error where validity context would not
show up if warnings were disabled pointed out by Bob Stayton show up if warnings were disabled pointed out by Bob Stayton
* xmlIO.c doc/generator.py: cleanup and fix to regenerate the docs * xmlIO.c doc/generator.py: cleanup and fix to regenerate the docs
* doc//* testapi.c: rebuilt the docs * doc//* testapi.c: rebuilt the docs
@ -1740,7 +1740,7 @@ Thu Aug 17 00:48:31 CEST 2006 Rob Richards <rrichards@ctindustries.net>
Wed Aug 16 01:15:12 CEST 2006 Rob Richards <rrichards@ctindustries.net> Wed Aug 16 01:15:12 CEST 2006 Rob Richards <rrichards@ctindustries.net>
* HTMLtree.c xmlsave.c: Add linefeeds to error messages allowing * HTMLtree.c xmlsave.c: Add linefeeds to error messages allowing
for consistant handling. for consistent handling.
Tue Aug 15 15:02:18 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net> Tue Aug 15 15:02:18 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
@ -1857,7 +1857,7 @@ Mon Jun 26 16:22:50 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
initialized to zero here; this could lead to the activation initialized to zero here; this could lead to the activation
of the axis rewrite code in xmlXPathNodeCollectAndTest() when of the axis rewrite code in xmlXPathNodeCollectAndTest() when
@rewriteType is randomly set to the value 1. A test @rewriteType is randomly set to the value 1. A test
(hardcoding the intial value to 1) revealed that the (hardcoding the initial value to 1) revealed that the
resulting incorrect behaviour is similar to the behaviour resulting incorrect behaviour is similar to the behaviour
as described by Arnold Hendriks on the mailing list; so I as described by Arnold Hendriks on the mailing list; so I
hope that will fix the issue. hope that will fix the issue.
@ -1912,7 +1912,7 @@ Fri Jun 16 21:37:44 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
for my custom handling of ns-references in my DOM wrapper. for my custom handling of ns-references in my DOM wrapper.
Substituted code which created the XML namespace decl on Substituted code which created the XML namespace decl on
the doc for a call to xmlTreeEnsureXMLDecl(). Removed the doc for a call to xmlTreeEnsureXMLDecl(). Removed
those nastly "warnigns" from the docs of the clone/adopt those nasty "warnings" from the docs of the clone/adopt
functions; they work fine on my side. functions; they work fine on my side.
Mon Jun 12 13:23:11 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net> Mon Jun 12 13:23:11 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
@ -2033,7 +2033,7 @@ Tue May 30 11:21:34 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
Mon May 29 18:06:17 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net> Mon May 29 18:06:17 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xpath.c include/libxml/xpath.h: Added an XPath object cache. * xpath.c include/libxml/xpath.h: Added an XPath object cache.
It sits on an xmlXPathContext and need to be explicitely It sits on an xmlXPathContext and need to be explicitly
activated (or deactivated again) with activated (or deactivated again) with
xmlXPathContextSetObjectCache(). The cache consists of 5 xmlXPathContextSetObjectCache(). The cache consists of 5
lists for node-set, string, number, boolean and misc XPath lists for node-set, string, number, boolean and misc XPath
@ -2052,7 +2052,7 @@ Wed May 24 10:54:25 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xpath.c: Removed a memcpy if xmlXPathNodeSetMerge(); it * xpath.c: Removed a memcpy if xmlXPathNodeSetMerge(); it
seems we really need to walk the whole list, since those seems we really need to walk the whole list, since those
nastly namespace nodes need to be added with nasty namespace nodes need to be added with
xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible. xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible.
A flag on the node-set indicating if namespace nodes are in A flag on the node-set indicating if namespace nodes are in
the set would help here; this is the 3rd flag which would the set would help here; this is the 3rd flag which would
@ -2063,7 +2063,7 @@ Wed May 24 10:54:25 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
2) Of what type are the nodes in the set (or of mixed type)? 2) Of what type are the nodes in the set (or of mixed type)?
This would allow for faster merging of node-sets. This would allow for faster merging of node-sets.
3) Are namespace nodes in the set? 3) Are namespace nodes in the set?
This would allow to skipp all the namespace node specific This would allow to skip all the namespace node specific
special handling. Faster node-set merging if the first special handling. Faster node-set merging if the first
set is empty; just memcpy the set. set is empty; just memcpy the set.
@ -2485,7 +2485,7 @@ Mon Jan 9 15:33:16 CET 2006 Daniel Veillard <daniel@veillard.com>
Thu Jan 5 16:25:06 CET 2006 Daniel Veillard <daniel@veillard.com> Thu Jan 5 16:25:06 CET 2006 Daniel Veillard <daniel@veillard.com>
* NEWS configure.in libxml.spec.in testapi.c doc/*: upated the news * NEWS configure.in libxml.spec.in testapi.c doc/*: updated the news
regenerated the docs, preparing for release of 2.6.23 regenerated the docs, preparing for release of 2.6.23
* pattern.c xmlschemas.c: fixed some comments * pattern.c xmlschemas.c: fixed some comments
@ -2520,7 +2520,7 @@ Wed Jan 4 18:07:47 CET 2006 Daniel Veillard <daniel@veillard.com>
Wed Jan 4 15:00:51 CET 2006 Daniel Veillard <daniel@veillard.com> Wed Jan 4 15:00:51 CET 2006 Daniel Veillard <daniel@veillard.com>
* SAX2.c: fix bug #324432 with <xml:foo/> * SAX2.c: fix bug #324432 with <xml:foo/>
* test/ns7 resul//ns7*: added to the regression tests * test/ns7 result/ns7*: added to the regression tests
Wed Jan 4 10:53:56 CET 2006 Daniel Veillard <daniel@veillard.com> Wed Jan 4 10:53:56 CET 2006 Daniel Veillard <daniel@veillard.com>
@ -2861,7 +2861,7 @@ Fri Oct 21 10:50:14 EDT 2005 Rob Richards <rrichards@ctindustries.net>
Wed Oct 19 16:53:47 BST 2005 Daniel Veillard <daniel@veillard.com> Wed Oct 19 16:53:47 BST 2005 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: commiting a some fixes and debug done yesterday in * xmlregexp.c: committing a some fixes and debug done yesterday in
the London airport. the London airport.
Thu Oct 20 12:54:23 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net> Thu Oct 20 12:54:23 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
@ -2932,7 +2932,7 @@ Fri Oct 14 16:21:22 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
Allowed IDCs to resolve also to nodes of complex type with Allowed IDCs to resolve also to nodes of complex type with
simple content. simple content.
Added check for keyrefs with references to keyrefs. Added check for keyrefs with references to keyrefs.
IDC target-nodes were interferring with IDC node-tables, IDC target-nodes were interfering with IDC node-tables,
since they used one list of entries only. I separated this since they used one list of entries only. I separated this
one big list into 3 lists: 1 for IDC node-table entries, one big list into 3 lists: 1 for IDC node-table entries,
1 for _duplicates_ of IDC node-table entries and 1 for 1 for _duplicates_ of IDC node-table entries and 1 for
@ -3053,7 +3053,7 @@ Mon Sep 12 21:00:53 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c include/libxml/schemasInternals.h * xmlschemas.c include/libxml/schemasInternals.h
include/libxml/xmlerror.h: Completion of the schema graph. include/libxml/xmlerror.h: Completion of the schema graph.
Centralisation, more robustness of the schema document Centralisation, more robustness of the schema document
aquisition story. Centralised and restructured component fixup. acquisition story. Centralised and restructured component fixup.
Fixed attribute derivation when 'prohibiting' attribute uses. Fixed attribute derivation when 'prohibiting' attribute uses.
Added warnings: when schema documents cannot be localized Added warnings: when schema documents cannot be localized
during imports; when we get duplicate and pointless attribute during imports; when we get duplicate and pointless attribute
@ -3385,7 +3385,7 @@ Wed Aug 10 18:21:41 CEST 2005 Daniel Veillard <daniel@veillard.com>
list values. list values.
* test/relaxng/307377* result/relaxng/307377* Makefile.am runtest.c: * test/relaxng/307377* result/relaxng/307377* Makefile.am runtest.c:
added examples to the regression tests, problem is that streaming added examples to the regression tests, problem is that streaming
version gives slightly more informations. version gives slightly more information.
Wed Aug 10 15:25:53 CEST 2005 Daniel Veillard <daniel@veillard.com> Wed Aug 10 15:25:53 CEST 2005 Daniel Veillard <daniel@veillard.com>
@ -3398,7 +3398,7 @@ Wed Aug 10 11:59:46 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
Tue Aug 9 23:37:22 CEST 2005 Daniel Veillard <daniel@veillard.com> Tue Aug 9 23:37:22 CEST 2005 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: fixed a determinism detection problem exposed by * xmlregexp.c: fixed a determinism detection problem exposed by
##other tests commited by Kasimier, also added a small speedup ##other tests committed by Kasimier, also added a small speedup
of determinism detection. of determinism detection.
* test/results/any6_2_0* any8_1_0* any7_1_2* any7_2_2*: added * test/results/any6_2_0* any8_1_0* any7_1_2* any7_2_2*: added
the results to the regression tests now the results to the regression tests now
@ -3424,7 +3424,7 @@ Tue Aug 9 13:07:27 CEST 2005 Daniel Veillard <daniel@veillard.com>
* result/schemas/any7* test/schemas/any7: completed the tests * result/schemas/any7* test/schemas/any7: completed the tests
and added the results and added the results
* result/schemas/any3_0_0.err result/schemas/any5_0_0.err * result/schemas/any3_0_0.err result/schemas/any5_0_0.err
result/schemas/any5_1_0.err: this slightly chnages the output result/schemas/any5_1_0.err: this slightly changes the output
from 3 existing tests from 3 existing tests
Mon Aug 8 22:33:08 CEST 2005 Daniel Veillard <daniel@veillard.com> Mon Aug 8 22:33:08 CEST 2005 Daniel Veillard <daniel@veillard.com>
@ -3468,7 +3468,7 @@ Mon Aug 8 01:41:53 CEST 2005 Daniel Veillard <daniel@veillard.com>
Sun Aug 7 12:39:35 CEST 2005 Daniel Veillard <daniel@veillard.com> Sun Aug 7 12:39:35 CEST 2005 Daniel Veillard <daniel@veillard.com>
* test/relaxng/docbook_0.xml: get rid of the dependancy on a locally * test/relaxng/docbook_0.xml: get rid of the dependency on a locally
installed DTD installed DTD
* uri.c include/libxml/uri.h xmlIO.c nanoftp.c nanohttp.c: try to * uri.c include/libxml/uri.h xmlIO.c nanoftp.c nanohttp.c: try to
cleanup the Path/URI conversion mess, needed fixing in various cleanup the Path/URI conversion mess, needed fixing in various
@ -3522,7 +3522,7 @@ Sat Jul 30 17:26:58 EDT 2005 Daniel Veillard <daniel@veillard.com>
Sat Jul 30 17:08:07 EDT 2005 Daniel Veillard <daniel@veillard.com> Sat Jul 30 17:08:07 EDT 2005 Daniel Veillard <daniel@veillard.com>
* schematron.c xmllint.c include/libxml/schematron.h: commiting * schematron.c xmllint.c include/libxml/schematron.h: committing
work done on the plane last week-end work done on the plane last week-end
Sat Jul 30 15:16:29 CEST 2005 Daniel Veillard <daniel@veillard.com> Sat Jul 30 15:16:29 CEST 2005 Daniel Veillard <daniel@veillard.com>
@ -4029,7 +4029,7 @@ Mon Jun 27 01:01:32 CEST 2005 Daniel Veillard <daniel@veillard.com>
Sun Jun 26 20:08:24 CEST 2005 Daniel Veillard <daniel@veillard.com> Sun Jun 26 20:08:24 CEST 2005 Daniel Veillard <daniel@veillard.com>
* include/libxml/valid.h valid.c: avoid name glob in agruments as * include/libxml/valid.h valid.c: avoid name glob in arguments as
it matches the glob() routine. it matches the glob() routine.
* runtest.c Makefile.am: first steps toward a C regression test * runtest.c Makefile.am: first steps toward a C regression test
framework. framework.
@ -4463,7 +4463,7 @@ Fri Apr 1 16:07:59 CEST 2005 Daniel Veillard <daniel@veillard.com>
* doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h * doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h
format to cope with gcc4 change of aliasing allowed scopes, had format to cope with gcc4 change of aliasing allowed scopes, had
to add extra informations to doc/libxml2-api.xml to separate to add extra information to doc/libxml2-api.xml to separate
the header from the c module source. the header from the c module source.
* *.c: updated all c library files to add a #define bottom_xxx * *.c: updated all c library files to add a #define bottom_xxx
and reimport elfgcchack.h thereafter, and a bit of cleanups. and reimport elfgcchack.h thereafter, and a bit of cleanups.
@ -4955,9 +4955,9 @@ Fri Jan 28 18:37:18 CET 2005 Daniel Veillard <daniel@veillard.com>
Fri Jan 28 16:51:47 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net> Fri Jan 28 16:51:47 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c: Corrected an ambigious symbol-space for * xmlschemas.c: Corrected an ambiguous symbol-space for
local attribute declarations. IFDEFed more IDC code to local attribute declarations. IFDEFed more IDC code to
surpress compiler warnings. suppress compiler warnings.
Fri Jan 28 00:57:04 CET 2005 Daniel Veillard <daniel@veillard.com> Fri Jan 28 00:57:04 CET 2005 Daniel Veillard <daniel@veillard.com>
@ -4978,7 +4978,7 @@ Thu Jan 27 13:39:04 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
Added an initial skeleton for indentity-constraints. This is all Added an initial skeleton for indentity-constraints. This is all
defined out, since not complete, plus it needs support from other defined out, since not complete, plus it needs support from other
modules. modules.
Added machanism to store element information for the Added mechanism to store element information for the
ancestor-or-self axis; this is needed for identity-constraints ancestor-or-self axis; this is needed for identity-constraints
and should be helpful for a future streamable validation. and should be helpful for a future streamable validation.
* include/libxml/xmlerror.h: Added an error code for * include/libxml/xmlerror.h: Added an error code for
@ -5028,7 +5028,7 @@ Sun Jan 23 21:14:20 CET 2005 Daniel Veillard <daniel@veillard.com>
Sun Jan 23 18:35:00 CET 2005 Daniel Veillard <daniel@veillard.com> Sun Jan 23 18:35:00 CET 2005 Daniel Veillard <daniel@veillard.com>
* parser.c: boosting common commnent parsing code, it was really * parser.c: boosting common comment parsing code, it was really
slow. slow.
* test/comment[3-5].xml result//comment[3-5].xml*: added sprecific * test/comment[3-5].xml result//comment[3-5].xml*: added sprecific
regression tests regression tests
@ -5179,7 +5179,7 @@ Sat Jan 8 23:04:10 CET 2005 Daniel Veillard <daniel@veillard.com>
Fri Jan 7 14:54:51 CET 2005 Daniel Veillard <daniel@veillard.com> Fri Jan 7 14:54:51 CET 2005 Daniel Veillard <daniel@veillard.com>
* TODO: small update * TODO: small update
* xmlregexp.c: trying to add an API to get useful error informations * xmlregexp.c: trying to add an API to get useful error information
back from a failing regexp context. back from a failing regexp context.
Thu Jan 6 17:35:41 HKT 2005 William Brack <wbrack@mmm.com.hk> Thu Jan 6 17:35:41 HKT 2005 William Brack <wbrack@mmm.com.hk>
@ -5280,7 +5280,7 @@ Sat Dec 25 18:10:02 HKT 2004 William Brack <wbrack@mmm.com.hk>
Fri Dec 24 16:31:22 HKT 2004 William Brack <wbrack@mmm.com.hk> Fri Dec 24 16:31:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
* python/generator.py: added most required entires to * python/generator.py: added most required entries to
foreign encoding table, plus some additional logic to foreign encoding table, plus some additional logic to
assure only the 1st param uses the 't#' format. Fixes assure only the 1st param uses the 't#' format. Fixes
bug #152286, but may still have some other UTF-16 problems. bug #152286, but may still have some other UTF-16 problems.
@ -5360,7 +5360,7 @@ Fri Nov 26 13:09:04 CET 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
of elements for which a declaration existed were still processed of elements for which a declaration existed were still processed
by the wildcard mechanism (reported by philippe ventrillon to the by the wildcard mechanism (reported by philippe ventrillon to the
mailing list). mailing list).
Changed the import and include machanism to share dictionaries. Changed the import and include mechanism to share dictionaries.
Fri Nov 26 11:44:36 CET 2004 Daniel Veillard <daniel@veillard.com> Fri Nov 26 11:44:36 CET 2004 Daniel Veillard <daniel@veillard.com>
@ -5640,7 +5640,7 @@ Tue Nov 2 15:49:34 CET 2004 Daniel Veillard <daniel@veillard.com>
* SAX2.c nanoftp.c parser.c parserInternals.c tree.c xmlIO.c * SAX2.c nanoftp.c parser.c parserInternals.c tree.c xmlIO.c
xmlstring.c: various API hardeing changes as a result of running xmlstring.c: various API hardeing changes as a result of running
the first set of automatic API regression tests. the first set of automatic API regression tests.
* test/slashdot16.xml: apparently missing from CVS, commited it * test/slashdot16.xml: apparently missing from CVS, committed it
Mon Nov 1 15:54:18 CET 2004 Daniel Veillard <daniel@veillard.com> Mon Nov 1 15:54:18 CET 2004 Daniel Veillard <daniel@veillard.com>
@ -5867,7 +5867,7 @@ Wed Sep 29 15:00:11 CEST 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
model group "all". model group "all".
* test/schemas/bug152470_1.xsd: Removed an "abstract" attribute, * test/schemas/bug152470_1.xsd: Removed an "abstract" attribute,
which broke the test. which broke the test.
* xstc/xstc.py: Workaround to accomodate case insensitive * xstc/xstc.py: Workaround to accommodate case insensitive
test definitions in ms-test.def.xml (was missing in a previous test definitions in ms-test.def.xml (was missing in a previous
commit). commit).
@ -5961,7 +5961,7 @@ Thu Sep 16 13:24:27 CEST 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c include/libxml/schemasInternals.h * xmlschemas.c include/libxml/schemasInternals.h
test/schemas/bug152470_1.* result/schemas/bug152470_1_1*: test/schemas/bug152470_1.* result/schemas/bug152470_1_1*:
Simpified attribute wildcard creation and assignment to get rid Simplified attribute wildcard creation and assignment to get rid
of memory leaks. of memory leaks.
Restructured the validation process. Restructured the validation process.
Restructured and expanded parsing of <attributeGroup>. Restructured and expanded parsing of <attributeGroup>.
@ -5978,7 +5978,7 @@ Thu Sep 16 13:24:27 CEST 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
'anyType' using the short-hand form (see bug # 152470, 'anyType' using the short-hand form (see bug # 152470,
submitted by Thilo Jeremias). submitted by Thilo Jeremias).
* include/libxml/xmlschematypes.h: Cleaned up some comments. * include/libxml/xmlschematypes.h: Cleaned up some comments.
* xstc/xstc.py: Workaround to accomodate case insensitive * xstc/xstc.py: Workaround to accommodate case insensitive
test definitions in ms-test.def.xml. test definitions in ms-test.def.xml.
* result/schemas/deter0_0_0.err result/schemas/ns0_0_2.err * result/schemas/deter0_0_0.err result/schemas/ns0_0_2.err
result/schemas/ns0_1_2.err: Adapted. result/schemas/ns0_1_2.err: Adapted.
@ -6321,7 +6321,7 @@ Sat Aug 14 13:18:57 CEST 2004 Daniel Veillard <daniel@veillard.com>
to document xmlSchemasSetValidErrors() limitations, #141827 to document xmlSchemasSetValidErrors() limitations, #141827
* error.c: Add information in generic and structured error * error.c: Add information in generic and structured error
setter functions that this need to be done per thread #144308 setter functions that this need to be done per thread #144308
* xmlsave.c: fixed bug whith missing NOTATION(s) serialization * xmlsave.c: fixed bug with missing NOTATION(s) serialization
bug #144162 bug #144162
* doc/xmllint.xml: typo fix #144840 * doc/xmllint.xml: typo fix #144840
@ -6691,7 +6691,7 @@ Tue Jun 8 21:27:03 HKT 2004 William Brack <wbrack@mmm.com.hk>
Tue Jun 8 14:01:14 CEST 2004 Daniel Veillard <daniel@veillard.com> Tue Jun 8 14:01:14 CEST 2004 Daniel Veillard <daniel@veillard.com>
* parser.c xmlreader.c include/libxml/parser.h: fixed a serious * parser.c xmlreader.c include/libxml/parser.h: fixed a serious
problem when substituing entities using the Reader, the entities problem when substituting entities using the Reader, the entities
content might be freed and if rereferenced would crash content might be freed and if rereferenced would crash
* Makefile.am test/* result/*: added a new test case and a new * Makefile.am test/* result/*: added a new test case and a new
test operation for the reader with substitution of entities. test operation for the reader with substitution of entities.
@ -6847,7 +6847,7 @@ Sun May 16 03:06:31 CEST 2004 Daniel Veillard <daniel@veillard.com>
Sat May 15 20:14:21 CEST 2004 Daniel Veillard <daniel@veillard.com> Sat May 15 20:14:21 CEST 2004 Daniel Veillard <daniel@veillard.com>
* doc/ChangeLog.awk doc/ChangeLog.xsl: first steps of a good * doc/ChangeLog.awk doc/ChangeLog.xsl: first steps of a good
ChangeLog page generation. The awk shoudl escape characters ChangeLog page generation. The awk should escape characters
not okay in XML and the xslt should make links to functions not okay in XML and the xslt should make links to functions
or variables or bug reported in the entries. or variables or bug reported in the entries.
@ -7049,7 +7049,7 @@ Sun Apr 18 23:45:46 CEST 2004 Daniel Veillard <daniel@veillard.com>
Sun Apr 18 22:51:43 CEST 2004 Daniel Veillard <daniel@veillard.com> Sun Apr 18 22:51:43 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xpath.c: relaxed id() to not check taht the name(s) passed * xpath.c: relaxed id() to not check that the name(s) passed
are actually NCName, decided this in agreement with Aleksey Sanin are actually NCName, decided this in agreement with Aleksey Sanin
since existing specs like Visa3D broke that conformance checking since existing specs like Visa3D broke that conformance checking
and other tools seems to not implement it sigh... and other tools seems to not implement it sigh...
@ -7062,7 +7062,7 @@ Sun Apr 18 21:46:17 CEST 2004 Daniel Veillard <daniel@veillard.com>
* xpath.c: work around Microsoft compiler NaN bug raise reported * xpath.c: work around Microsoft compiler NaN bug raise reported
by Mark Vakoc by Mark Vakoc
* xmlschemas.c include/libxml/schemasInternals.h * xmlschemas.c include/libxml/schemasInternals.h
include/libxml/xmlerror.h: fixed a recusive extention schemas include/libxml/xmlerror.h: fixed a recursive extension schemas
compilation error raised by taihei goi compilation error raised by taihei goi
Sun Apr 18 16:57:02 CEST 2004 Daniel Veillard <daniel@veillard.com> Sun Apr 18 16:57:02 CEST 2004 Daniel Veillard <daniel@veillard.com>
@ -7228,7 +7228,7 @@ Tue Mar 23 12:35:08 CET 2004 Daniel Veillard <daniel@veillard.com>
* configure.in doc/* News: preparing 2.6.8 release, updated and rebuilt * configure.in doc/* News: preparing 2.6.8 release, updated and rebuilt
the docs. the docs.
* Makefile.am: use valgring fro the new Python based regression tests * Makefile.am: use valgring for the new Python based regression tests
Mon Mar 22 20:07:27 CET 2004 Daniel Veillard <daniel@veillard.com> Mon Mar 22 20:07:27 CET 2004 Daniel Veillard <daniel@veillard.com>
@ -7292,7 +7292,7 @@ Wed Mar 10 17:22:48 CET 2004 Daniel Veillard <daniel@veillard.com>
Wed Mar 10 19:42:22 HKT 2004 William Brack <wbrack@mmm.com.hk> Wed Mar 10 19:42:22 HKT 2004 William Brack <wbrack@mmm.com.hk>
* doc/search.php: Minor change for later verson of php requiring * doc/search.php: Minor change for later version of php requiring
$HTTP_GET_VARS. $HTTP_GET_VARS.
Wed Mar 10 00:12:31 HKT 2004 William Brack <wbrack@mmm.com.hk> Wed Mar 10 00:12:31 HKT 2004 William Brack <wbrack@mmm.com.hk>
@ -7361,8 +7361,8 @@ Thu Mar 4 15:00:45 CET 2004 Daniel Veillard <daniel@veillard.com>
Thu Mar 4 14:39:38 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Mar 4 14:39:38 CET 2004 Daniel Veillard <daniel@veillard.com>
* Makefile.am tree.c xmlsave.c include/libxml/xmlsave.h: commiting * Makefile.am tree.c xmlsave.c include/libxml/xmlsave.h: committing
the new xmlsave module before the actuall big code change. the new xmlsave module before the actual big code change.
Thu Mar 4 12:38:53 CET 2004 Daniel Veillard <daniel@veillard.com> Thu Mar 4 12:38:53 CET 2004 Daniel Veillard <daniel@veillard.com>
@ -7872,7 +7872,7 @@ Mon Jan 5 20:47:07 MST 2004 John Fleck <jfleck@inkstain.net>
Tue Jan 6 00:10:33 CET 2004 Daniel Veillard <daniel@veillard.com> Tue Jan 6 00:10:33 CET 2004 Daniel Veillard <daniel@veillard.com>
* rngparser.c: commiting the compact relax ng parser. It's not * rngparser.c: committing the compact relax ng parser. It's not
completely finished, it's not integrated but I want to save the completely finished, it's not integrated but I want to save the
current state current state
@ -8026,7 +8026,7 @@ Wed Dec 24 00:29:30 CET 2003 Daniel Veillard <daniel@veillard.com>
Tue Dec 23 15:14:37 HKT 2003 William Brack <wbrack@mmm.com.hk> Tue Dec 23 15:14:37 HKT 2003 William Brack <wbrack@mmm.com.hk>
* valid.c: fixed bug concerning validation using external * valid.c: fixed bug concerning validation using external
dtd of element with mutiple namespace declarations dtd of element with multiple namespace declarations
(Bug 129821) (Bug 129821)
Tue Dec 23 11:41:42 HKT 2003 William Brack <wbrack@mmm.com.hk> Tue Dec 23 11:41:42 HKT 2003 William Brack <wbrack@mmm.com.hk>
@ -8407,7 +8407,7 @@ Thu Nov 20 12:54:30 CET 2003 Daniel Veillard <daniel@veillard.com>
* doc/examples/*: added his test as the xmlWriter example * doc/examples/*: added his test as the xmlWriter example
* doc/html/ doc/*.html: this resulted in some improvements * doc/html/ doc/*.html: this resulted in some improvements
* include/libxml/hash.h: fixed an inclusion problem when * include/libxml/hash.h: fixed an inclusion problem when
<libxml/hash.h> wasn't preceeded by <xml/parser.h> <libxml/hash.h> wasn't preceded by <xml/parser.h>
Wed Nov 19 17:19:35 CET 2003 Daniel Veillard <daniel@veillard.com> Wed Nov 19 17:19:35 CET 2003 Daniel Veillard <daniel@veillard.com>
@ -8430,7 +8430,7 @@ Wed Nov 19 00:48:56 CET 2003 Daniel Veillard <daniel@veillard.com>
Tue Nov 18 21:51:15 CET 2003 Daniel Veillard <daniel@veillard.com> Tue Nov 18 21:51:15 CET 2003 Daniel Veillard <daniel@veillard.com>
* include/libxml/*.h include/libxml/*.h.in: modified the file * include/libxml/*.h include/libxml/*.h.in: modified the file
header to add more informations, painful... header to add more information, painful...
* genChRanges.py genUnicode.py: updated to generate said changes * genChRanges.py genUnicode.py: updated to generate said changes
in headers in headers
* doc/apibuild.py: extract headers, add them to libxml2-api.xml * doc/apibuild.py: extract headers, add them to libxml2-api.xml
@ -8572,7 +8572,7 @@ Wed Nov 12 01:38:16 CET 2003 Daniel Veillard <daniel@veillard.com>
added autogeneration of a web page for the examples added autogeneration of a web page for the examples
* doc/examples/example1.c doc/examples/.cvsignore * doc/examples/example1.c doc/examples/.cvsignore
doc/examples/examples.xml doc/examples/index.py: updated the doc/examples/examples.xml doc/examples/index.py: updated the
informations extracted, improved the format and indexing. information extracted, improved the format and indexing.
Tue Nov 11 22:08:59 CET 2003 Daniel Veillard <daniel@veillard.com> Tue Nov 11 22:08:59 CET 2003 Daniel Veillard <daniel@veillard.com>
@ -8774,7 +8774,7 @@ Tue Oct 28 16:42:16 CET 2003 Daniel Veillard <daniel@veillard.com>
* error.c valid.c include/libxml/xmlerror.h: fixing bug #125653 * error.c valid.c include/libxml/xmlerror.h: fixing bug #125653
sometimes the error handlers can get a parser context on DTD sometimes the error handlers can get a parser context on DTD
errors, and sometime they don't. So be very careful when trying errors, and sometime they don't. So be very careful when trying
to grab those informations. to grab those information.
Tue Oct 28 15:26:18 CET 2003 Daniel Veillard <daniel@veillard.com> Tue Oct 28 15:26:18 CET 2003 Daniel Veillard <daniel@veillard.com>
@ -8884,7 +8884,7 @@ Mon Oct 20 19:02:53 CEST 2003 Daniel Veillard <daniel@veillard.com>
* python/tests/Makefile.am python/tests/reader7.py * python/tests/Makefile.am python/tests/reader7.py
python/tests/walker.py: adding regression testing for the python/tests/walker.py: adding regression testing for the
new xmlreader APIs, new APIs for reader creation, including new xmlreader APIs, new APIs for reader creation, including
makeing reader "walker" operating on preparsed document trees. making reader "walker" operating on preparsed document trees.
Sun Oct 20 22:37:03 HKT 2003 William Brack <wbrack@mmm.com.hk> Sun Oct 20 22:37:03 HKT 2003 William Brack <wbrack@mmm.com.hk>
@ -9084,7 +9084,7 @@ Fri Oct 10 16:45:20 CEST 2003 Daniel Veillard <daniel@veillard.com>
Fri Oct 10 16:19:17 CEST 2003 Daniel Veillard <daniel@veillard.com> Fri Oct 10 16:19:17 CEST 2003 Daniel Veillard <daniel@veillard.com>
* include/libxml/tree.h: make room in Doc, Element, Attributes * include/libxml/tree.h: make room in Doc, Element, Attributes
for PSVI type informations. for PSVI type information.
Fri Oct 10 16:08:02 CEST 2003 Daniel Veillard <daniel@veillard.com> Fri Oct 10 16:08:02 CEST 2003 Daniel Veillard <daniel@veillard.com>
@ -9251,7 +9251,7 @@ Fri Oct 3 00:19:02 CEST 2003 Daniel Veillard <daniel@veillard.com>
scrolling to see where thing broke wasn't pleasant scrolling to see where thing broke wasn't pleasant
* configure.in: some beta4 preparation, but not ready yet * configure.in: some beta4 preparation, but not ready yet
* error.c globals.c include/libxml/globals.h include/libxml/xmlerror.h: * error.c globals.c include/libxml/globals.h include/libxml/xmlerror.h:
new error handling code, last error informations are stored new error handling code, last error information are stored
in the parsing context or a global variable, new APIs to in the parsing context or a global variable, new APIs to
handle the xmlErrorPtr type. handle the xmlErrorPtr type.
* parser.c parserInternals.c valid.c : started migrating to the * parser.c parserInternals.c valid.c : started migrating to the
@ -9261,7 +9261,7 @@ Fri Oct 3 00:19:02 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: small potential buffer access problem in push code * parser.c: small potential buffer access problem in push code
provided by Justin Fletcher provided by Justin Fletcher
* result/*.sax result/VC/PENesting* result/namespaces/* * result/*.sax result/VC/PENesting* result/namespaces/*
result/valid/*.err: some error messages were sligthly changed. result/valid/*.err: some error messages were slightly changed.
Thu Oct 2 13:01:13 2003 Aleksey Sanin <aleksey@aleksey.com> Thu Oct 2 13:01:13 2003 Aleksey Sanin <aleksey@aleksey.com>
@ -9369,7 +9369,7 @@ Sun Sep 28 02:15:07 CEST 2003 Daniel Veillard <daniel@veillard.com>
* include/libxml/SAX.h include/libxml/parser.h: move the * include/libxml/SAX.h include/libxml/parser.h: move the
SAXv1 block definitions to parser.h fixes bug #123380 SAXv1 block definitions to parser.h fixes bug #123380
* xmlreader.c include/libxml/xmlreader.h: reinstanciate * xmlreader.c include/libxml/xmlreader.h: reinstanciate
the attribute and element pool borken 2 commits ago. the attribute and element pool broken 2 commits ago.
Start playing with an entry point to preserve a subtree. Start playing with an entry point to preserve a subtree.
* entities.c: remove a warning. * entities.c: remove a warning.
@ -9436,7 +9436,7 @@ Thu Sep 25 16:23:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
include/libxml/globals.h include/libxml/SAX.h: make sure the include/libxml/globals.h include/libxml/SAX.h: make sure the
global variables for the default SAX handler are V1 ones to global variables for the default SAX handler are V1 ones to
avoid ABI compat problems. avoid ABI compat problems.
* xmlreader.c: cleanup of uneeded code * xmlreader.c: cleanup of unneeded code
* hash.c: fix a comment * hash.c: fix a comment
Thu Sep 25 14:16:51 CEST 2003 Daniel Veillard <daniel@veillard.com> Thu Sep 25 14:16:51 CEST 2003 Daniel Veillard <daniel@veillard.com>
@ -9734,7 +9734,7 @@ Sun Sep 7 11:11:45 CEST 2003 Daniel Veillard <daniel@veillard.com>
* dict.c: allow to give -1 for undefined length in lookups * dict.c: allow to give -1 for undefined length in lookups
* include/libxml/parser.h parser.c parserInternals.c testSAX.c: * include/libxml/parser.h parser.c parserInternals.c testSAX.c:
first round of work on the new SAX2 interfaces, the API first round of work on the new SAX2 interfaces, the API
will change but commiting before changing for historical will change but committing before changing for historical
reference. reference.
Sat Sep 6 10:55:01 PTD 2003 William Brack <wbrack@mmm.com.hk> Sat Sep 6 10:55:01 PTD 2003 William Brack <wbrack@mmm.com.hk>
@ -10091,7 +10091,7 @@ Thu Aug 7 21:13:22 HKT 2003 William Brack <wbrack@mmm.com.hk>
Wed Aug 6 12:32:11 HKT 2003 William Brack <wbrack@mmm.com.hk> Wed Aug 6 12:32:11 HKT 2003 William Brack <wbrack@mmm.com.hk>
* error.c trionan.[ch] testThreads.c python/generator.py: * error.c trionan.[ch] testThreads.c python/generator.py:
further small changes to elminate most of the remaining further small changes to eliminate most of the remaining
warnings. warnings.
Tue Aug 5 23:51:21 HKT 2003 William Brack <wbrack@mmm.com.hk> Tue Aug 5 23:51:21 HKT 2003 William Brack <wbrack@mmm.com.hk>
@ -10130,7 +10130,7 @@ Sun Aug 3 21:02:30 EDT 2003 Daniel Veillard <daniel@veillard.com>
* valid.c: fixed another problem with namespaces on element * valid.c: fixed another problem with namespaces on element
in mixed content case in mixed content case
* python/tests/reader2.py: updated the testcase with * python/tests/reader2.py: updated the testcase with
Bjorn Reese fix to reader for unsignificant white space Bjorn Reese fix to reader for insignificant white space
* parser.c HTMLparser.c: cleanup. * parser.c HTMLparser.c: cleanup.
Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard <daniel@veillard.com> Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard <daniel@veillard.com>
@ -10151,7 +10151,7 @@ Sun Aug 3 18:56:54 EDT 2003 Daniel Veillard <daniel@veillard.com>
Fri Aug 1 23:55:23 HKT 2003 William Brack <wbrack@mmm.com.hk> Fri Aug 1 23:55:23 HKT 2003 William Brack <wbrack@mmm.com.hk>
Coninuing work on bug 118559 Coninuing work on bug 118559
* DOCBparser.c: removed 2 unsed vars * DOCBparser.c: removed 2 unused vars
* xmlregexp.c: changed some numeric const to their enum symbols * xmlregexp.c: changed some numeric const to their enum symbols
* xmlreader.c: changed one var define from int to enum * xmlreader.c: changed one var define from int to enum
(a little more to be done, awaiting co-ordination) (a little more to be done, awaiting co-ordination)
@ -10318,7 +10318,7 @@ Thu Jul 10 16:02:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
Tue Jul 8 16:02:19 CEST 2003 Daniel Veillard <daniel@veillard.com> Tue Jul 8 16:02:19 CEST 2003 Daniel Veillard <daniel@veillard.com>
* globals.c threads.c: fixes some problem when freeing unititialized * globals.c threads.c: fixes some problem when freeing uninitialized
mutexes mutexes
Tue Jul 8 14:15:07 CEST 2003 Daniel Veillard <daniel@veillard.com> Tue Jul 8 14:15:07 CEST 2003 Daniel Veillard <daniel@veillard.com>
@ -10373,7 +10373,7 @@ Sat Jul 5 22:30:25 CEST 2003 Daniel Veillard <daniel@veillard.com>
Sat Jul 5 00:51:30 HKT 2003 William Brack <wbrack@mmm.com.hk> Sat Jul 5 00:51:30 HKT 2003 William Brack <wbrack@mmm.com.hk>
Fixed problem with multi-threading, shown by the test program Fixed problem with multi-threading, shown by the test program
testThreads. After fix, ran mutiple tests on various speed testThreads. After fix, ran multiple tests on various speed
machines (single and dual processor X86), which all seem okay. machines (single and dual processor X86), which all seem okay.
* catalog.c: added missing xmlRMutexUnlock in xmlLoadCatalog * catalog.c: added missing xmlRMutexUnlock in xmlLoadCatalog
@ -10451,7 +10451,7 @@ Thu Jun 5 11:31:02 CEST 2003 Daniel Veillard <daniel@veillard.com>
Mon Jun 2 21:56:15 MVT 2003 Daniel Veillard <daniel@veillard.com> Mon Jun 2 21:56:15 MVT 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c xmlschemas.c include/libxml/schemasInternals.h: commiting * relaxng.c xmlschemas.c include/libxml/schemasInternals.h: committing
some work done while in the Maldives (hence the timezone on the some work done while in the Maldives (hence the timezone on the
laptop !) laptop !)
* result/schemas/length3* test/schemas/deter0_* * result/schemas/length3* test/schemas/deter0_*
@ -11398,7 +11398,7 @@ Wed Feb 19 14:26:51 CET 2003 Daniel Veillard <daniel@veillard.com>
Wed Feb 19 01:17:48 CET 2003 Daniel Veillard <daniel@veillard.com> Wed Feb 19 01:17:48 CET 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c: guess what ! Relax-NG bugfixing, what a surprize... * relaxng.c: guess what ! Relax-NG bugfixing, what a surprise...
Tue Feb 18 22:09:50 CET 2003 Daniel Veillard <daniel@veillard.com> Tue Feb 18 22:09:50 CET 2003 Daniel Veillard <daniel@veillard.com>
@ -11929,10 +11929,10 @@ Mon Jan 6 14:06:07 CET 2003 Daniel Veillard <daniel@veillard.com>
* configure.in NEWS: preparing 2.5.0 release * configure.in NEWS: preparing 2.5.0 release
* SAX.c: only warn in pedantic mode about namespace name * SAX.c: only warn in pedantic mode about namespace name
brokeness brokenness
* globals.c: fix a doc generation problem * globals.c: fix a doc generation problem
* uri.c: fix #101520 * uri.c: fix #101520
* doc/*: updated and rebuilt the doc for the release, includuding * doc/*: updated and rebuilt the doc for the release, including
stylesheet update stylesheet update
* python/Makefile.am: fix a filename bug * python/Makefile.am: fix a filename bug
@ -12092,7 +12092,7 @@ Sun Dec 29 12:13:18 CET 2002 Daniel Veillard <daniel@veillard.com>
Sat Dec 28 23:49:12 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Dec 28 23:49:12 CET 2002 Daniel Veillard <daniel@veillard.com>
* xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml:
extended the XmlTextReader API a bit, addding accessors for extended the XmlTextReader API a bit, adding accessors for
the current doc and node, and an entity substitution mode for the current doc and node, and an entity substitution mode for
the parser. the parser.
* python/libxml.py python/libxml2class.txt: related updates * python/libxml.py python/libxml2class.txt: related updates
@ -12479,7 +12479,7 @@ Sun Nov 17 10:25:43 CET 2002 Daniel Veillard <daniel@veillard.com>
Sat Nov 16 16:30:25 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Nov 16 16:30:25 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c xpath.c: fixing #96925 wich was also dependent on the * parser.c xpath.c: fixing #96925 which was also dependent on the
processing of parsed entities, and XPath computation on sustitued processing of parsed entities, and XPath computation on sustitued
entities. entities.
* testXPath.c: make sure entities are substituted. * testXPath.c: make sure entities are substituted.
@ -12715,7 +12715,7 @@ Wed Oct 16 16:05:38 CEST 2002 Daniel Veillard <daniel@veillard.com>
Tue Oct 15 12:41:01 CEST 2002 Daniel Veillard <daniel@veillard.com> Tue Oct 15 12:41:01 CEST 2002 Daniel Veillard <daniel@veillard.com>
* README: updated the contact informations * README: updated the contact information
Tue Oct 15 10:35:57 CEST 2002 Daniel Veillard <daniel@veillard.com> Tue Oct 15 10:35:57 CEST 2002 Daniel Veillard <daniel@veillard.com>
@ -13009,7 +13009,7 @@ Thu Sep 5 13:10:57 CEST 2002 Daniel Veillard <daniel@veillard.com>
Thu Sep 5 12:57:38 CEST 2002 Daniel Veillard <daniel@veillard.com> Thu Sep 5 12:57:38 CEST 2002 Daniel Veillard <daniel@veillard.com>
* valid.c: try to provide file and line informations, not all * valid.c: try to provide file and line information, not all
messages are covered, but it's a (good) start messages are covered, but it's a (good) start
Thu Sep 5 12:49:35 CEST 2002 Daniel Veillard <daniel@veillard.com> Thu Sep 5 12:49:35 CEST 2002 Daniel Veillard <daniel@veillard.com>
@ -13060,7 +13060,7 @@ Wed Aug 28 13:44:54 CEST 2002 Daniel Veillard <daniel@veillard.com>
Sun Aug 25 16:38:05 CEST 2002 Daniel Veillard <daniel@veillard.com> Sun Aug 25 16:38:05 CEST 2002 Daniel Veillard <daniel@veillard.com>
* xmlIO.c: handle Windows sepecific file://localhost/ semantic ... * xmlIO.c: handle Windows specific file://localhost/ semantic ...
Thu Aug 22 22:03:19 CEST 2002 Daniel Veillard <daniel@veillard.com> Thu Aug 22 22:03:19 CEST 2002 Daniel Veillard <daniel@veillard.com>
@ -13394,7 +13394,7 @@ Mon Jun 03 00:04:21 2002 Chema Celorio <chema@ximian.com>
* tree.h: added xmlDocFormatDump which is just as xmlDocDump * tree.h: added xmlDocFormatDump which is just as xmlDocDump
but with the format parameter but with the format parameter
* tree.c: made xmlDocDump a wrapper arround xmlDocFormatDump * tree.c: made xmlDocDump a wrapper around xmlDocFormatDump
Fri May 31 12:16:48 2002 Aleksey Sanin <aleksey@aleksey.com> Fri May 31 12:16:48 2002 Aleksey Sanin <aleksey@aleksey.com>
@ -13499,13 +13499,13 @@ Wed May 15 00:25:34 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
Tue May 14 13:00:48 CEST 2002 Daniel Veillard <daniel@veillard.com> Tue May 14 13:00:48 CEST 2002 Daniel Veillard <daniel@veillard.com>
* xpath.c: fixing an XPath function evalutation bug pointed out * xpath.c: fixing an XPath function evaluation bug pointed out
by Alexey Efimov where the context was lost when evaluating by Alexey Efimov where the context was lost when evaluating
the function arguments the function arguments
Mon 13 May 2002 11:37:39 PM PDT Aleksey Sanin <aleksey@aleksey.com> Mon 13 May 2002 11:37:39 PM PDT Aleksey Sanin <aleksey@aleksey.com>
* xpath.c include/libxml/xpathInternals.h: maked xmlXPathNodeSetAddNs() * xpath.c include/libxml/xpathInternals.h: made xmlXPathNodeSetAddNs()
function public for XMLSec performance optimizations function public for XMLSec performance optimizations
Mon May 13 12:32:22 CEST 2002 Daniel Veillard <daniel@veillard.com> Mon May 13 12:32:22 CEST 2002 Daniel Veillard <daniel@veillard.com>
@ -13542,7 +13542,7 @@ Wed 01 May 2002 11:29:27 AM PDT Aleksey Sanin <aleksey@aleksey.com>
* include/libxml/xmlIO.h win32/dsp/libxml2.def.src * include/libxml/xmlIO.h win32/dsp/libxml2.def.src
win32/libxml2.def.src xmlIO.c: exported default win32/libxml2.def.src xmlIO.c: exported default
'file:', 'http:' and 'ftp:' protocols input handlers 'file:', 'http:' and 'ftp:' protocols input handlers
and maked protocols comparisson case insensitive and made protocols comparison case insensitive
Tue Apr 30 16:29:05 CEST 2002 Daniel Veillard <daniel@veillard.com> Tue Apr 30 16:29:05 CEST 2002 Daniel Veillard <daniel@veillard.com>
@ -13999,7 +13999,7 @@ Mon Mar 11 10:10:30 CET 2002 Daniel Veillard <daniel@veillard.com>
Sun Mar 10 17:47:58 CET 2002 Daniel Veillard <daniel@veillard.com> Sun Mar 10 17:47:58 CET 2002 Daniel Veillard <daniel@veillard.com>
* valid.c: applied patch from Dodji Seketeli fixing an * valid.c: applied patch from Dodji Seketeli fixing an
uninitailized variable in xmlValidGetValidElements() uninitialized variable in xmlValidGetValidElements()
Sat Mar 9 15:10:49 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Mar 9 15:10:49 CET 2002 Daniel Veillard <daniel@veillard.com>
@ -14139,12 +14139,12 @@ Fri Mar 1 17:12:15 CET 2002 Daniel Veillard <daniel@veillard.com>
Fri Mar 1 13:56:12 CET 2002 Daniel Veillard <daniel@veillard.com> Fri Mar 1 13:56:12 CET 2002 Daniel Veillard <daniel@veillard.com>
* python/*: commiting some Python bindings work done while travelling * python/*: committing some Python bindings work done while travelling
Fri Mar 1 10:11:15 CET 2002 Daniel Veillard <daniel@veillard.com> Fri Mar 1 10:11:15 CET 2002 Daniel Veillard <daniel@veillard.com>
* xmllint.c: close #72663 and #72658, don't memdump unless compiled * xmllint.c: close #72663 and #72658, don't memdump unless compiled
explicitely with memory debugging switched on explicitly with memory debugging switched on
Sat Feb 23 11:08:09 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Feb 23 11:08:09 CET 2002 Daniel Veillard <daniel@veillard.com>
@ -14496,7 +14496,7 @@ Sat Feb 2 11:25:51 CET 2002 Daniel Veillard <daniel@veillard.com>
Sat Feb 2 10:13:52 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Feb 2 10:13:52 CET 2002 Daniel Veillard <daniel@veillard.com>
* configure.in libxml.spec.in python/Makefile.am python/TODO * configure.in libxml.spec.in python/Makefile.am python/TODO
python/generator.py python/libxml2class.txt: added more informations python/generator.py python/libxml2class.txt: added more information
in the libxml2-python package including docs. Slightly changed in the libxml2-python package including docs. Slightly changed
the class hierarchy the class hierarchy
* python/tests/*: added basic regression tests infrastructure too * python/tests/*: added basic regression tests infrastructure too
@ -14543,7 +14543,7 @@ Wed Jan 30 21:51:26 CET 2002 Daniel Veillard <daniel@veillard.com>
Wed Jan 30 17:35:33 CET 2002 Daniel Veillard <daniel@veillard.com> Wed Jan 30 17:35:33 CET 2002 Daniel Veillard <daniel@veillard.com>
* python/generator.py python/libxml.c python/libxml.py * python/generator.py python/libxml.c python/libxml.py
python/libxml_wrap.h: commited early version of a python binding python/libxml_wrap.h: committed early version of a python binding
for private use only ATM for private use only ATM
Sat Jan 26 22:41:13 CET 2002 Daniel Veillard <daniel@veillard.com> Sat Jan 26 22:41:13 CET 2002 Daniel Veillard <daniel@veillard.com>
@ -15441,7 +15441,7 @@ Thu Sep 20 15:54:29 CEST 2001 Daniel Veillard <daniel@veillard.com>
Wed Sep 19 10:01:37 CEST 2001 Daniel Veillard <daniel@veillard.com> Wed Sep 19 10:01:37 CEST 2001 Daniel Veillard <daniel@veillard.com>
* Makefile.am libxml.spec.in: backing up non-documented changes * Makefile.am libxml.spec.in: backing up non-documented changes
commited without review or aproval by Jens Finke <jens@gnome.org> committed without review or approval by Jens Finke <jens@gnome.org>
* HACKING: made 100% clear that no commit should be done directly * HACKING: made 100% clear that no commit should be done directly
Mon Sep 17 18:52:37 CEST 2001 Daniel Veillard <daniel@veillard.com> Mon Sep 17 18:52:37 CEST 2001 Daniel Veillard <daniel@veillard.com>
@ -15586,7 +15586,7 @@ Sat Aug 25 15:30:17 CEST 2001 Daniel Veillard <daniel@veillard.com>
Thu Aug 23 23:16:32 CEST 2001 Daniel Veillard <daniel@veillard.com> Thu Aug 23 23:16:32 CEST 2001 Daniel Veillard <daniel@veillard.com>
* catalog.c xmlIO.c: started some serious testing and fixed * catalog.c xmlIO.c: started some serious testing and fixed
a few bug and optmization needs. a few bug and optimization needs.
Thu Aug 23 17:26:58 CEST 2001 Daniel Veillard <daniel@veillard.com> Thu Aug 23 17:26:58 CEST 2001 Daniel Veillard <daniel@veillard.com>
@ -15874,7 +15874,7 @@ Tue Jul 24 15:39:11 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
this slightly this slightly
* include/libxml/parser.h SAX.c parser.c parserInternals.c * include/libxml/parser.h SAX.c parser.c parserInternals.c
xmllint.c: make element content line number generation xmllint.c: make element content line number generation
optionnal to avoid breaking old apps added interface to switch optional to avoid breaking old apps added interface to switch
Tue Jul 24 15:06:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Tue Jul 24 15:06:58 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -16543,7 +16543,7 @@ Sun May 20 15:15:46 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Sat May 19 17:11:15 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat May 19 17:11:15 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* doc/xml.html: update with 2.3.9 informations * doc/xml.html: update with 2.3.9 information
Sat May 19 16:50:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat May 19 16:50:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -16738,7 +16738,7 @@ Sat Apr 28 18:54:28 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Sat Apr 28 16:33:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat Apr 28 16:33:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xpath.c: simple and efficient optimization, XPath functions * xpath.c: simple and efficient optimization, XPath functions
aways bind to the same code, cache this always bind to the same code, cache this
* TODO: updated (by saying some is obsolete) * TODO: updated (by saying some is obsolete)
Sat Apr 28 14:23:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat Apr 28 14:23:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -16977,7 +16977,7 @@ Thu Apr 12 10:50:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Wed Apr 11 16:37:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Wed Apr 11 16:37:50 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tree.h: include xmlmemory.h this seems to havoid a nasty glibc * tree.h: include xmlmemory.h this seems to havoid a nasty glibc
bug where the linktime verions of free() won't work ... bug where the linktime versions of free() won't work ...
Wed Apr 11 14:21:31 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Wed Apr 11 14:21:31 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -17376,7 +17376,7 @@ Thu Feb 15 15:57:14 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Wed Feb 14 11:35:39 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Wed Feb 14 11:35:39 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* hash.[ch]: added Paolo Casarini patch to provide Delete from * hash.[ch]: added Paolo Casarini patch to provide Delete from
hash functionnalities. hash functionalities.
* doc/html/* : rebuild the doc * doc/html/* : rebuild the doc
Tue Feb 13 18:01:48 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Tue Feb 13 18:01:48 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -17514,7 +17514,7 @@ Thu Jan 25 13:34:11 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Wed Jan 24 20:27:28 COT 2001 Alejandro Forero <bachue@bachue.com> Wed Jan 24 20:27:28 COT 2001 Alejandro Forero <bachue@bachue.com>
* xmlIO.c (xmlFileOpen, xmlFileOpenW): Removed unnecesary checks. * xmlIO.c (xmlFileOpen, xmlFileOpenW): Removed unnecessary checks.
* xmlIO.c (xmlCheckFilename): Function added to know whether a given * xmlIO.c (xmlCheckFilename): Function added to know whether a given
filename points to a valid file (not a directory). filename points to a valid file (not a directory).
@ -17551,7 +17551,7 @@ Mon Jan 22 10:35:40 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
of the data format with node set, as well as operators. of the data format with node set, as well as operators.
* HTMLtree.c: added a newline at the end of the doctype output * HTMLtree.c: added a newline at the end of the doctype output
whe this one is not present initially. whe this one is not present initially.
* tree.c: make sure taht the parent and doc pointers are properly * tree.c: make sure that the parent and doc pointers are properly
set when copying attributes (lists). set when copying attributes (lists).
Sun Jan 21 10:47:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sun Jan 21 10:47:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -17613,7 +17613,7 @@ Sat Jan 6 22:05:09 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
Sat Jan 6 19:13:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat Jan 6 19:13:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* Makefile.am: applied patch fro make check from Martin Vidner * Makefile.am: applied patch for make check from Martin Vidner
Thu Jan 4 19:07:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Thu Jan 4 19:07:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
@ -17667,7 +17667,7 @@ Wed Dec 27 12:35:49 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
of xmllint too when using --memory flag, added a memory test of xmllint too when using --memory flag, added a memory test
suite at the Makefile level. suite at the Makefile level.
* xpathInternals.h xpath.[ch] xpointer.c: fixed problems * xpathInternals.h xpath.[ch] xpointer.c: fixed problems
with namespace use when encountering QNames in XPath evalation, with namespace use when encountering QNames in XPath evaluation,
added xmlns() scheme in XPointer. added xmlns() scheme in XPointer.
* nanoftp.c : incorporated a fix * nanoftp.c : incorporated a fix
* parser.c xmlIO.c: fixed problems raised with encoding when using * parser.c xmlIO.c: fixed problems raised with encoding when using
@ -17892,7 +17892,7 @@ Sun Oct 22 13:59:50 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* valid.c: handling of blank nodes in DTd validation (raised * valid.c: handling of blank nodes in DTd validation (raised
by problems with a posteriori validation). by problems with a posteriori validation).
* nanohttp.c: changing behaviour on HTTP write stuff. * nanohttp.c: changing behaviour on HTTP write stuff.
* HTMLtree.c: forced body and html to be explicitely closed. * HTMLtree.c: forced body and html to be explicitly closed.
* xpath.h: exported more XPath functions. * xpath.h: exported more XPath functions.
Sun Oct 15 22:28:32 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org> Sun Oct 15 22:28:32 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
@ -18037,7 +18037,7 @@ Fri Oct 6 12:58:04 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
Thu Oct 5 18:13:15 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org> Thu Oct 5 18:13:15 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* debugXML.c testXPath.c xpath.[ch]: got pissed by some nastyness * debugXML.c testXPath.c xpath.[ch]: got pissed by some nastiness
in the XPath engine, rewrote large parts of it, now it's far in the XPath engine, rewrote large parts of it, now it's far
cleaner and in sync with the REC not an old WD. Fixed a parsing cleaner and in sync with the REC not an old WD. Fixed a parsing
problem in the interactive XML shell found when testing XPath. problem in the interactive XML shell found when testing XPath.
@ -18895,7 +18895,7 @@ Tue Dec 21 14:29:34 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* result/HTML/*.htm*: Updated the HTML examples regression tests output * result/HTML/*.htm*: Updated the HTML examples regression tests output
* SAX.c tree.c: fixed bug on defaulting namespaces on attributes * SAX.c tree.c: fixed bug on defaulting namespaces on attributes
* debugXML.c: fixed a bug on printing default namespaces. * debugXML.c: fixed a bug on printing default namespaces.
* HTMLtree.c: fixed a problem when outputing XML parsed docs as HTML * HTMLtree.c: fixed a problem when outputting XML parsed docs as HTML
Mon Dec 20 16:20:55 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org> Mon Dec 20 16:20:55 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
@ -18922,7 +18922,7 @@ Sat Dec 18 16:07:03 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
Thu Dec 16 16:19:29 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org> Thu Dec 16 16:19:29 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* tree.c: fixed a bug introduced in 1.8.0 and breaking default * tree.c: fixed a bug introduced in 1.8.0 and breaking default
namespace recognition, and Dia as a resul :-( namespace recognition, and Dia as a result :-(
* encoding.c: closed bug #3950 * encoding.c: closed bug #3950
Wed Dec 15 19:22:23 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org> Wed Dec 15 19:22:23 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
@ -18952,7 +18952,7 @@ Sun Dec 12 13:08:15 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
buffers instead, this was really needed, validation was breaking buffers instead, this was really needed, validation was breaking
in strange ways due to that. Added xmlParseStringPEReference() in strange ways due to that. Added xmlParseStringPEReference()
and other parsing from strings functions. Entities processing and other parsing from strings functions. Entities processing
modified again, but PERef are still not handled correcly but modified again, but PERef are still not handled correctly but
unless you're Eve Maller you won't notice :-) unless you're Eve Maller you won't notice :-)
* HTMLparser.c: large changes toward reliability, and switched to * HTMLparser.c: large changes toward reliability, and switched to
lowercase internal tags, XHTML is lowercase, so it will help lowercase internal tags, XHTML is lowercase, so it will help
@ -19042,8 +19042,8 @@ Mon Oct 25 12:13:25 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
a new release out a new release out
* HTMLparser.c: fixed auto-close bugs on list items, zeroing * HTMLparser.c: fixed auto-close bugs on list items, zeroing
some structures, comments before and after the some structures, comments before and after the
main element, and other nastyness main element, and other nastiness
* HTMLtree.c tree.c: accomodate the extended HTML supported * HTMLtree.c tree.c: accommodate the extended HTML supported
* configure.in: pushing 1.7.4 * configure.in: pushing 1.7.4
* test/ent8 and related outputs : added a new test for bug #2784 * test/ent8 and related outputs : added a new test for bug #2784
* test/HTML/wired.html and related output: a nasty HTML example * test/HTML/wired.html and related output: a nasty HTML example
@ -19450,7 +19450,7 @@ Sun Jan 31 22:06:48 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* valid.[ch], tree.c, parser.c : more work toward full parsing * valid.[ch], tree.c, parser.c : more work toward full parsing
of XML DTDs. of XML DTDs.
* README: added informations about mailing-list and on-line * README: added information about mailing-list and on-line
documentation documentation
1999-01-27 Raja R Harinath <harinath@cs.umn.edu> 1999-01-27 Raja R Harinath <harinath@cs.umn.edu>
@ -19535,7 +19535,7 @@ Thu Oct 29 00:48:45 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
Wed Oct 28 17:56:35 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org> Wed Oct 28 17:56:35 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* tree.[ch]: more cleanup on the API, made the tree mor conformant. * tree.[ch]: more cleanup on the API, made the tree more conformant.
Tue Oct 27 17:54:00 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org> Tue Oct 27 17:54:00 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
@ -19594,7 +19594,7 @@ Sat Oct 17 02:43:21 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
Tue Oct 13 21:46:57 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org> Tue Oct 13 21:46:57 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* tree.h, tree.c, parser.c: added prev and doc pointers to Node, * tree.h, tree.c, parser.c: added prev and doc pointers to Node,
and changed NODEs contants for conformity with DOM Level 1 and changed NODEs constants for conformity with DOM Level 1
Wed Oct 7 23:42:46 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org> Wed Oct 7 23:42:46 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
@ -19631,7 +19631,7 @@ Mon Sep 21 20:11:13 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
1998-08-20 Raja R Harinath <harinath@cs.umn.edu> 1998-08-20 Raja R Harinath <harinath@cs.umn.edu>
* error.h: New file. Contains prototyes from `error.c'. * error.h: New file. Contains prototypes from `error.c'.
Thu Aug 13 19:02:34 1998 Tom Tromey <tromey@cygnus.com> Thu Aug 13 19:02:34 1998 Tom Tromey <tromey@cygnus.com>
@ -19662,13 +19662,13 @@ Sun Jul 26 17:29:52 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
Sun Jul 26 00:17:51 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org> Sun Jul 26 00:17:51 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in: added test for CPP * configure.in: added test for CPP
* AUTHORS, Changelog: the original ones didn't get commited but the * AUTHORS, Changelog: the original ones didn't get committed but the
glib ones instead, fixed. glib ones instead, fixed.
* Makefile.am: corrected an error in library naming * Makefile.am: corrected an error in library naming
Fri Jul 24 16:47:14 1998 Daniel Veillard <Daniel.Veillard@w3.org> Fri Jul 24 16:47:14 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* integrated code developped at W3C * integrated code developed at W3C
* changed the original Copyright * changed the original Copyright
* migrated to automake * migrated to automake
* prefixed the filenames by xml_ to avoid filename clashes * prefixed the filenames by xml_ to avoid filename clashes

File diff suppressed because it is too large Load diff

View file

@ -226,7 +226,7 @@ found_head:
found_meta: found_meta:
/* /*
* Search and update all the remaining the meta elements carrying * Search and update all the remaining the meta elements carrying
* encoding informations * encoding information
*/ */
while (cur != NULL) { while (cur != NULL) {
if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
@ -345,7 +345,7 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
************************************************************************/ ************************************************************************/
/** /**
* htmlSaveErrMemory: * htmlSaveErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -359,7 +359,7 @@ htmlSaveErrMemory(const char *extra)
* htmlSaveErr: * htmlSaveErr:
* @code: the error number * @code: the error number
* @node: the location of the error. * @node: the location of the error.
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -518,7 +518,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
buf = xmlOutputBufferCreateFile(out, handler); buf = xmlOutputBufferCreateFile(out, handler);
if (buf == NULL) return(0); if (buf == NULL) return(0);
htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format); htmlNodeDumpFormatOutput(buf, doc, cur, NULL, format);
ret = xmlOutputBufferClose(buf); ret = xmlOutputBufferClose(buf);
return(ret); return(ret);
@ -670,13 +670,11 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the attribute pointer * @cur: the attribute pointer
* @encoding: the encoding string
* *
* Dump an HTML attribute * Dump an HTML attribute
*/ */
static void static void
htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
const char *encoding ATTRIBUTE_UNUSED) {
xmlChar *value; xmlChar *value;
/* /*
@ -706,49 +704,22 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
(!xmlStrcasecmp(cur->name, BAD_CAST "src")) || (!xmlStrcasecmp(cur->name, BAD_CAST "src")) ||
((!xmlStrcasecmp(cur->name, BAD_CAST "name")) && ((!xmlStrcasecmp(cur->name, BAD_CAST "name")) &&
(!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) { (!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) {
xmlChar *escaped;
xmlChar *tmp = value; xmlChar *tmp = value;
/* xmlURIEscapeStr() escapes '"' so it can be safely used. */
xmlBufCCat(buf->buffer, "\"");
while (IS_BLANK_CH(*tmp)) tmp++; while (IS_BLANK_CH(*tmp)) tmp++;
/* URI Escape everything, except server side includes. */ /*
for ( ; ; ) { * the < and > have already been escaped at the entity level
xmlChar *escaped; * And doing so here breaks server side includes
xmlChar endChar; */
xmlChar *end = NULL; escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+<>");
xmlChar *start = (xmlChar *)xmlStrstr(tmp, BAD_CAST "<!--"); if (escaped != NULL) {
if (start != NULL) { xmlBufWriteQuotedString(buf->buffer, escaped);
end = (xmlChar *)xmlStrstr(tmp, BAD_CAST "-->"); xmlFree(escaped);
if (end != NULL) { } else {
*start = '\0'; xmlBufWriteQuotedString(buf->buffer, value);
}
}
/* Escape the whole string, or until start (set to '\0'). */
escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
if (escaped != NULL) {
xmlBufCat(buf->buffer, escaped);
xmlFree(escaped);
} else {
xmlBufCat(buf->buffer, tmp);
}
if (end == NULL) { /* Everything has been written. */
break;
}
/* Do not escape anything within server side includes. */
*start = '<'; /* Restore the first character of "<!--". */
end += 3; /* strlen("-->") */
endChar = *end;
*end = '\0';
xmlBufCat(buf->buffer, start);
*end = endChar;
tmp = end;
} }
xmlBufCCat(buf->buffer, "\"");
} else { } else {
xmlBufWriteQuotedString(buf->buffer, value); xmlBufWriteQuotedString(buf->buffer, value);
} }
@ -759,63 +730,22 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
} }
} }
/**
* htmlAttrListDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @cur: the first attribute pointer
* @encoding: the encoding string
*
* Dump a list of HTML attributes
*/
static void
htmlAttrListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const char *encoding) {
if (cur == NULL) {
return;
}
while (cur != NULL) {
htmlAttrDumpOutput(buf, doc, cur, encoding);
cur = cur->next;
}
}
/**
* htmlNodeListDumpOutput:
* @buf: the HTML buffer output
* @doc: the document
* @cur: the first node
* @encoding: the encoding string
* @format: should formatting spaces been added
*
* Dump an HTML node list, recursive behaviour,children are printed too.
*/
static void
htmlNodeListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlNodePtr cur, const char *encoding, int format) {
if (cur == NULL) {
return;
}
while (cur != NULL) {
htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format);
cur = cur->next;
}
}
/** /**
* htmlNodeDumpFormatOutput: * htmlNodeDumpFormatOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the current node * @cur: the current node
* @encoding: the encoding string * @encoding: the encoding string (unused)
* @format: should formatting spaces been added * @format: should formatting spaces been added
* *
* Dump an HTML node, recursive behaviour,children are printed too. * Dump an HTML node, recursive behaviour,children are printed too.
*/ */
void void
htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlNodePtr cur, const char *encoding, int format) { xmlNodePtr cur, const char *encoding ATTRIBUTE_UNUSED,
int format) {
xmlNodePtr root;
xmlAttrPtr attr;
const htmlElemDesc * info; const htmlElemDesc * info;
xmlInitParser(); xmlInitParser();
@ -823,172 +753,199 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
if ((cur == NULL) || (buf == NULL)) { if ((cur == NULL) || (buf == NULL)) {
return; return;
} }
/*
* Special cases.
*/
if (cur->type == XML_DTD_NODE)
return;
if ((cur->type == XML_HTML_DOCUMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE)){
htmlDocContentDumpOutput(buf, (xmlDocPtr) cur, encoding);
return;
}
if (cur->type == XML_ATTRIBUTE_NODE) {
htmlAttrDumpOutput(buf, doc, (xmlAttrPtr) cur, encoding);
return;
}
if (cur->type == HTML_TEXT_NODE) {
if (cur->content != NULL) {
if (((cur->name == (const xmlChar *)xmlStringText) ||
(cur->name != (const xmlChar *)xmlStringTextNoenc)) &&
((cur->parent == NULL) ||
((xmlStrcasecmp(cur->parent->name, BAD_CAST "script")) &&
(xmlStrcasecmp(cur->parent->name, BAD_CAST "style"))))) {
xmlChar *buffer;
buffer = xmlEncodeEntitiesReentrant(doc, cur->content); root = cur;
if (buffer != NULL) { while (1) {
xmlOutputBufferWriteString(buf, (const char *)buffer); switch (cur->type) {
xmlFree(buffer); case XML_HTML_DOCUMENT_NODE:
} case XML_DOCUMENT_NODE:
} else { if (((xmlDocPtr) cur)->intSubset != NULL) {
xmlOutputBufferWriteString(buf, (const char *)cur->content); htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL);
} }
} if (cur->children != NULL) {
return; cur = cur->children;
} continue;
if (cur->type == HTML_COMMENT_NODE) { }
if (cur->content != NULL) { break;
xmlOutputBufferWriteString(buf, "<!--");
xmlOutputBufferWriteString(buf, (const char *)cur->content);
xmlOutputBufferWriteString(buf, "-->");
}
return;
}
if (cur->type == HTML_PI_NODE) {
if (cur->name == NULL)
return;
xmlOutputBufferWriteString(buf, "<?");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, " ");
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
xmlOutputBufferWriteString(buf, ">");
return;
}
if (cur->type == HTML_ENTITY_REF_NODE) {
xmlOutputBufferWriteString(buf, "&");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
xmlOutputBufferWriteString(buf, ";");
return;
}
if (cur->type == HTML_PRESERVE_NODE) {
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
return;
}
/* case XML_ELEMENT_NODE:
* Get specific HTML info for that node. /*
*/ * Get specific HTML info for that node.
if (cur->ns == NULL) */
info = htmlTagLookup(cur->name); if (cur->ns == NULL)
else info = htmlTagLookup(cur->name);
info = NULL; else
info = NULL;
xmlOutputBufferWriteString(buf, "<"); xmlOutputBufferWriteString(buf, "<");
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
xmlOutputBufferWriteString(buf, ":");
}
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->nsDef)
xmlNsListDumpOutput(buf, cur->nsDef);
if (cur->properties != NULL)
htmlAttrListDumpOutput(buf, doc, cur->properties, encoding);
if ((info != NULL) && (info->empty)) {
xmlOutputBufferWriteString(buf, ">");
if ((format) && (!info->isinline) && (cur->next != NULL)) {
if ((cur->next->type != HTML_TEXT_NODE) &&
(cur->next->type != HTML_ENTITY_REF_NODE) &&
(cur->parent != NULL) &&
(cur->parent->name != NULL) &&
(cur->parent->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, "\n");
}
return;
}
if (((cur->type == XML_ELEMENT_NODE) || (cur->content == NULL)) &&
(cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) &&
(xmlStrcmp(BAD_CAST info->name, BAD_CAST "html")) &&
(xmlStrcmp(BAD_CAST info->name, BAD_CAST "body"))) {
xmlOutputBufferWriteString(buf, ">");
} else {
xmlOutputBufferWriteString(buf, "></");
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix); xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
xmlOutputBufferWriteString(buf, ":"); xmlOutputBufferWriteString(buf, ":");
} }
xmlOutputBufferWriteString(buf, (const char *)cur->name); xmlOutputBufferWriteString(buf, (const char *)cur->name);
xmlOutputBufferWriteString(buf, ">"); if (cur->nsDef)
} xmlNsListDumpOutput(buf, cur->nsDef);
if ((format) && (cur->next != NULL) && attr = cur->properties;
(info != NULL) && (!info->isinline)) { while (attr != NULL) {
if ((cur->next->type != HTML_TEXT_NODE) && htmlAttrDumpOutput(buf, doc, attr);
(cur->next->type != HTML_ENTITY_REF_NODE) && attr = attr->next;
(cur->parent != NULL) && }
(cur->parent->name != NULL) &&
(cur->parent->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, "\n");
}
return;
}
xmlOutputBufferWriteString(buf, ">");
if ((cur->type != XML_ELEMENT_NODE) &&
(cur->content != NULL)) {
/*
* Uses the OutputBuffer property to automatically convert
* invalids to charrefs
*/
xmlOutputBufferWriteString(buf, (const char *) cur->content); if ((info != NULL) && (info->empty)) {
} xmlOutputBufferWriteString(buf, ">");
if (cur->children != NULL) { } else if (cur->children == NULL) {
if ((format) && (info != NULL) && (!info->isinline) && if ((info != NULL) && (info->saveEndTag != 0) &&
(cur->children->type != HTML_TEXT_NODE) && (xmlStrcmp(BAD_CAST info->name, BAD_CAST "html")) &&
(cur->children->type != HTML_ENTITY_REF_NODE) && (xmlStrcmp(BAD_CAST info->name, BAD_CAST "body"))) {
(cur->children != cur->last) && xmlOutputBufferWriteString(buf, ">");
(cur->name != NULL) && } else {
(cur->name[0] != 'p')) /* p, pre, param */ xmlOutputBufferWriteString(buf, "></");
xmlOutputBufferWriteString(buf, "\n"); if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
htmlNodeListDumpOutput(buf, doc, cur->children, encoding, format); xmlOutputBufferWriteString(buf,
if ((format) && (info != NULL) && (!info->isinline) && (const char *)cur->ns->prefix);
(cur->last->type != HTML_TEXT_NODE) && xmlOutputBufferWriteString(buf, ":");
(cur->last->type != HTML_ENTITY_REF_NODE) && }
(cur->children != cur->last) && xmlOutputBufferWriteString(buf, (const char *)cur->name);
(cur->name != NULL) && xmlOutputBufferWriteString(buf, ">");
(cur->name[0] != 'p')) /* p, pre, param */ }
xmlOutputBufferWriteString(buf, "\n"); } else {
} xmlOutputBufferWriteString(buf, ">");
xmlOutputBufferWriteString(buf, "</"); if ((format) && (info != NULL) && (!info->isinline) &&
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { (cur->children->type != HTML_TEXT_NODE) &&
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix); (cur->children->type != HTML_ENTITY_REF_NODE) &&
xmlOutputBufferWriteString(buf, ":"); (cur->children != cur->last) &&
} (cur->name != NULL) &&
xmlOutputBufferWriteString(buf, (const char *)cur->name); (cur->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, ">"); xmlOutputBufferWriteString(buf, "\n");
if ((format) && (info != NULL) && (!info->isinline) && cur = cur->children;
(cur->next != NULL)) { continue;
if ((cur->next->type != HTML_TEXT_NODE) && }
(cur->next->type != HTML_ENTITY_REF_NODE) &&
(cur->parent != NULL) && if ((format) && (cur->next != NULL) &&
(cur->parent->name != NULL) && (info != NULL) && (!info->isinline)) {
(cur->parent->name[0] != 'p')) /* p, pre, param */ if ((cur->next->type != HTML_TEXT_NODE) &&
xmlOutputBufferWriteString(buf, "\n"); (cur->next->type != HTML_ENTITY_REF_NODE) &&
(cur->parent != NULL) &&
(cur->parent->name != NULL) &&
(cur->parent->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, "\n");
}
break;
case XML_ATTRIBUTE_NODE:
htmlAttrDumpOutput(buf, doc, (xmlAttrPtr) cur);
break;
case HTML_TEXT_NODE:
if (cur->content == NULL)
break;
if (((cur->name == (const xmlChar *)xmlStringText) ||
(cur->name != (const xmlChar *)xmlStringTextNoenc)) &&
((cur->parent == NULL) ||
((xmlStrcasecmp(cur->parent->name, BAD_CAST "script")) &&
(xmlStrcasecmp(cur->parent->name, BAD_CAST "style"))))) {
xmlChar *buffer;
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
if (buffer != NULL) {
xmlOutputBufferWriteString(buf, (const char *)buffer);
xmlFree(buffer);
}
} else {
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
break;
case HTML_COMMENT_NODE:
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, "<!--");
xmlOutputBufferWriteString(buf, (const char *)cur->content);
xmlOutputBufferWriteString(buf, "-->");
}
break;
case HTML_PI_NODE:
if (cur->name != NULL) {
xmlOutputBufferWriteString(buf, "<?");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, " ");
xmlOutputBufferWriteString(buf,
(const char *)cur->content);
}
xmlOutputBufferWriteString(buf, ">");
}
break;
case HTML_ENTITY_REF_NODE:
xmlOutputBufferWriteString(buf, "&");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
xmlOutputBufferWriteString(buf, ";");
break;
case HTML_PRESERVE_NODE:
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
break;
default:
break;
}
while (1) {
if (cur == root)
return;
if (cur->next != NULL) {
cur = cur->next;
break;
}
/*
* The parent should never be NULL here but we want to handle
* corrupted documents gracefully.
*/
if (cur->parent == NULL)
return;
cur = cur->parent;
if ((cur->type == XML_HTML_DOCUMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE)) {
xmlOutputBufferWriteString(buf, "\n");
} else {
if ((format) && (cur->ns == NULL))
info = htmlTagLookup(cur->name);
else
info = NULL;
if ((format) && (info != NULL) && (!info->isinline) &&
(cur->last->type != HTML_TEXT_NODE) &&
(cur->last->type != HTML_ENTITY_REF_NODE) &&
(cur->children != cur->last) &&
(cur->name != NULL) &&
(cur->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, "\n");
xmlOutputBufferWriteString(buf, "</");
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
xmlOutputBufferWriteString(buf, ":");
}
xmlOutputBufferWriteString(buf, (const char *)cur->name);
xmlOutputBufferWriteString(buf, ">");
if ((format) && (info != NULL) && (!info->isinline) &&
(cur->next != NULL)) {
if ((cur->next->type != HTML_TEXT_NODE) &&
(cur->next->type != HTML_ENTITY_REF_NODE) &&
(cur->parent != NULL) &&
(cur->parent->name != NULL) &&
(cur->parent->name[0] != 'p')) /* p, pre, param */
xmlOutputBufferWriteString(buf, "\n");
}
}
}
} }
} }
@ -997,63 +954,45 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @doc: the document * @doc: the document
* @cur: the current node * @cur: the current node
* @encoding: the encoding string * @encoding: the encoding string (unused)
* *
* Dump an HTML node, recursive behaviour,children are printed too, * Dump an HTML node, recursive behaviour,children are printed too,
* and formatting returns/spaces are added. * and formatting returns/spaces are added.
*/ */
void void
htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlNodePtr cur, const char *encoding) { xmlNodePtr cur, const char *encoding ATTRIBUTE_UNUSED) {
htmlNodeDumpFormatOutput(buf, doc, cur, encoding, 1); htmlNodeDumpFormatOutput(buf, doc, cur, NULL, 1);
} }
/** /**
* htmlDocContentDumpFormatOutput: * htmlDocContentDumpFormatOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @cur: the document * @cur: the document
* @encoding: the encoding string * @encoding: the encoding string (unused)
* @format: should formatting spaces been added * @format: should formatting spaces been added
* *
* Dump an HTML document. * Dump an HTML document.
*/ */
void void
htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
const char *encoding, int format) { const char *encoding ATTRIBUTE_UNUSED,
int type; int format) {
htmlNodeDumpFormatOutput(buf, cur, (xmlNodePtr) cur, NULL, format);
xmlInitParser();
if ((buf == NULL) || (cur == NULL))
return;
/*
* force to output the stuff as HTML, especially for entities
*/
type = cur->type;
cur->type = XML_HTML_DOCUMENT_NODE;
if (cur->intSubset != NULL) {
htmlDtdDumpOutput(buf, cur, NULL);
}
if (cur->children != NULL) {
htmlNodeListDumpOutput(buf, cur, cur->children, encoding, format);
}
xmlOutputBufferWriteString(buf, "\n");
cur->type = (xmlElementType) type;
} }
/** /**
* htmlDocContentDumpOutput: * htmlDocContentDumpOutput:
* @buf: the HTML buffer output * @buf: the HTML buffer output
* @cur: the document * @cur: the document
* @encoding: the encoding string * @encoding: the encoding string (unused)
* *
* Dump an HTML document. Formatting return/spaces are added. * Dump an HTML document. Formatting return/spaces are added.
*/ */
void void
htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
const char *encoding) { const char *encoding ATTRIBUTE_UNUSED) {
htmlDocContentDumpFormatOutput(buf, cur, encoding, 1); htmlNodeDumpFormatOutput(buf, cur, (xmlNodePtr) cur, NULL, 1);
} }
/************************************************************************ /************************************************************************

View file

@ -19,7 +19,7 @@ To assert build quality:
There is 3 standalone tools runtest.c runsuite.c testapi.c, which There is 3 standalone tools runtest.c runsuite.c testapi.c, which
should compile as part of the build or as any application would. should compile as part of the build or as any application would.
Launch them from this directory to get results, runtest checks Launch them from this directory to get results, runtest checks
the proper functionning of libxml2 main APIs while testapi does the proper functioning of libxml2 main APIs while testapi does
a full coverage check. Report failures to the list. a full coverage check. Report failures to the list.
To report bugs, follow the instructions at: To report bugs, follow the instructions at:

View file

@ -590,36 +590,6 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
} else { } else {
ret = xmlGetDocEntity(ctxt->myDoc, name); ret = xmlGetDocEntity(ctxt->myDoc, name);
} }
if ((ret != NULL) &&
((ctxt->validate) || (ctxt->replaceEntities)) &&
(ret->children == NULL) &&
(ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
int val;
/*
* for validation purposes we really need to fetch and
* parse the external entity
*/
xmlNodePtr children;
unsigned long oldnbent = ctxt->nbentities;
val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
ret->ExternalID, &children);
if (val == 0) {
xmlAddChildList((xmlNodePtr) ret, children);
} else {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
"Failure to process entity %s\n", name, NULL);
ctxt->validate = 0;
return(NULL);
}
ret->owner = 1;
if (ret->checked == 0) {
ret->checked = (ctxt->nbentities - oldnbent + 1) * 2;
if ((ret->content != NULL) && (xmlStrchr(ret->content, '<')))
ret->checked |= 1;
}
}
return(ret); return(ret);
} }
@ -1693,23 +1663,23 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
} }
} }
/* if (!ctxt->html) {
* Insert all the defaulted attributes from the DTD especially namespaces /*
*/ * Insert all the defaulted attributes from the DTD especially
if ((!ctxt->html) && * namespaces
((ctxt->myDoc->intSubset != NULL) || */
(ctxt->myDoc->extSubset != NULL))) { if ((ctxt->myDoc->intSubset != NULL) ||
xmlCheckDefaultedAttributes(ctxt, name, prefix, atts); (ctxt->myDoc->extSubset != NULL)) {
} xmlCheckDefaultedAttributes(ctxt, name, prefix, atts);
}
/* /*
* process all the attributes whose name start with "xmlns" * process all the attributes whose name start with "xmlns"
*/ */
if (atts != NULL) { if (atts != NULL) {
i = 0; i = 0;
att = atts[i++]; att = atts[i++];
value = atts[i++]; value = atts[i++];
if (!ctxt->html) {
while ((att != NULL) && (value != NULL)) { while ((att != NULL) && (value != NULL)) {
if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') && if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') &&
(att[3] == 'n') && (att[4] == 's')) (att[3] == 'n') && (att[4] == 's'))
@ -1718,30 +1688,30 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
att = atts[i++]; att = atts[i++];
value = atts[i++]; value = atts[i++];
} }
} }
}
/* /*
* Search the namespace, note that since the attributes have been * Search the namespace, note that since the attributes have been
* processed, the local namespaces are available. * processed, the local namespaces are available.
*/ */
ns = xmlSearchNs(ctxt->myDoc, ret, prefix); ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
if ((ns == NULL) && (parent != NULL)) if ((ns == NULL) && (parent != NULL))
ns = xmlSearchNs(ctxt->myDoc, parent, prefix); ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
if ((prefix != NULL) && (ns == NULL)) { if ((prefix != NULL) && (ns == NULL)) {
ns = xmlNewNs(ret, NULL, prefix); ns = xmlNewNs(ret, NULL, prefix);
xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE, xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
"Namespace prefix %s is not defined\n", "Namespace prefix %s is not defined\n",
prefix, NULL); prefix, NULL);
} }
/* /*
* set the namespace node, making sure that if the default namespace * set the namespace node, making sure that if the default namespace
* is unbound on a parent we simply keep it NULL * is unbound on a parent we simply keep it NULL
*/ */
if ((ns != NULL) && (ns->href != NULL) && if ((ns != NULL) && (ns->href != NULL) &&
((ns->href[0] != 0) || (ns->prefix != NULL))) ((ns->href[0] != 0) || (ns->prefix != NULL)))
xmlSetNs(ret, ns); xmlSetNs(ret, ns);
}
/* /*
* process all the other attributes * process all the other attributes
@ -2203,7 +2173,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
* attribute values. * attribute values.
* *
* SAX2 callback when an element start has been detected by the parser. * SAX2 callback when an element start has been detected by the parser.
* It provides the namespace informations for the element, as well as * It provides the namespace information for the element, as well as
* the new namespace declarations on the element. * the new namespace declarations on the element.
*/ */
void void
@ -2456,7 +2426,7 @@ xmlSAX2StartElementNs(void *ctx,
* @URI: the element namespace name if available * @URI: the element namespace name if available
* *
* SAX2 callback when an element end has been detected by the parser. * SAX2 callback when an element end has been detected by the parser.
* It provides the namespace informations for the element. * It provides the namespace information for the element.
*/ */
void void
xmlSAX2EndElementNs(void *ctx, xmlSAX2EndElementNs(void *ctx,
@ -2523,20 +2493,21 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
} }
/** /**
* xmlSAX2Characters: * xmlSAX2Text:
* @ctx: the user data (XML parser context) * @ctx: the user data (XML parser context)
* @ch: a xmlChar string * @ch: a xmlChar string
* @len: the number of xmlChar * @len: the number of xmlChar
* @type: text or cdata
* *
* receiving some chars from the parser. * Append characters.
*/ */
void static void
xmlSAX2Characters(void *ctx, const xmlChar *ch, int len) xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len,
xmlElementType type)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNodePtr lastChild; xmlNodePtr lastChild;
if (ctx == NULL) return; if (ctxt == NULL) return;
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len); "SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len);
@ -2565,7 +2536,10 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
* elements. Use an attribute in the structure !!! * elements. Use an attribute in the structure !!!
*/ */
if (lastChild == NULL) { if (lastChild == NULL) {
lastChild = xmlSAX2TextNode(ctxt, ch, len); if (type == XML_TEXT_NODE)
lastChild = xmlSAX2TextNode(ctxt, ch, len);
else
lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
if (lastChild != NULL) { if (lastChild != NULL) {
ctxt->node->children = lastChild; ctxt->node->children = lastChild;
ctxt->node->last = lastChild; ctxt->node->last = lastChild;
@ -2579,8 +2553,9 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
} }
} else { } else {
int coalesceText = (lastChild != NULL) && int coalesceText = (lastChild != NULL) &&
(lastChild->type == XML_TEXT_NODE) && (lastChild->type == type) &&
(lastChild->name == xmlStringText); ((type != XML_TEXT_NODE) ||
(lastChild->name == xmlStringText));
if ((coalesceText) && (ctxt->nodemem != 0)) { if ((coalesceText) && (ctxt->nodemem != 0)) {
/* /*
* The whole point of maintaining nodelen and nodemem, * The whole point of maintaining nodelen and nodemem,
@ -2637,7 +2612,10 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
} }
} else { } else {
/* Mixed content, first time */ /* Mixed content, first time */
lastChild = xmlSAX2TextNode(ctxt, ch, len); if (type == XML_TEXT_NODE)
lastChild = xmlSAX2TextNode(ctxt, ch, len);
else
lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
if (lastChild != NULL) { if (lastChild != NULL) {
xmlAddChild(ctxt->node, lastChild); xmlAddChild(ctxt->node, lastChild);
if (ctxt->node->children != NULL) { if (ctxt->node->children != NULL) {
@ -2649,6 +2627,20 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
} }
} }
/**
* xmlSAX2Characters:
* @ctx: the user data (XML parser context)
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* receiving some chars from the parser.
*/
void
xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
{
xmlSAX2Text((xmlParserCtxtPtr) ctx, ch, len, XML_TEXT_NODE);
}
/** /**
* xmlSAX2IgnorableWhitespace: * xmlSAX2IgnorableWhitespace:
* @ctx: the user data (XML parser context) * @ctx: the user data (XML parser context)
@ -2805,27 +2797,7 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
void void
xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len) xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlSAX2Text((xmlParserCtxtPtr) ctx, value, len, XML_CDATA_SECTION_NODE);
xmlNodePtr ret, lastChild;
if (ctx == NULL) return;
#ifdef DEBUG_SAX
xmlGenericError(xmlGenericErrorContext,
"SAX.pcdata(%.10s, %d)\n", value, len);
#endif
lastChild = xmlGetLastChild(ctxt->node);
#ifdef DEBUG_SAX_TREE
xmlGenericError(xmlGenericErrorContext,
"add chars to %s \n", ctxt->node->name);
#endif
if ((lastChild != NULL) &&
(lastChild->type == XML_CDATA_SECTION_NODE)) {
xmlTextConcat(lastChild, value, len);
} else {
ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
if (xmlAddChild(ctxt->node, ret) == NULL)
xmlFreeNode(ret);
}
} }
static int xmlSAX2DefaultVersionValue = 2; static int xmlSAX2DefaultVersionValue = 2;

View file

@ -202,7 +202,7 @@ Done:
by the XML parser, UTF-8 should be checked when there is no "encoding" by the XML parser, UTF-8 should be checked when there is no "encoding"
declared ! declared !
- Support for UTF-8 and UTF-16 encoding - Support for UTF-8 and UTF-16 encoding
=> added some convertion routines provided by Martin Durst => added some conversion routines provided by Martin Durst
patched them, got fixes from @@@ patched them, got fixes from @@@
I plan to keep everything internally as UTF-8 (or ISO-Latin-X) I plan to keep everything internally as UTF-8 (or ISO-Latin-X)
this is slightly more costly but more compact, and recent processors this is slightly more costly but more compact, and recent processors
@ -212,7 +212,7 @@ Done:
is enabled, tested the ISO->UTF-8 stuff is enabled, tested the ISO->UTF-8 stuff
- External entities loading: - External entities loading:
- allow override by client code - allow override by client code
- make sure it is alled for all external entities referenced - make sure it is called for all external entities referenced
Done, client code should use xmlSetExternalEntityLoader() to set Done, client code should use xmlSetExternalEntityLoader() to set
the default loading routine. It will be called each time an external the default loading routine. It will be called each time an external
entity entity resolution is triggered. entity entity resolution is triggered.
@ -245,8 +245,8 @@ Done:
most cases ! most cases !
- progressive reading. The entity support is a first step toward - progressive reading. The entity support is a first step toward
asbtraction of an input stream. A large part of the context is still abstraction of an input stream. A large part of the context is still
located on the stack, moving to a state machine and putting everyting located on the stack, moving to a state machine and putting everything
in the parsing context should provide an adequate solution. in the parsing context should provide an adequate solution.
=> Rather than progressive parsing, give more power to the SAX-like => Rather than progressive parsing, give more power to the SAX-like
interface. Currently the DOM-like representation is built but interface. Currently the DOM-like representation is built but

View file

@ -83,7 +83,7 @@ struct _xmlBuf {
/** /**
* xmlBufMemoryError: * xmlBufMemoryError:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
* To be improved... * To be improved...
@ -98,7 +98,7 @@ xmlBufMemoryError(xmlBufPtr buf, const char *extra)
/** /**
* xmlBufOverflowError: * xmlBufOverflowError:
* @extra: extra informations * @extra: extra information
* *
* Handle a buffer overflow error * Handle a buffer overflow error
* To be improved... * To be improved...
@ -1233,10 +1233,12 @@ xmlBufBackToBuffer(xmlBufPtr buf) {
* Keep the buffer but provide a truncated size value. * Keep the buffer but provide a truncated size value.
*/ */
xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer"); xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer");
ret->use = (int) buf->use;
ret->size = INT_MAX; ret->size = INT_MAX;
} else {
ret->use = (int) buf->use;
ret->size = (int) buf->size;
} }
ret->use = (int) buf->use;
ret->size = (int) buf->size;
ret->alloc = buf->alloc; ret->alloc = buf->alloc;
ret->content = buf->content; ret->content = buf->content;
ret->contentIO = buf->contentIO; ret->contentIO = buf->contentIO;
@ -1332,8 +1334,12 @@ xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input) {
int int
xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
size_t base, size_t cur) { size_t base, size_t cur) {
if ((input == NULL) || (buf == NULL) || (buf->error)) if (input == NULL)
return(-1); return(-1);
if ((buf == NULL) || (buf->error)) {
input->base = input->cur = input->end = BAD_CAST "";
return(-1);
}
CHECK_COMPAT(buf) CHECK_COMPAT(buf)
input->base = &buf->content[base]; input->base = &buf->content[base];
input->cur = input->base + cur; input->cur = input->base + cur;

View file

@ -132,7 +132,7 @@ static xmlChar *xmlC11NNormalizeString(const xmlChar * input,
/** /**
* xmlC14NErrMemory: * xmlC14NErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of memory error * Handle a redefinition of memory error
*/ */
@ -147,7 +147,7 @@ xmlC14NErrMemory(const char *extra)
/** /**
* xmlC14NErrParam: * xmlC14NErrParam:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of param error * Handle a redefinition of param error
*/ */
@ -162,7 +162,7 @@ xmlC14NErrParam(const char *extra)
/** /**
* xmlC14NErrInternal: * xmlC14NErrInternal:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of internal error * Handle a redefinition of internal error
*/ */
@ -177,7 +177,7 @@ xmlC14NErrInternal(const char *extra)
/** /**
* xmlC14NErrInvalidNode: * xmlC14NErrInvalidNode:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of invalid node error * Handle a redefinition of invalid node error
*/ */
@ -192,7 +192,7 @@ xmlC14NErrInvalidNode(const char *node_type, const char *extra)
/** /**
* xmlC14NErrUnknownNode: * xmlC14NErrUnknownNode:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of unknown node error * Handle a redefinition of unknown node error
*/ */
@ -207,7 +207,7 @@ xmlC14NErrUnknownNode(int node_type, const char *extra)
/** /**
* xmlC14NErrRelativeNamespace: * xmlC14NErrRelativeNamespace:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of relative namespace error * Handle a redefinition of relative namespace error
*/ */
@ -228,7 +228,7 @@ xmlC14NErrRelativeNamespace(const char *ns_uri)
* @node: the context node * @node: the context node
* @error: the error code * @error: the error code
* @msg: the message * @msg: the message
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -2033,13 +2033,13 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
} }
ret = xmlBufUse(buf->buffer); ret = xmlBufUse(buf->buffer);
if (ret > 0) { if (ret >= 0) {
*doc_txt_ptr = xmlStrndup(xmlBufContent(buf->buffer), ret); *doc_txt_ptr = xmlStrndup(xmlBufContent(buf->buffer), ret);
} }
(void) xmlOutputBufferClose(buf); (void) xmlOutputBufferClose(buf);
if ((*doc_txt_ptr == NULL) && (ret > 0)) { if ((*doc_txt_ptr == NULL) && (ret >= 0)) {
xmlC14NErrMemory("coping canonicalized document"); xmlC14NErrMemory("copying canonicalized document");
return (-1); return (-1);
} }
return (ret); return (ret);

View file

@ -216,7 +216,7 @@ static int xmlCatalogInitialized = 0;
/** /**
* xmlCatalogErrMemory: * xmlCatalogErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -234,7 +234,7 @@ xmlCatalogErrMemory(const char *extra)
* @catal: the Catalog entry * @catal: the Catalog entry
* @node: the context node * @node: the context node
* @msg: the error message * @msg: the error message
* @extra: extra informations * @extra: extra information
* *
* Handle a catalog error * Handle a catalog error
*/ */
@ -924,7 +924,7 @@ xmlParseCatalogFile(const char *filename) {
xmlBufResetInput(buf->buffer, inputStream); xmlBufResetInput(buf->buffer, inputStream);
inputPush(ctxt, inputStream); inputPush(ctxt, inputStream);
if ((ctxt->directory == NULL) && (directory == NULL)) if (ctxt->directory == NULL)
directory = xmlParserGetDirectory(filename); directory = xmlParserGetDirectory(filename);
if ((ctxt->directory == NULL) && (directory != NULL)) if ((ctxt->directory == NULL) && (directory != NULL))
ctxt->directory = directory; ctxt->directory = directory;
@ -2069,8 +2069,7 @@ xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
ret = xmlCatalogXMLResolve(catal->children, pubID, sysID); ret = xmlCatalogXMLResolve(catal->children, pubID, sysID);
if (ret != NULL) { if (ret != NULL) {
break; break;
} else if ((catal->children != NULL) && } else if (catal->children->depth > MAX_CATAL_DEPTH) {
(catal->children->depth > MAX_CATAL_DEPTH)) {
ret = NULL; ret = NULL;
break; break;
} }
@ -2353,7 +2352,7 @@ xmlParseSGMLCatalog(xmlCatalogPtr catal, const xmlChar *value,
xmlCatalogEntryType type = XML_CATA_NONE; xmlCatalogEntryType type = XML_CATA_NONE;
cur = xmlParseSGMLCatalogName(cur, &name); cur = xmlParseSGMLCatalogName(cur, &name);
if (name == NULL) { if (cur == NULL || name == NULL) {
/* error */ /* error */
break; break;
} }
@ -3254,6 +3253,7 @@ xmlLoadCatalogs(const char *pathss) {
while ((*cur != 0) && (*cur != PATH_SEPARATOR) && (!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);
if (path != NULL) {
#ifdef _WIN32 #ifdef _WIN32
iLen = strlen((const char*)path); iLen = strlen((const char*)path);
for(i = 0; i < iLen; i++) { for(i = 0; i < iLen; i++) {
@ -3262,7 +3262,6 @@ xmlLoadCatalogs(const char *pathss) {
} }
} }
#endif #endif
if (path != NULL) {
xmlLoadCatalog((const char *) path); xmlLoadCatalog((const char *) path);
xmlFree(path); xmlFree(path);
} }
@ -3427,9 +3426,10 @@ xmlCatalogAdd(const xmlChar *type, const xmlChar *orig, const xmlChar *replace)
(xmlStrEqual(type, BAD_CAST "catalog"))) { (xmlStrEqual(type, BAD_CAST "catalog"))) {
xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE,
xmlCatalogDefaultPrefer); xmlCatalogDefaultPrefer);
xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, if (xmlDefaultCatalog != NULL) {
xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL,
orig, NULL, xmlCatalogDefaultPrefer, NULL); orig, NULL, xmlCatalogDefaultPrefer, NULL);
}
xmlRMutexUnlock(xmlCatalogMutex); xmlRMutexUnlock(xmlCatalogMutex);
return(0); return(0);
} }

View file

@ -1,6 +1,9 @@
/* config.h. Generated from config.h.in by configure. */ /* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */ /* config.h.in. Generated from configure.in by autoheader. */
/* A form that will not confuse apibuild.py */
/* #undef ATTRIBUTE_DESTRUCTOR */
/* Type cast for the gethostbyname() argument */ /* Type cast for the gethostbyname() argument */
#define GETHOSTBYNAME_ARG_CAST #define GETHOSTBYNAME_ARG_CAST
@ -10,6 +13,9 @@
/* Define to 1 if you have the <arpa/nameser.h> header file. */ /* Define to 1 if you have the <arpa/nameser.h> header file. */
/* #undef HAVE_ARPA_NAMESER_H */ /* #undef HAVE_ARPA_NAMESER_H */
/* Define if __attribute__((destructor)) is accepted */
/* #undef HAVE_ATTRIBUTE_DESTRUCTOR */
/* Whether struct sockaddr::__ss_family exists */ /* Whether struct sockaddr::__ss_family exists */
/* #undef HAVE_BROKEN_SS_FAMILY */ /* #undef HAVE_BROKEN_SS_FAMILY */

View file

@ -1342,7 +1342,7 @@ xmlCtxtDumpDTD(xmlDebugCtxtPtr ctxt, xmlDtdPtr dtd)
* @output: the FILE * for the output * @output: the FILE * for the output
* @str: the string * @str: the string
* *
* Dumps informations about the string, shorten it if necessary * Dumps information about the string, shorten it if necessary
*/ */
void void
xmlDebugDumpString(FILE * output, const xmlChar * str) xmlDebugDumpString(FILE * output, const xmlChar * str)
@ -2190,7 +2190,7 @@ xmlShellRegisterRootNamespaces(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
* @node2: unused * @node2: unused
* *
* Implements the XML shell function "grep" * Implements the XML shell function "grep"
* dumps informations about the node (namespace, attributes, content). * dumps information about the node (namespace, attributes, content).
* *
* Returns 0 * Returns 0
*/ */
@ -2268,7 +2268,7 @@ xmlShellGrep(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
* @node2: unused * @node2: unused
* *
* Implements the XML shell function "dir" * Implements the XML shell function "dir"
* dumps informations about the node (namespace, attributes, content). * dumps information about the node (namespace, attributes, content).
* *
* Returns 0 * Returns 0
*/ */
@ -2302,7 +2302,7 @@ xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
* @node2: unused * @node2: unused
* *
* Implements the XML shell function "dir" * Implements the XML shell function "dir"
* dumps informations about the node (namespace, attributes, content). * dumps information about the node (namespace, attributes, content).
* *
* Returns 0 * Returns 0
*/ */
@ -2900,7 +2900,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output, "\tbye leave shell\n"); fprintf(ctxt->output, "\tbye leave shell\n");
fprintf(ctxt->output, "\tcat [node] display node or current node\n"); fprintf(ctxt->output, "\tcat [node] display node or current node\n");
fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n"); fprintf(ctxt->output, "\tcd [path] change directory to path or to root\n");
fprintf(ctxt->output, "\tdir [path] dumps informations about the node (namespace, attributes, content)\n"); fprintf(ctxt->output, "\tdir [path] dumps information about the node (namespace, attributes, content)\n");
fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n"); fprintf(ctxt->output, "\tdu [path] show the structure of the subtree under path or the current node\n");
fprintf(ctxt->output, "\texit leave shell\n"); fprintf(ctxt->output, "\texit leave shell\n");
fprintf(ctxt->output, "\thelp display this help\n"); fprintf(ctxt->output, "\thelp display this help\n");

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
* Author: daniel@veillard.com * Author: daniel@veillard.com
@ -452,7 +452,7 @@ xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) {
unsigned long value = seed; unsigned long value = seed;
if (name == NULL) return(0); if (name == NULL) return(0);
value = *name; value += *name;
value <<= 5; value <<= 5;
if (namelen > 10) { if (namelen > 10) {
value += name[namelen - 1]; value += name[namelen - 1];

View file

@ -76,7 +76,7 @@ static int xmlLittleEndian = 1;
/** /**
* xmlEncodingErrMemory: * xmlEncodingErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -170,7 +170,7 @@ closeIcuConverter(uconv_t *conv)
* Returns 0 if success, or -1 otherwise * Returns 0 if success, or -1 otherwise
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* if the return value is positive, else unpredictable. * if the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
static int static int
asciiToUTF8(unsigned char* out, int *outlen, asciiToUTF8(unsigned char* out, int *outlen,
@ -217,7 +217,7 @@ asciiToUTF8(unsigned char* out, int *outlen,
* Returns 0 if success, -2 if the transcoding fails, or -1 otherwise * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* if the return value is positive, else unpredictable. * if the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
static int static int
UTF8Toascii(unsigned char* out, int *outlen, UTF8Toascii(unsigned char* out, int *outlen,
@ -301,7 +301,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
* Returns the number of bytes written if success, or -1 otherwise * Returns the number of bytes written if success, or -1 otherwise
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* if the return value is positive, else unpredictable. * if the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
int int
isolat1ToUTF8(unsigned char* out, int *outlen, isolat1ToUTF8(unsigned char* out, int *outlen,
@ -373,6 +373,11 @@ UTF8ToUTF8(unsigned char* out, int *outlen,
if (len < 0) if (len < 0)
return(-1); return(-1);
/*
* FIXME: Conversion functions must assure valid UTF-8, so we have
* to check for UTF-8 validity. Preferably, this converter shouldn't
* be used at all.
*/
memcpy(out, inb, len); memcpy(out, inb, len);
*outlen = len; *outlen = len;
@ -396,7 +401,7 @@ UTF8ToUTF8(unsigned char* out, int *outlen,
or -1 otherwise or -1 otherwise
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* if the return value is positive, else unpredictable. * if the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
int int
UTF8Toisolat1(unsigned char* out, int *outlen, UTF8Toisolat1(unsigned char* out, int *outlen,
@ -496,13 +501,18 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
{ {
unsigned char* outstart = out; unsigned char* outstart = out;
const unsigned char* processed = inb; const unsigned char* processed = inb;
unsigned char* outend = out + *outlen; unsigned char* outend;
unsigned short* in = (unsigned short*) inb; unsigned short* in = (unsigned short*) inb;
unsigned short* inend; unsigned short* inend;
unsigned int c, d, inlen; unsigned int c, d, inlen;
unsigned char *tmp; unsigned char *tmp;
int bits; int bits;
if (*outlen == 0) {
*inlenb = 0;
return(0);
}
outend = out + *outlen;
if ((*inlenb % 2) == 1) if ((*inlenb % 2) == 1)
(*inlenb)--; (*inlenb)--;
inlen = *inlenb / 2; inlen = *inlenb / 2;
@ -1483,16 +1493,25 @@ xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
if ((handler == NULL) || (handlers == NULL)) { if ((handler == NULL) || (handlers == NULL)) {
xmlEncodingErr(XML_I18N_NO_HANDLER, xmlEncodingErr(XML_I18N_NO_HANDLER,
"xmlRegisterCharEncodingHandler: NULL handler !\n", NULL); "xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
return; goto free_handler;
} }
if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) { if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
xmlEncodingErr(XML_I18N_EXCESS_HANDLER, xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
"xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n", "xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
"MAX_ENCODING_HANDLERS"); "MAX_ENCODING_HANDLERS");
return; goto free_handler;
} }
handlers[nbCharEncodingHandler++] = handler; handlers[nbCharEncodingHandler++] = handler;
return;
free_handler:
if (handler != NULL) {
if (handler->name != NULL) {
xmlFree(handler->name);
}
xmlFree(handler);
}
} }
/** /**
@ -1784,7 +1803,7 @@ xmlFindCharEncodingHandler(const char *name) {
* @cd: iconv converter data structure * @cd: iconv converter data structure
* @out: a pointer to an array of bytes to store the result * @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out * @outlen: the length of @out
* @in: a pointer to an array of ISO Latin 1 chars * @in: a pointer to an array of input bytes
* @inlen: the length of @in * @inlen: the length of @in
* *
* Returns 0 if success, or * Returns 0 if success, or
@ -1795,7 +1814,7 @@ xmlFindCharEncodingHandler(const char *name) {
* *
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable. * as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
static int static int
xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen, xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
@ -1851,7 +1870,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
* @toUnicode : non-zero if toUnicode. 0 otherwise. * @toUnicode : non-zero if toUnicode. 0 otherwise.
* @out: a pointer to an array of bytes to store the result * @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out * @outlen: the length of @out
* @in: a pointer to an array of ISO Latin 1 chars * @in: a pointer to an array of input bytes
* @inlen: the length of @in * @inlen: the length of @in
* @flush: if true, indicates end of input * @flush: if true, indicates end of input
* *
@ -1863,7 +1882,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
* *
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable. * as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets consumed. * The value of @outlen after return is the number of octets produced.
*/ */
static int static int
xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen, xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
@ -1912,6 +1931,25 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
* * * *
************************************************************************/ ************************************************************************/
/**
* xmlEncInputChunk:
* @handler: encoding handler
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of input bytes
* @inlen: the length of @in
* @flush: flush (ICU-related)
*
* Returns 0 if success, or
* -1 by lack of space, or
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
* -3 if there the last byte can't form a single output char.
*
* The value of @inlen after return is the number of octets consumed
* as the return value is 0, else unpredictable.
* The value of @outlen after return is the number of octets produced.
*/
static int static int
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen, int flush) { int *outlen, const unsigned char *in, int *inlen, int flush) {
@ -1920,6 +1958,8 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
if (handler->input != NULL) { if (handler->input != NULL) {
ret = handler->input(out, outlen, in, inlen); ret = handler->input(out, outlen, in, inlen);
if (ret > 0)
ret = 0;
} }
#ifdef LIBXML_ICONV_ENABLED #ifdef LIBXML_ICONV_ENABLED
else if (handler->iconv_in != NULL) { else if (handler->iconv_in != NULL) {
@ -1941,7 +1981,25 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
return(ret); return(ret);
} }
/* Returns -4 if no output function was found. */ /**
* xmlEncOutputChunk:
* @handler: encoding handler
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of input bytes
* @inlen: the length of @in
*
* Returns 0 if success, or
* -1 by lack of space, or
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
* -3 if there the last byte can't form a single output char.
* -4 if no output function was found.
*
* The value of @inlen after return is the number of octets consumed
* as the return value is 0, else unpredictable.
* The value of @outlen after return is the number of octets produced.
*/
static int static int
xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen) { int *outlen, const unsigned char *in, int *inlen) {
@ -1949,6 +2007,8 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
if (handler->output != NULL) { if (handler->output != NULL) {
ret = handler->output(out, outlen, in, inlen); ret = handler->output(out, outlen, in, inlen);
if (ret > 0)
ret = 0;
} }
#ifdef LIBXML_ICONV_ENABLED #ifdef LIBXML_ICONV_ENABLED
else if (handler->iconv_out != NULL) { else if (handler->iconv_out != NULL) {
@ -1958,7 +2018,7 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
#ifdef LIBXML_ICU_ENABLED #ifdef LIBXML_ICU_ENABLED
else if (handler->uconv_out != NULL) { else if (handler->uconv_out != NULL) {
ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen, ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen,
TRUE); 1);
} }
#endif /* LIBXML_ICU_ENABLED */ #endif /* LIBXML_ICU_ENABLED */
else { else {
@ -2054,7 +2114,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
*/ */
if (ret == -3) ret = 0; if (ret == -3) ret = 0;
if (ret == -1) ret = 0; if (ret == -1) ret = 0;
return(ret); return(written ? written : ret);
} }
/** /**
@ -2184,7 +2244,7 @@ xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
*/ */
if (ret == -3) ret = 0; if (ret == -3) ret = 0;
if (ret == -1) ret = 0; if (ret == -1) ret = 0;
return(ret); return(c_out ? c_out : ret);
} }
/** /**
@ -2394,7 +2454,7 @@ xmlCharEncOutput(xmlOutputBufferPtr output, int init)
{ {
int ret; int ret;
size_t written; size_t written;
size_t writtentot = 0; int writtentot = 0;
size_t toconv; size_t toconv;
int c_in; int c_in;
int c_out; int c_out;
@ -2427,7 +2487,7 @@ retry:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"initialized encoder\n"); "initialized encoder\n");
#endif #endif
return(0); return(c_out);
} }
/* /*
@ -2540,7 +2600,7 @@ retry:
goto retry; goto retry;
} }
} }
return(ret); return(writtentot ? writtentot : ret);
} }
#endif #endif
@ -2705,7 +2765,7 @@ retry:
goto retry; goto retry;
} }
} }
return(ret); return(writtentot ? writtentot : ret);
} }
/** /**

View file

@ -71,7 +71,7 @@ static xmlEntity xmlEntityApos = {
/** /**
* xmlEntitiesErrMemory: * xmlEntitiesErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -210,7 +210,7 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
const xmlChar *content) { const xmlChar *content) {
xmlDictPtr dict = NULL; xmlDictPtr dict = NULL;
xmlEntitiesTablePtr table = NULL; xmlEntitiesTablePtr table = NULL;
xmlEntityPtr ret; xmlEntityPtr ret, predef;
if (name == NULL) if (name == NULL)
return(NULL); return(NULL);
@ -223,6 +223,44 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
case XML_INTERNAL_GENERAL_ENTITY: case XML_INTERNAL_GENERAL_ENTITY:
case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY: case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
predef = xmlGetPredefinedEntity(name);
if (predef != NULL) {
int valid = 0;
/* 4.6 Predefined Entities */
if ((type == XML_INTERNAL_GENERAL_ENTITY) &&
(content != NULL)) {
int c = predef->content[0];
if (((content[0] == c) && (content[1] == 0)) &&
((c == '>') || (c == '\'') || (c == '"'))) {
valid = 1;
} else if ((content[0] == '&') && (content[1] == '#')) {
if (content[2] == 'x') {
xmlChar *hex = BAD_CAST "0123456789ABCDEF";
xmlChar ref[] = "00;";
ref[0] = hex[c / 16 % 16];
ref[1] = hex[c % 16];
if (xmlStrcasecmp(&content[3], ref) == 0)
valid = 1;
} else {
xmlChar ref[] = "00;";
ref[0] = '0' + c / 10 % 10;
ref[1] = '0' + c % 10;
if (xmlStrEqual(&content[2], ref))
valid = 1;
}
}
}
if (!valid) {
xmlEntitiesErr(XML_ERR_ENTITY_PROCESSING,
"xmlAddEntity: invalid redeclaration of predefined"
" entity");
return(NULL);
}
}
if (dtd->entities == NULL) if (dtd->entities == NULL)
dtd->entities = xmlHashCreateDict(0, dict); dtd->entities = xmlHashCreateDict(0, dict);
table = dtd->entities; table = dtd->entities;
@ -666,11 +704,25 @@ xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
} else { } else {
/* /*
* We assume we have UTF-8 input. * We assume we have UTF-8 input.
* It must match either:
* 110xxxxx 10xxxxxx
* 1110xxxx 10xxxxxx 10xxxxxx
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* That is:
* cur[0] is 11xxxxxx
* cur[1] is 10xxxxxx
* cur[2] is 10xxxxxx if cur[0] is 111xxxxx
* cur[3] is 10xxxxxx if cur[0] is 1111xxxx
* cur[0] is not 11111xxx
*/ */
char buf[11], *ptr; char buf[11], *ptr;
int val = 0, l = 1; int val = 0, l = 1;
if (*cur < 0xC0) { if (((cur[0] & 0xC0) != 0xC0) ||
((cur[1] & 0xC0) != 0x80) ||
(((cur[0] & 0xE0) == 0xE0) && ((cur[2] & 0xC0) != 0x80)) ||
(((cur[0] & 0xF0) == 0xF0) && ((cur[3] & 0xC0) != 0x80)) ||
(((cur[0] & 0xF8) == 0xF8))) {
xmlEntitiesErr(XML_CHECK_NOT_UTF8, xmlEntitiesErr(XML_CHECK_NOT_UTF8,
"xmlEncodeEntities: input not UTF-8"); "xmlEncodeEntities: input not UTF-8");
if (doc != NULL) if (doc != NULL)

View file

@ -146,7 +146,7 @@ xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
* xmlParserPrintFileInfo: * xmlParserPrintFileInfo:
* @input: an xmlParserInputPtr input * @input: an xmlParserInputPtr input
* *
* Displays the associated file and line informations for the current input * Displays the associated file and line information for the current input
*/ */
void void
@ -557,6 +557,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
* of the usual "base" (doc->URL) for the node (bug 152623). * of the usual "base" (doc->URL) for the node (bug 152623).
*/ */
xmlNodePtr prev = baseptr; xmlNodePtr prev = baseptr;
char *href = NULL;
int inclcount = 0; int inclcount = 0;
while (prev != NULL) { while (prev != NULL) {
if (prev->prev == NULL) if (prev->prev == NULL)
@ -564,21 +565,20 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
else { else {
prev = prev->prev; prev = prev->prev;
if (prev->type == XML_XINCLUDE_START) { if (prev->type == XML_XINCLUDE_START) {
if (--inclcount < 0) if (inclcount > 0) {
break; --inclcount;
} else {
href = (char *) xmlGetProp(prev, BAD_CAST "href");
if (href != NULL)
break;
}
} else if (prev->type == XML_XINCLUDE_END) } else if (prev->type == XML_XINCLUDE_END)
inclcount++; inclcount++;
} }
} }
if (prev != NULL) { if (href != NULL)
if (prev->type == XML_XINCLUDE_START) { to->file = href;
prev->type = XML_ELEMENT_NODE; else
to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
prev->type = XML_XINCLUDE_START;
} else {
to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
}
} else
#endif #endif
to->file = (char *) xmlStrdup(baseptr->doc->URL); to->file = (char *) xmlStrdup(baseptr->doc->URL);
if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) { if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
@ -643,7 +643,7 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
* @domain: where the error comes from * @domain: where the error comes from
* @code: the error code * @code: the error code
* @node: the context node * @node: the context node
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */

View file

@ -215,7 +215,7 @@ int oldXMLWDcompatibility = 0; /* DEPRECATED */
/** /**
* xmlParserDebugEntities: * xmlParserDebugEntities:
* *
* Global setting, asking the parser to print out debugging informations. * Global setting, asking the parser to print out debugging information.
* while handling entities. * while handling entities.
* Disabled by default * Disabled by default
*/ */

View file

@ -11,7 +11,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
* Author: breese@users.sourceforge.net * Author: breese@users.sourceforge.net

View file

@ -9,7 +9,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
* Author: Gary.Pennington@uk.sun.com * Author: Gary.Pennington@uk.sun.com

View file

@ -158,7 +158,7 @@ int have_ipv6(void) {
/** /**
* xmlFTPErrMemory: * xmlFTPErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -172,7 +172,7 @@ xmlFTPErrMemory(const char *extra)
* xmlNanoFTPInit: * xmlNanoFTPInit:
* *
* Initialize the FTP protocol layer. * Initialize the FTP protocol layer.
* Currently it just checks for proxy informations, * Currently it just checks for proxy information,
* and get the hostname * and get the hostname
*/ */
@ -218,7 +218,7 @@ xmlNanoFTPInit(void) {
/** /**
* xmlNanoFTPCleanup: * xmlNanoFTPCleanup:
* *
* Cleanup the FTP protocol layer. This cleanup proxy informations. * Cleanup the FTP protocol layer. This cleanup proxy information.
*/ */
void void
@ -250,7 +250,7 @@ xmlNanoFTPCleanup(void) {
* @passwd: the proxy password * @passwd: the proxy password
* @type: the type of proxy 1 for using SITE, 2 for USER a@b * @type: the type of proxy 1 for using SITE, 2 for USER a@b
* *
* Setup the FTP proxy informations. * Setup the FTP proxy information.
* This can also be done by using ftp_proxy ftp_proxy_user and * This can also be done by using ftp_proxy ftp_proxy_user and
* ftp_proxy_password environment variables. * ftp_proxy_password environment variables.
*/ */
@ -412,7 +412,7 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
* (Re)Initialize the FTP Proxy context by parsing the URL and finding * (Re)Initialize the FTP Proxy context by parsing the URL and finding
* the protocol host port it indicates. * the protocol host port it indicates.
* Should be like ftp://myproxy/ or ftp://myproxy:3128/ * Should be like ftp://myproxy/ or ftp://myproxy:3128/
* A NULL URL cleans up proxy informations. * A NULL URL cleans up proxy information.
*/ */
void void
@ -1251,8 +1251,7 @@ xmlNanoFTPConnectTo(const char *server, int port) {
xmlNanoFTPFreeCtxt(ctxt); xmlNanoFTPFreeCtxt(ctxt);
return(NULL); return(NULL);
} }
if (port != 0) ctxt->port = port;
ctxt->port = port;
res = xmlNanoFTPConnect(ctxt); res = xmlNanoFTPConnect(ctxt);
if (res < 0) { if (res < 0) {
xmlNanoFTPFreeCtxt(ctxt); xmlNanoFTPFreeCtxt(ctxt);
@ -1268,7 +1267,7 @@ xmlNanoFTPConnectTo(const char *server, int port) {
* *
* Tries to change the remote directory * Tries to change the remote directory
* *
* Returns -1 incase of error, 1 if CWD worked, 0 if it failed * Returns -1 in case of error, 1 if CWD worked, 0 if it failed
*/ */
int int
@ -1317,7 +1316,7 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
* *
* Tries to delete an item (file or directory) from server * Tries to delete an item (file or directory) from server
* *
* Returns -1 incase of error, 1 if DELE worked, 0 if it failed * Returns -1 in case of error, 1 if DELE worked, 0 if it failed
*/ */
int int
@ -1367,7 +1366,7 @@ xmlNanoFTPDele(void *ctx, const char *file) {
* Try to open a data connection to the server. Currently only * Try to open a data connection to the server. Currently only
* passive mode is supported. * passive mode is supported.
* *
* Returns -1 incase of error, 0 otherwise * Returns -1 in case of error, 0 otherwise
*/ */
SOCKET SOCKET
@ -1540,7 +1539,7 @@ xmlNanoFTPGetConnection(void *ctx) {
* *
* Close the data connection from the server * Close the data connection from the server
* *
* Returns -1 incase of error, 0 otherwise * Returns -1 in case of error, 0 otherwise
*/ */
int int
@ -1591,7 +1590,7 @@ xmlNanoFTPCloseConnection(void *ctx) {
* *
* Parse at most one entry from the listing. * Parse at most one entry from the listing.
* *
* Returns -1 incase of error, the length of data parsed otherwise * Returns -1 in case of error, the length of data parsed otherwise
*/ */
static int static int
@ -1719,7 +1718,7 @@ xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData)
* Do a listing on the server. All files info are passed back * Do a listing on the server. All files info are passed back
* in the callbacks. * in the callbacks.
* *
* Returns -1 incase of error, 0 otherwise * Returns -1 in case of error, 0 otherwise
*/ */
int int
@ -1894,7 +1893,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
* Fetch the given file from the server. All data are passed back * Fetch the given file from the server. All data are passed back
* in the callbacks. The last callback has a size of 0 block. * in the callbacks. The last callback has a size of 0 block.
* *
* Returns -1 incase of error, 0 otherwise * Returns -1 in case of error, 0 otherwise
*/ */
int int
@ -2024,7 +2023,7 @@ xmlNanoFTPOpen(const char *URL) {
* *
* Close the connection and both control and transport * Close the connection and both control and transport
* *
* Returns -1 incase of error, 0 otherwise * Returns -1 in case of error, 0 otherwise
*/ */
int int

View file

@ -160,7 +160,7 @@ static int xmlNanoHTTPFetchContent( void * ctx, char ** ptr, int * len );
/** /**
* xmlHTTPErrMemory: * xmlHTTPErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -213,7 +213,7 @@ int have_ipv6(void) {
* xmlNanoHTTPInit: * xmlNanoHTTPInit:
* *
* Initialize the HTTP protocol layer. * Initialize the HTTP protocol layer.
* Currently it just checks for proxy informations * Currently it just checks for proxy information
*/ */
void void
@ -344,7 +344,7 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
* (Re)Initialize the HTTP Proxy context by parsing the URL and finding * (Re)Initialize the HTTP Proxy context by parsing the URL and finding
* the protocol host port it indicates. * the protocol host port it indicates.
* Should be like http://myproxy/ or http://myproxy:3128/ * Should be like http://myproxy/ or http://myproxy:3128/
* A NULL URL cleans up proxy informations. * A NULL URL cleans up proxy information.
*/ */
void void
@ -650,7 +650,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt)
* @ctxt: an HTTP context * @ctxt: an HTTP context
* *
* Read one line in the HTTP server output, usually for extracting * Read one line in the HTTP server output, usually for extracting
* the HTTP protocol informations from the answer header. * the HTTP protocol information from the answer header.
* *
* Returns a newly allocated string with a copy of the line, or NULL * Returns a newly allocated string with a copy of the line, or NULL
* which indicate the end of the input. * which indicate the end of the input.
@ -693,7 +693,7 @@ xmlNanoHTTPReadLine(xmlNanoHTTPCtxtPtr ctxt) {
* @ctxt: an HTTP context * @ctxt: an HTTP context
* @line: an HTTP header line * @line: an HTTP header line
* *
* Try to extract useful informations from the server answer. * Try to extract useful information from the server answer.
* We currently parse and process: * We currently parse and process:
* - The HTTP revision/ return code * - The HTTP revision/ return code
* - The Content-Type, Mime-Type and charset used * - The Content-Type, Mime-Type and charset used
@ -1625,7 +1625,7 @@ xmlNanoHTTPMethod(const char *URL, const char *method, const char *input,
* This function try to fetch the indicated resource via HTTP GET * This function try to fetch the indicated resource via HTTP GET
* and save it's content in the file. * and save it's content in the file.
* *
* Returns -1 in case of failure, 0 incase of success. The contentType, * Returns -1 in case of failure, 0 in case of success. The contentType,
* if provided must be freed by the caller * if provided must be freed by the caller
*/ */
int int
@ -1675,7 +1675,7 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
* This function saves the output of the HTTP transaction to a file * This function saves the output of the HTTP transaction to a file
* It closes and free the context at the end * It closes and free the context at the end
* *
* Returns -1 in case of failure, 0 incase of success. * Returns -1 in case of failure, 0 in case of success.
*/ */
int int
xmlNanoHTTPSave(void *ctxt, const char *filename) { xmlNanoHTTPSave(void *ctxt, const char *filename) {

File diff suppressed because it is too large Load diff

View file

@ -105,7 +105,7 @@ xmlCheckVersion(int version) {
/** /**
* xmlErrMemory: * xmlErrMemory:
* @ctxt: an XML parser context * @ctxt: an XML parser context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -165,7 +165,7 @@ __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
* xmlErrInternal: * xmlErrInternal:
* @ctxt: an XML parser context * @ctxt: an XML parser context
* @msg: the error message * @msg: the error message
* @str: error informations * @str: error information
* *
* Handle an internal error * Handle an internal error
*/ */
@ -519,8 +519,6 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
} else } else
/* 1-byte code */ /* 1-byte code */
ctxt->input->cur++; ctxt->input->cur++;
ctxt->nbChars++;
} else { } else {
/* /*
* Assume it's a fixed length encoding (1) with * Assume it's a fixed length encoding (1) with
@ -533,7 +531,6 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
} else } else
ctxt->input->col++; ctxt->input->col++;
ctxt->input->cur++; ctxt->input->cur++;
ctxt->nbChars++;
} }
if (*ctxt->input->cur == 0) if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
@ -677,7 +674,6 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
} }
if (*ctxt->input->cur == 0xD) { if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) { if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++;
ctxt->input->cur++; ctxt->input->cur++;
} }
return(0xA); return(0xA);
@ -693,7 +689,6 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
*len = 1; *len = 1;
if (*ctxt->input->cur == 0xD) { if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) { if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++;
ctxt->input->cur++; ctxt->input->cur++;
} }
return(0xA); return(0xA);
@ -1158,6 +1153,11 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* Note: this is a bit dangerous, but that's what it * Note: this is a bit dangerous, but that's what it
* takes to use nearly compatible signature for different * takes to use nearly compatible signature for different
* encodings. * encodings.
*
* FIXME: Encoders might buffer partial byte sequences, so
* this probably can't work. We should return an error and
* make sure that callers never try to switch the encoding
* twice.
*/ */
xmlCharEncCloseFunc(input->buf->encoder); xmlCharEncCloseFunc(input->buf->encoder);
input->buf->encoder = handler; input->buf->encoder = handler;
@ -1748,7 +1748,6 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->options |= XML_PARSE_NOENT; ctxt->options |= XML_PARSE_NOENT;
} }
ctxt->record_info = 0; ctxt->record_info = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
ctxt->inSubset = 0; ctxt->inSubset = 0;
ctxt->errNo = XML_ERR_OK; ctxt->errNo = XML_ERR_OK;
@ -1877,7 +1876,7 @@ xmlNewParserCtxt(void)
/************************************************************************ /************************************************************************
* * * *
* Handling of node informations * * Handling of node information *
* * * *
************************************************************************/ ************************************************************************/

View file

@ -430,7 +430,7 @@ struct _xmlRelaxNGDocument {
/** /**
* xmlRngPErrMemory: * xmlRngPErrMemory:
* @ctxt: an Relax-NG parser context * @ctxt: an Relax-NG parser context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -465,7 +465,7 @@ xmlRngPErrMemory(xmlRelaxNGParserCtxtPtr ctxt, const char *extra)
/** /**
* xmlRngVErrMemory: * xmlRngVErrMemory:
* @ctxt: a Relax-NG validation context * @ctxt: a Relax-NG validation context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -1409,7 +1409,7 @@ xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt,
* @ctxt: a RelaxNG parser context * @ctxt: a RelaxNG parser context
* @flags: a set of flags values * @flags: a set of flags values
* *
* Semi private function used to pass informations to a parser context * Semi private function used to pass information to a parser context
* which are a combination of xmlRelaxNGParserFlag . * which are a combination of xmlRelaxNGParserFlag .
* *
* Returns 0 if success and -1 in case of error * Returns 0 if success and -1 in case of error
@ -8165,7 +8165,7 @@ xmlRelaxNGElemPop(xmlRelaxNGValidCtxtPtr ctxt)
@ @inputdata: callback data, the Relax NG validation context @ @inputdata: callback data, the Relax NG validation context
* *
* Handle the callback and if needed validate the element children. * Handle the callback and if needed validate the element children.
* some of the in/out informations are passed via the context in @inputdata. * some of the in/out information are passed via the context in @inputdata.
*/ */
static void static void
xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec xmlRelaxNGValidateProgressiveCallback(xmlRegExecCtxtPtr exec
@ -11000,7 +11000,7 @@ xmlRelaxNGFreeValidCtxt(xmlRelaxNGValidCtxtPtr ctxt)
* @warn: the warning function * @warn: the warning function
* @ctx: the functions context * @ctx: the functions context
* *
* Set the error and warning callback informations * Set the error and warning callback information
*/ */
void void
xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
@ -11042,7 +11042,7 @@ xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
* @warn: the warning function result * @warn: the warning function result
* @ctx: the functions context result * @ctx: the functions context result
* *
* Get the error and warning callback informations * Get the error and warning callback information
* *
* Returns -1 in case of error and 0 otherwise * Returns -1 in case of error and 0 otherwise
*/ */

View file

@ -220,7 +220,7 @@ struct _xmlSchematronParserCtxt {
/** /**
* xmlSchematronPErrMemory: * xmlSchematronPErrMemory:
* @node: a context node * @node: a context node
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -268,7 +268,7 @@ xmlSchematronPErr(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr node, int error,
/** /**
* xmlSchematronVTypeErrMemory: * xmlSchematronVTypeErrMemory:
* @node: a context node * @node: a context node
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */

View file

@ -885,8 +885,6 @@ xmlInitThreads(void)
} }
} }
#endif /* XML_PTHREAD_WEAK */ #endif /* XML_PTHREAD_WEAK */
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
InitializeCriticalSection(&cleanup_helpers_cs);
#endif #endif
} }
@ -958,6 +956,9 @@ xmlOnceInit(void)
if (!run_once.done) { if (!run_once.done) {
if (InterlockedIncrement(&run_once.control) == 1) { if (InterlockedIncrement(&run_once.control) == 1) {
#if !defined(HAVE_COMPILER_TLS) #if !defined(HAVE_COMPILER_TLS)
#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
InitializeCriticalSection(&cleanup_helpers_cs);
#endif
globalkey = TlsAlloc(); globalkey = TlsAlloc();
#endif #endif
mainthread = GetCurrentThreadId(); mainthread = GetCurrentThreadId();

View file

@ -70,7 +70,7 @@ static xmlChar* xmlGetPropNodeValueInternal(const xmlAttr *prop);
************************************************************************/ ************************************************************************/
/** /**
* xmlTreeErrMemory: * xmlTreeErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -83,7 +83,7 @@ xmlTreeErrMemory(const char *extra)
/** /**
* xmlTreeErr: * xmlTreeErr:
* @code: the error number * @code: the error number
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -1064,7 +1064,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* @str: a string * @str: a string
* *
* Copy a string using a "dict" dictionary in the current scope, * Copy a string using a "dict" dictionary in the current scope,
* if availabe. * if available.
*/ */
#define DICT_COPY(str, cpy) \ #define DICT_COPY(str, cpy) \
if (str) { \ if (str) { \
@ -1081,7 +1081,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* @str: a string * @str: a string
* *
* Copy a string using a "dict" dictionary in the current scope, * Copy a string using a "dict" dictionary in the current scope,
* if availabe. * if available.
*/ */
#define DICT_CONST_COPY(str, cpy) \ #define DICT_CONST_COPY(str, cpy) \
if (str) { \ if (str) { \
@ -1276,12 +1276,14 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
xmlNodePtr ret = NULL, last = NULL; xmlNodePtr ret = NULL, last = NULL;
xmlNodePtr node; xmlNodePtr node;
xmlChar *val; xmlChar *val;
const xmlChar *cur = value, *end = cur + len; const xmlChar *cur, *end;
const xmlChar *q; const xmlChar *q;
xmlEntityPtr ent; xmlEntityPtr ent;
xmlBufPtr buf; xmlBufPtr buf;
if (value == NULL) return(NULL); if (value == NULL) return(NULL);
cur = value;
end = cur + len;
buf = xmlBufCreateSize(0); buf = xmlBufCreateSize(0);
if (buf == NULL) return(NULL); if (buf == NULL) return(NULL);
@ -1308,6 +1310,16 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
else else
tmp = 0; tmp = 0;
while (tmp != ';') { /* Non input consuming loop */ while (tmp != ';') { /* Non input consuming loop */
/*
* If you find an integer overflow here when fuzzing,
* the bug is probably elsewhere. This function should
* only receive entities that were already validated by
* the parser, typically by xmlParseAttValueComplex
* calling xmlStringDecodeEntities.
*
* So it's better *not* to check for overflow to
* potentially discover new bugs.
*/
if ((tmp >= '0') && (tmp <= '9')) if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0'); charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f')) else if ((tmp >= 'a') && (tmp <= 'f'))
@ -1336,6 +1348,7 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
else else
tmp = 0; tmp = 0;
while (tmp != ';') { /* Non input consuming loops */ while (tmp != ';') { /* Non input consuming loops */
/* Don't check for integer overflow, see above. */
if ((tmp >= '0') && (tmp <= '9')) if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0'); charval = charval * 10 + (tmp - '0');
else { else {
@ -1515,6 +1528,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
cur += 3; cur += 3;
tmp = *cur; tmp = *cur;
while (tmp != ';') { /* Non input consuming loop */ while (tmp != ';') { /* Non input consuming loop */
/* Don't check for integer overflow, see above. */
if ((tmp >= '0') && (tmp <= '9')) if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0'); charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f')) else if ((tmp >= 'a') && (tmp <= 'f'))
@ -1537,6 +1551,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
cur += 2; cur += 2;
tmp = *cur; tmp = *cur;
while (tmp != ';') { /* Non input consuming loops */ while (tmp != ';') { /* Non input consuming loops */
/* Don't check for integer overflow, see above. */
if ((tmp >= '0') && (tmp <= '9')) if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0'); charval = charval * 10 + (tmp - '0');
else { else {
@ -1647,6 +1662,10 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
if (!xmlBufIsEmpty(buf)) { if (!xmlBufIsEmpty(buf)) {
node = xmlNewDocText(doc, NULL); node = xmlNewDocText(doc, NULL);
if (node == NULL) {
xmlBufFree(buf);
return(NULL);
}
node->content = xmlBufDetach(buf); node->content = xmlBufDetach(buf);
if (last == NULL) { if (last == NULL) {
@ -1882,12 +1901,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
if (value != NULL) { if (value != NULL) {
xmlNodePtr tmp; xmlNodePtr tmp;
if(!xmlCheckUTF8(value)) {
xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) doc,
NULL);
if (doc != NULL)
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
}
cur->children = xmlNewDocText(doc, value); cur->children = xmlNewDocText(doc, value);
cur->last = NULL; cur->last = NULL;
tmp = cur->children; tmp = cur->children;
@ -2007,6 +2020,11 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
* @value: the value of the attribute * @value: the value of the attribute
* *
* Create a new property carried by a document. * Create a new property carried by a document.
* NOTE: @value is supposed to be a piece of XML CDATA, so it allows entity
* references, but XML special chars need to be escaped first by using
* xmlEncodeEntitiesReentrant(). Use xmlNewProp() if you don't need
* entities support.
*
* Returns a pointer to the attribute * Returns a pointer to the attribute
*/ */
xmlAttrPtr xmlAttrPtr
@ -3706,6 +3724,11 @@ xmlFreeNodeList(xmlNodePtr cur) {
(cur->type != XML_XINCLUDE_START) && (cur->type != XML_XINCLUDE_START) &&
(cur->type != XML_XINCLUDE_END) && (cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_ENTITY_REF_NODE) && (cur->type != XML_ENTITY_REF_NODE) &&
(cur->type != XML_DOCUMENT_NODE) &&
#ifdef LIBXML_DOCB_ENABLED
(cur->type != XML_DOCB_DOCUMENT_NODE) &&
#endif
(cur->type != XML_HTML_DOCUMENT_NODE) &&
(cur->content != (xmlChar *) &(cur->properties))) { (cur->content != (xmlChar *) &(cur->properties))) {
DICT_FREE(cur->content) DICT_FREE(cur->content)
} }
@ -4066,7 +4089,7 @@ xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
} else { } else {
/* /*
* we have to find something appropriate here since * we have to find something appropriate here since
* we cant be sure, that the namespace we found is identified * we can't be sure, that the namespace we found is identified
* by the prefix * by the prefix
*/ */
if (xmlStrEqual(ns->href, cur->ns->href)) { if (xmlStrEqual(ns->href, cur->ns->href)) {
@ -4547,6 +4570,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
if (doc == NULL) return(NULL); if (doc == NULL) return(NULL);
ret = xmlNewDoc(doc->version); ret = xmlNewDoc(doc->version);
if (ret == NULL) return(NULL); if (ret == NULL) return(NULL);
ret->type = doc->type;
if (doc->name != NULL) if (doc->name != NULL)
ret->name = xmlMemStrdup(doc->name); ret->name = xmlMemStrdup(doc->name);
if (doc->encoding != NULL) if (doc->encoding != NULL)
@ -4869,7 +4893,9 @@ xmlGetNodePath(const xmlNode *node)
} }
next = ((xmlAttrPtr) cur)->parent; next = ((xmlAttrPtr) cur)->parent;
} else { } else {
next = cur->parent; xmlFree(buf);
xmlFree(buffer);
return (NULL);
} }
/* /*
@ -6564,6 +6590,16 @@ xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name,
attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, attrDecl = xmlGetDtdQAttrDesc(doc->extSubset,
elemQName, name, NULL); elemQName, name, NULL);
} }
} else if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
/*
* The XML namespace must be bound to prefix 'xml'.
*/
attrDecl = xmlGetDtdQAttrDesc(doc->intSubset,
elemQName, name, BAD_CAST "xml");
if ((attrDecl == NULL) && (doc->extSubset != NULL)) {
attrDecl = xmlGetDtdQAttrDesc(doc->extSubset,
elemQName, name, BAD_CAST "xml");
}
} else { } else {
xmlNsPtr *nsList, *cur; xmlNsPtr *nsList, *cur;
@ -6910,12 +6946,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
if (value != NULL) { if (value != NULL) {
xmlNodePtr tmp; xmlNodePtr tmp;
if(!xmlCheckUTF8(value)) {
xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
NULL);
if (node->doc != NULL)
node->doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
}
prop->children = xmlNewDocText(node->doc, value); prop->children = xmlNewDocText(node->doc, value);
prop->last = NULL; prop->last = NULL;
tmp = prop->children; tmp = prop->children;
@ -7243,7 +7273,7 @@ xmlBufferShrink(xmlBufferPtr buf, unsigned int len) {
((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) { ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
/* /*
* we just move the content pointer, but also make sure * we just move the content pointer, but also make sure
* the perceived buffer size has shrinked accordingly * the perceived buffer size has shrunk accordingly
*/ */
buf->content += len; buf->content += len;
buf->size -= len; buf->size -= len;
@ -7417,12 +7447,17 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
if (size < buf->size) if (size < buf->size)
return 1; return 1;
if (size > UINT_MAX - 10) {
xmlTreeErrMemory("growing buffer");
return 0;
}
/* figure out new size */ /* figure out new size */
switch (buf->alloc){ switch (buf->alloc){
case XML_BUFFER_ALLOC_IO: case XML_BUFFER_ALLOC_IO:
case XML_BUFFER_ALLOC_DOUBLEIT: case XML_BUFFER_ALLOC_DOUBLEIT:
/*take care of empty case*/ /*take care of empty case*/
newSize = (buf->size ? buf->size*2 : size + 10); newSize = (buf->size ? buf->size : size + 10);
while (size > newSize) { while (size > newSize) {
if (newSize > UINT_MAX / 2) { if (newSize > UINT_MAX / 2) {
xmlTreeErrMemory("growing buffer"); xmlTreeErrMemory("growing buffer");
@ -7438,7 +7473,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
if (buf->use < BASE_BUFFER_SIZE) if (buf->use < BASE_BUFFER_SIZE)
newSize = size; newSize = size;
else { else {
newSize = buf->size * 2; newSize = buf->size;
while (size > newSize) { while (size > newSize) {
if (newSize > UINT_MAX / 2) { if (newSize > UINT_MAX / 2) {
xmlTreeErrMemory("growing buffer"); xmlTreeErrMemory("growing buffer");
@ -7595,7 +7630,7 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
if (start_buf > (unsigned int) len) { if (start_buf > (unsigned int) len) {
/* /*
* We can add it in the space previously shrinked * We can add it in the space previously shrunk
*/ */
buf->content -= len; buf->content -= len;
memmove(&buf->content[0], str, len); memmove(&buf->content[0], str, len);

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************* *************************************************************************

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************* *************************************************************************

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************/ ************************************************************************/

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************ ************************************************************************
@ -123,8 +123,8 @@ static TRIO_CONST char rcsid[] = "@(#)$Id$";
* integer, becomes 0x0706050403020100 (we could have used a 64-bit * integer, becomes 0x0706050403020100 (we could have used a 64-bit
* integer value instead of a double, but not all platforms supports * integer value instead of a double, but not all platforms supports
* that type). The value is automatically encoded with the correct * that type). The value is automatically encoded with the correct
* endianess by the compiler, which means that we can support any * endianness by the compiler, which means that we can support any
* kind of endianess. The individual bytes are then used as an index * kind of endianness. The individual bytes are then used as an index
* for the IEEE 754 bit-patterns and masks. * for the IEEE 754 bit-patterns and masks.
*/ */
#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************/ ************************************************************************/

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************ ************************************************************************

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************/ ************************************************************************/

View file

@ -10,7 +10,7 @@
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
* CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
* *
************************************************************************/ ************************************************************************/

View file

@ -11,6 +11,7 @@
#define IN_LIBXML #define IN_LIBXML
#include "libxml.h" #include "libxml.h"
#include <limits.h>
#include <string.h> #include <string.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
@ -329,9 +330,14 @@ xmlParse3986Port(xmlURIPtr uri, const char **str)
if (ISA_DIGIT(cur)) { if (ISA_DIGIT(cur)) {
while (ISA_DIGIT(cur)) { while (ISA_DIGIT(cur)) {
port = port * 10 + (*cur - '0'); int digit = *cur - '0';
if (port > 99999999)
port = 99999999; if (port > INT_MAX / 10)
return(1);
port *= 10;
if (port > INT_MAX - digit)
return(1);
port += digit;
cur++; cur++;
} }
@ -348,7 +354,7 @@ xmlParse3986Port(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 an user informations part and fills in the appropriate fields * Parse an user information part and fills in the appropriate fields
* of the @uri structure * of the @uri structure
* *
* userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) * userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
@ -1748,11 +1754,6 @@ xmlURIEscape(const xmlChar * str)
xmlURIPtr uri; xmlURIPtr uri;
int ret2; int ret2;
#define NULLCHK(p) if(!p) { \
xmlURIErrMemory("escaping URI value\n"); \
xmlFreeURI(uri); \
return NULL; } \
if (str == NULL) if (str == NULL)
return (NULL); return (NULL);
@ -1774,6 +1775,12 @@ xmlURIEscape(const xmlChar * str)
ret = NULL; ret = NULL;
#define NULLCHK(p) if(!p) { \
xmlURIErrMemory("escaping URI value\n"); \
xmlFreeURI(uri); \
xmlFree(ret); \
return NULL; } \
if (uri->scheme) { if (uri->scheme) {
segment = xmlURIEscapeStr(BAD_CAST uri->scheme, BAD_CAST "+-."); segment = xmlURIEscapeStr(BAD_CAST uri->scheme, BAD_CAST "+-.");
NULLCHK(segment) NULLCHK(segment)
@ -1794,7 +1801,7 @@ xmlURIEscape(const xmlChar * str)
if (uri->user) { if (uri->user) {
segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,"); segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,");
NULLCHK(segment) NULLCHK(segment)
ret = xmlStrcat(ret,BAD_CAST "//"); ret = xmlStrcat(ret,BAD_CAST "//");
ret = xmlStrcat(ret, segment); ret = xmlStrcat(ret, segment);
ret = xmlStrcat(ret, BAD_CAST "@"); ret = xmlStrcat(ret, BAD_CAST "@");
xmlFree(segment); xmlFree(segment);
@ -1803,8 +1810,8 @@ xmlURIEscape(const xmlChar * str)
if (uri->server) { if (uri->server) {
segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@"); segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@");
NULLCHK(segment) NULLCHK(segment)
if (uri->user == NULL) if (uri->user == NULL)
ret = xmlStrcat(ret, BAD_CAST "//"); ret = xmlStrcat(ret, BAD_CAST "//");
ret = xmlStrcat(ret, segment); ret = xmlStrcat(ret, segment);
xmlFree(segment); xmlFree(segment);
} }

View file

@ -50,7 +50,7 @@ xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
/** /**
* xmlVErrMemory: * xmlVErrMemory:
* @ctxt: an XML validation parser context * @ctxt: an XML validation parser context
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory error * Handle an out of memory error
*/ */
@ -89,7 +89,7 @@ xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
* xmlErrValid: * xmlErrValid:
* @ctxt: an XML validation parser context * @ctxt: an XML validation parser context
* @error: the error number * @error: the error number
* @extra: extra informations * @extra: extra information
* *
* Handle a validation error * Handle a validation error
*/ */
@ -131,11 +131,11 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
* @ctxt: an XML validation parser context * @ctxt: an XML validation parser context
* @node: the node raising the error * @node: the node raising the error
* @error: the error number * @error: the error number
* @str1: extra informations * @str1: extra information
* @str2: extra informations * @str2: extra information
* @str3: extra informations * @str3: extra information
* *
* Handle a validation error, provide contextual informations * Handle a validation error, provide contextual information
*/ */
static void LIBXML_ATTR_FORMAT(4,0) static void LIBXML_ATTR_FORMAT(4,0)
xmlErrValidNode(xmlValidCtxtPtr ctxt, xmlErrValidNode(xmlValidCtxtPtr ctxt,
@ -174,11 +174,11 @@ xmlErrValidNode(xmlValidCtxtPtr ctxt,
* @ctxt: an XML validation parser context * @ctxt: an XML validation parser context
* @node: the node raising the error * @node: the node raising the error
* @error: the error number * @error: the error number
* @str1: extra informations * @str1: extra information
* @int2: extra informations * @int2: extra information
* @str3: extra informations * @str3: extra information
* *
* Handle a validation error, provide contextual informations * Handle a validation error, provide contextual information
*/ */
static void LIBXML_ATTR_FORMAT(4,0) static void LIBXML_ATTR_FORMAT(4,0)
xmlErrValidNodeNr(xmlValidCtxtPtr ctxt, xmlErrValidNodeNr(xmlValidCtxtPtr ctxt,
@ -1174,7 +1174,7 @@ xmlFreeElementContent(xmlElementContentPtr cur) {
* @buf: An XML buffer * @buf: An XML buffer
* @cur: An element table * @cur: An element table
* *
* Dump the occurence operator of an element. * Dump the occurrence operator of an element.
*/ */
static void static void
xmlDumpElementOccur(xmlBufferPtr buf, xmlElementContentPtr cur) { xmlDumpElementOccur(xmlBufferPtr buf, xmlElementContentPtr cur) {
@ -5434,7 +5434,7 @@ fail:
} else if (ret == -2) { } else if (ret == -2) {
/* /*
* An entities reference appeared at this level. * An entities reference appeared at this level.
* Buid a minimal representation of this node content * Build a minimal representation of this node content
* sufficient to run the validation process on it * sufficient to run the validation process on it
*/ */
DEBUG_VALID_MSG("Found an entity reference, linearizing"); DEBUG_VALID_MSG("Found an entity reference, linearizing");
@ -5919,28 +5919,27 @@ xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) {
break; break;
case XML_ELEMENT_TYPE_MIXED: case XML_ELEMENT_TYPE_MIXED:
break; break;
case XML_ELEMENT_TYPE_ELEMENT: case XML_ELEMENT_TYPE_ELEMENT: {
if (len > 0) { int i;
int i;
for (i = 0;i < len;i++) { for (i = 0;i < len;i++) {
if (!IS_BLANK_CH(data[i])) { if (!IS_BLANK_CH(data[i])) {
xmlErrValidNode(ctxt, state->node, xmlErrValidNode(ctxt, state->node,
XML_DTD_CONTENT_MODEL, XML_DTD_CONTENT_MODEL,
"Element %s content does not follow the DTD, Text not allowed\n", "Element %s content does not follow the DTD, Text not allowed\n",
state->node->name, NULL, NULL); state->node->name, NULL, NULL);
ret = 0; ret = 0;
goto done; goto done;
} }
} }
/* /*
* TODO: * TODO:
* VC: Standalone Document Declaration * VC: Standalone Document Declaration
* element types with element content, if white space * element types with element content, if white space
* occurs directly within any instance of those types. * occurs directly within any instance of those types.
*/ */
} break;
break; }
} }
} }
} }

View file

@ -59,7 +59,7 @@ struct _xmlXIncludeRef {
xmlNodePtr inc; /* the included copy */ xmlNodePtr inc; /* the included copy */
int xml; /* xml or txt */ int xml; /* xml or txt */
int count; /* how many refs use that specific doc */ int count; /* how many refs use that specific doc */
xmlXPathObjectPtr xptr; /* the xpointer if needed */ int fallback; /* fallback was loaded */
int emptyFb; /* flag to show fallback empty */ int emptyFb; /* flag to show fallback empty */
}; };
@ -72,7 +72,7 @@ struct _xmlXIncludeCtxt {
int txtNr; /* number of unparsed documents */ int txtNr; /* number of unparsed documents */
int txtMax; /* size of unparsed documents tab */ int txtMax; /* size of unparsed documents tab */
xmlNodePtr *txtTab; /* array of unparsed text nodes */ xmlChar * *txtTab; /* array of unparsed text strings */
xmlURL *txturlTab; /* array of unparsed text URLs */ xmlURL *txturlTab; /* array of unparsed text URLs */
xmlChar * url; /* the current URL processed */ xmlChar * url; /* the current URL processed */
@ -86,10 +86,13 @@ struct _xmlXIncludeCtxt {
xmlChar * base; /* the current xml:base */ xmlChar * base; /* the current xml:base */
void *_private; /* application data */ void *_private; /* application data */
unsigned long incTotal; /* total number of processed inclusions */
}; };
static int static int
xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree); xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree,
int skipRoot);
/************************************************************************ /************************************************************************
@ -207,8 +210,6 @@ xmlXIncludeFreeRef(xmlXIncludeRefPtr ref) {
xmlFree(ref->URI); xmlFree(ref->URI);
if (ref->fragment != NULL) if (ref->fragment != NULL)
xmlFree(ref->fragment); xmlFree(ref->fragment);
if (ref->xptr != NULL)
xmlXPathFreeObject(ref->xptr);
xmlFree(ref); xmlFree(ref);
} }
@ -392,18 +393,22 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
if (ctxt->incTab[i] != NULL) if (ctxt->incTab[i] != NULL)
xmlXIncludeFreeRef(ctxt->incTab[i]); xmlXIncludeFreeRef(ctxt->incTab[i]);
} }
if (ctxt->incTab != NULL)
xmlFree(ctxt->incTab);
if (ctxt->txtTab != NULL) {
for (i = 0;i < ctxt->txtNr;i++) {
if (ctxt->txtTab[i] != NULL)
xmlFree(ctxt->txtTab[i]);
}
xmlFree(ctxt->txtTab);
}
if (ctxt->txturlTab != NULL) { if (ctxt->txturlTab != NULL) {
for (i = 0;i < ctxt->txtNr;i++) { for (i = 0;i < ctxt->txtNr;i++) {
if (ctxt->txturlTab[i] != NULL) if (ctxt->txturlTab[i] != NULL)
xmlFree(ctxt->txturlTab[i]); xmlFree(ctxt->txturlTab[i]);
} }
}
if (ctxt->incTab != NULL)
xmlFree(ctxt->incTab);
if (ctxt->txtTab != NULL)
xmlFree(ctxt->txtTab);
if (ctxt->txturlTab != NULL)
xmlFree(ctxt->txturlTab); xmlFree(ctxt->txturlTab);
}
if (ctxt->base != NULL) { if (ctxt->base != NULL) {
xmlFree(ctxt->base); xmlFree(ctxt->base);
} }
@ -626,8 +631,8 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION, xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
"detected a local recursion with no xpointer in %s\n", "detected a local recursion with no xpointer in %s\n",
URL); URL);
if (fragment != NULL) xmlFree(URL);
xmlFree(fragment); xmlFree(fragment);
return(-1); return(-1);
} }
@ -639,12 +644,15 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
if (xmlStrEqual(URL, ctxt->urlTab[i])) { if (xmlStrEqual(URL, ctxt->urlTab[i])) {
xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION, xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
"detected a recursion in %s\n", URL); "detected a recursion in %s\n", URL);
xmlFree(URL);
xmlFree(fragment);
return(-1); return(-1);
} }
} }
} }
ref = xmlXIncludeNewRef(ctxt, URL, cur); ref = xmlXIncludeNewRef(ctxt, URL, cur);
xmlFree(URL);
if (ref == NULL) { if (ref == NULL) {
return(-1); return(-1);
} }
@ -652,7 +660,6 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
ref->doc = NULL; ref->doc = NULL;
ref->xml = xml; ref->xml = xml;
ref->count = 1; ref->count = 1;
xmlFree(URL);
return(0); return(0);
} }
@ -729,7 +736,9 @@ xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
* (bug 132597) * (bug 132597)
*/ */
newctxt->parseFlags = ctxt->parseFlags; newctxt->parseFlags = ctxt->parseFlags;
xmlXIncludeDoProcess(newctxt, doc, xmlDocGetRootElement(doc)); newctxt->incTotal = ctxt->incTotal;
xmlXIncludeDoProcess(newctxt, doc, xmlDocGetRootElement(doc), 0);
ctxt->incTotal = newctxt->incTotal;
for (i = 0;i < ctxt->incNr;i++) { for (i = 0;i < ctxt->incNr;i++) {
newctxt->incTab[i]->count--; newctxt->incTab[i]->count--;
newctxt->incTab[i] = NULL; newctxt->incTab[i] = NULL;
@ -759,13 +768,14 @@ xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
* Add a new text node to the list * Add a new text node to the list
*/ */
static void static void
xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) { xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *txt,
const xmlURL url) {
#ifdef DEBUG_XINCLUDE #ifdef DEBUG_XINCLUDE
xmlGenericError(xmlGenericErrorContext, "Adding text %s\n", url); xmlGenericError(xmlGenericErrorContext, "Adding text %s\n", url);
#endif #endif
if (ctxt->txtMax == 0) { if (ctxt->txtMax == 0) {
ctxt->txtMax = 4; ctxt->txtMax = 4;
ctxt->txtTab = (xmlNodePtr *) xmlMalloc(ctxt->txtMax * ctxt->txtTab = (xmlChar **) xmlMalloc(ctxt->txtMax *
sizeof(ctxt->txtTab[0])); sizeof(ctxt->txtTab[0]));
if (ctxt->txtTab == NULL) { if (ctxt->txtTab == NULL) {
xmlXIncludeErrMemory(ctxt, NULL, "processing text"); xmlXIncludeErrMemory(ctxt, NULL, "processing text");
@ -780,7 +790,7 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
} }
if (ctxt->txtNr >= ctxt->txtMax) { if (ctxt->txtNr >= ctxt->txtMax) {
ctxt->txtMax *= 2; ctxt->txtMax *= 2;
ctxt->txtTab = (xmlNodePtr *) xmlRealloc(ctxt->txtTab, ctxt->txtTab = (xmlChar **) xmlRealloc(ctxt->txtTab,
ctxt->txtMax * sizeof(ctxt->txtTab[0])); ctxt->txtMax * sizeof(ctxt->txtTab[0]));
if (ctxt->txtTab == NULL) { if (ctxt->txtTab == NULL) {
xmlXIncludeErrMemory(ctxt, NULL, "processing text"); xmlXIncludeErrMemory(ctxt, NULL, "processing text");
@ -793,7 +803,7 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
return; return;
} }
} }
ctxt->txtTab[ctxt->txtNr] = txt; ctxt->txtTab[ctxt->txtNr] = xmlStrdup(txt);
ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url); ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url);
ctxt->txtNr++; ctxt->txtNr++;
} }
@ -1071,7 +1081,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
case XML_ELEMENT_DECL: case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL: case XML_ATTRIBUTE_DECL:
case XML_ENTITY_NODE: case XML_ENTITY_NODE:
/* Do not copy DTD informations */ /* Do not copy DTD information */
break; break;
case XML_ENTITY_DECL: case XML_ENTITY_DECL:
/* handle crossing entities -> stack needed */ /* handle crossing entities -> stack needed */
@ -1459,7 +1469,7 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
*/ */
if ((URL[0] == 0) || (URL[0] == '#') || if ((URL[0] == 0) || (URL[0] == '#') ||
((ctxt->doc != NULL) && (xmlStrEqual(URL, ctxt->doc->URL)))) { ((ctxt->doc != NULL) && (xmlStrEqual(URL, ctxt->doc->URL)))) {
doc = NULL; doc = ctxt->doc;
goto loaded; goto loaded;
} }
@ -1551,15 +1561,8 @@ loaded:
/* /*
* Add the top children list as the replacement copy. * Add the top children list as the replacement copy.
*/ */
if (doc == NULL) ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc,
{ doc, doc->children);
/* Hopefully a DTD declaration won't be copied from
* the same document */
ctxt->incTab[nr]->inc = xmlCopyNodeList(ctxt->doc->children);
} else {
ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc,
doc, doc->children);
}
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_ENABLED
else { else {
@ -1571,12 +1574,7 @@ loaded:
xmlXPathContextPtr xptrctxt; xmlXPathContextPtr xptrctxt;
xmlNodeSetPtr set; xmlNodeSetPtr set;
if (doc == NULL) { xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
xptrctxt = xmlXPtrNewContext(ctxt->doc, ctxt->incTab[nr]->ref,
NULL);
} else {
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
}
if (xptrctxt == NULL) { if (xptrctxt == NULL) {
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_FAILED, XML_XINCLUDE_XPTR_FAILED,
@ -1608,6 +1606,7 @@ loaded:
XML_XINCLUDE_XPTR_RESULT, XML_XINCLUDE_XPTR_RESULT,
"XPointer is not a range: #%s\n", "XPointer is not a range: #%s\n",
fragment); fragment);
xmlXPathFreeObject(xptr);
xmlXPathFreeContext(xptrctxt); xmlXPathFreeContext(xptrctxt);
xmlFree(URL); xmlFree(URL);
xmlFree(fragment); xmlFree(fragment);
@ -1615,6 +1614,7 @@ loaded:
case XPATH_NODESET: case XPATH_NODESET:
if ((xptr->nodesetval == NULL) || if ((xptr->nodesetval == NULL) ||
(xptr->nodesetval->nodeNr <= 0)) { (xptr->nodesetval->nodeNr <= 0)) {
xmlXPathFreeObject(xptr);
xmlXPathFreeContext(xptrctxt); xmlXPathFreeContext(xptrctxt);
xmlFree(URL); xmlFree(URL);
xmlFree(fragment); xmlFree(fragment);
@ -1678,14 +1678,9 @@ loaded:
} }
} }
} }
if (doc == NULL) { ctxt->incTab[nr]->inc =
ctxt->incTab[nr]->xptr = xptr; xmlXIncludeCopyXPointer(ctxt, ctxt->doc, doc, xptr);
ctxt->incTab[nr]->inc = NULL; xmlXPathFreeObject(xptr);
} else {
ctxt->incTab[nr]->inc =
xmlXIncludeCopyXPointer(ctxt, ctxt->doc, doc, xptr);
xmlXPathFreeObject(xptr);
}
xmlXPathFreeContext(xptrctxt); xmlXPathFreeContext(xptrctxt);
xmlFree(fragment); xmlFree(fragment);
} }
@ -1855,7 +1850,7 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
*/ */
for (i = 0; i < ctxt->txtNr; i++) { for (i = 0; i < ctxt->txtNr; i++) {
if (xmlStrEqual(URL, ctxt->txturlTab[i])) { if (xmlStrEqual(URL, ctxt->txturlTab[i])) {
node = xmlCopyNode(ctxt->txtTab[i], 1); node = xmlNewText(ctxt->txtTab[i]);
goto loaded; goto loaded;
} }
} }
@ -1945,7 +1940,7 @@ xinclude_multibyte_fallback:
xmlBufShrink(buf->buffer, len); xmlBufShrink(buf->buffer, len);
} }
xmlFreeParserCtxt(pctxt); xmlFreeParserCtxt(pctxt);
xmlXIncludeAddTxt(ctxt, node, URL); xmlXIncludeAddTxt(ctxt, node->content, URL);
xmlFreeInputStream(inputStream); xmlFreeInputStream(inputStream);
loaded: loaded:
@ -1988,19 +1983,23 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
newctxt->_private = ctxt->_private; newctxt->_private = ctxt->_private;
newctxt->base = xmlStrdup(ctxt->base); /* Inherit the base from the existing context */ newctxt->base = xmlStrdup(ctxt->base); /* Inherit the base from the existing context */
xmlXIncludeSetFlags(newctxt, ctxt->parseFlags); xmlXIncludeSetFlags(newctxt, ctxt->parseFlags);
ret = xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback->children); newctxt->incTotal = ctxt->incTotal;
if (xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback, 1) < 0)
ret = -1;
ctxt->incTotal = newctxt->incTotal;
if (ctxt->nbErrors > oldNbErrors) if (ctxt->nbErrors > oldNbErrors)
ret = -1; ret = -1;
else if (ret > 0)
ret = 0; /* xmlXIncludeDoProcess can return +ve number */
xmlXIncludeFreeContext(newctxt); xmlXIncludeFreeContext(newctxt);
ctxt->incTab[nr]->inc = xmlDocCopyNodeList(ctxt->doc, ctxt->incTab[nr]->inc = xmlDocCopyNodeList(ctxt->doc,
fallback->children); fallback->children);
if (ctxt->incTab[nr]->inc == NULL)
ctxt->incTab[nr]->emptyFb = 1;
} else { } else {
ctxt->incTab[nr]->inc = NULL; ctxt->incTab[nr]->inc = NULL;
ctxt->incTab[nr]->emptyFb = 1; /* flag empty callback */ ctxt->incTab[nr]->emptyFb = 1; /* flag empty callback */
} }
ctxt->incTab[nr]->fallback = 1;
return(ret); return(ret);
} }
@ -2156,8 +2155,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
((xmlStrEqual(children->ns->href, XINCLUDE_NS)) || ((xmlStrEqual(children->ns->href, XINCLUDE_NS)) ||
(xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) { (xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) {
ret = xmlXIncludeLoadFallback(ctxt, children, nr); ret = xmlXIncludeLoadFallback(ctxt, children, nr);
if (ret == 0) break;
break;
} }
children = children->next; children = children->next;
} }
@ -2204,19 +2202,9 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(-1); return(-1);
/*
* If we stored an XPointer a late computation may be needed
*/
if ((ctxt->incTab[nr]->inc == NULL) &&
(ctxt->incTab[nr]->xptr != NULL)) {
ctxt->incTab[nr]->inc =
xmlXIncludeCopyXPointer(ctxt, ctxt->doc, ctxt->doc,
ctxt->incTab[nr]->xptr);
xmlXPathFreeObject(ctxt->incTab[nr]->xptr);
ctxt->incTab[nr]->xptr = NULL;
}
list = ctxt->incTab[nr]->inc; list = ctxt->incTab[nr]->inc;
ctxt->incTab[nr]->inc = NULL; ctxt->incTab[nr]->inc = NULL;
ctxt->incTab[nr]->emptyFb = 0;
/* /*
* Check against the risk of generating a multi-rooted document * Check against the risk of generating a multi-rooted document
@ -2236,6 +2224,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
XML_XINCLUDE_MULTIPLE_ROOT, XML_XINCLUDE_MULTIPLE_ROOT,
"XInclude error: would result in multiple root nodes\n", "XInclude error: would result in multiple root nodes\n",
NULL); NULL);
xmlFreeNodeList(list);
return(-1); return(-1);
} }
} }
@ -2253,16 +2242,27 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlUnlinkNode(cur); xmlUnlinkNode(cur);
xmlFreeNode(cur); xmlFreeNode(cur);
} else { } else {
xmlNodePtr child, next;
/* /*
* Change the current node as an XInclude start one, and add an * Change the current node as an XInclude start one, and add an
* XInclude end one * XInclude end one
*/ */
if (ctxt->incTab[nr]->fallback)
xmlUnsetProp(cur, BAD_CAST "href");
cur->type = XML_XINCLUDE_START; cur->type = XML_XINCLUDE_START;
/* Remove fallback children */
for (child = cur->children; child != NULL; child = next) {
next = child->next;
xmlUnlinkNode(child);
xmlFreeNode(child);
}
end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL); end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL);
if (end == NULL) { if (end == NULL) {
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_BUILD_FAILED, XML_XINCLUDE_BUILD_FAILED,
"failed to build node\n", NULL); "failed to build node\n", NULL);
xmlFreeNodeList(list);
return(-1); return(-1);
} }
end->type = XML_XINCLUDE_END; end->type = XML_XINCLUDE_END;
@ -2364,6 +2364,7 @@ xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
* @ctxt: the XInclude processing context * @ctxt: the XInclude processing context
* @doc: an XML document * @doc: an XML document
* @tree: the top of the tree to process * @tree: the top of the tree to process
* @skipRoot: don't process the root node of the tree
* *
* Implement the XInclude substitution on the XML document @doc * Implement the XInclude substitution on the XML document @doc
* *
@ -2371,13 +2372,16 @@ xmlXIncludeTestNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
* or the number of substitutions done. * or the number of substitutions done.
*/ */
static int static int
xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) { xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree,
int skipRoot) {
xmlNodePtr cur; xmlNodePtr cur;
int ret = 0; int ret = 0;
int i, start; int i, start;
if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL)) if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
return(-1); return(-1);
if ((skipRoot) && (tree->children == NULL))
return(-1);
if (ctxt == NULL) if (ctxt == NULL)
return(-1); return(-1);
@ -2388,41 +2392,59 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) {
} }
start = ctxt->incNr; start = ctxt->incNr;
/*
* TODO: The phases must run separately for recursive inclusions.
*
* - Phase 1 should start with top-level XInclude nodes, load documents,
* execute XPointer expressions, then process only the result nodes
* (not whole document, see bug #324081) and only for phase 1
* recursively. We will need a backreference from xmlNodes to
* xmlIncludeRefs to detect references that were already visited.
* This can also be used for proper cycle detection, see bug #344240.
*
* - Phase 2 should visit all top-level XInclude nodes and expand
* possible subreferences in the replacement recursively.
*
* - Phase 3 should finally replace the top-level XInclude nodes.
* It could also be run together with phase 2.
*/
/* /*
* First phase: lookup the elements in the document * First phase: lookup the elements in the document
*/ */
cur = tree; if (skipRoot)
if (xmlXIncludeTestNode(ctxt, cur) == 1) cur = tree->children;
xmlXIncludePreProcessNode(ctxt, cur); else
while ((cur != NULL) && (cur != tree->parent)) { cur = tree;
do {
/* TODO: need to work on entities -> stack */ /* TODO: need to work on entities -> stack */
if ((cur->children != NULL) && if (xmlXIncludeTestNode(ctxt, cur) == 1) {
(cur->children->type != XML_ENTITY_DECL) && #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
(cur->children->type != XML_XINCLUDE_START) && /*
(cur->children->type != XML_XINCLUDE_END)) { * Avoid superlinear expansion by limiting the total number
cur = cur->children; * of replacements.
if (xmlXIncludeTestNode(ctxt, cur)) */
xmlXIncludePreProcessNode(ctxt, cur); if (ctxt->incTotal >= 20)
} else if (cur->next != NULL) { return(-1);
cur = cur->next; #endif
if (xmlXIncludeTestNode(ctxt, cur)) ctxt->incTotal++;
xmlXIncludePreProcessNode(ctxt, cur); xmlXIncludePreProcessNode(ctxt, cur);
} else { } else if ((cur->children != NULL) &&
if (cur == tree) ((cur->type == XML_DOCUMENT_NODE) ||
break; (cur->type == XML_ELEMENT_NODE))) {
do { cur = cur->children;
cur = cur->parent; continue;
if ((cur == NULL) || (cur == tree->parent)) }
break; /* do */ do {
if (cur->next != NULL) { if (cur == tree)
cur = cur->next; break;
if (xmlXIncludeTestNode(ctxt, cur)) if (cur->next != NULL) {
xmlXIncludePreProcessNode(ctxt, cur); cur = cur->next;
break; /* do */ break;
} }
} while (cur != NULL); cur = cur->parent;
} } while (cur != NULL);
} } while ((cur != NULL) && (cur != tree));
/* /*
* Second Phase : collect the infosets fragments * Second Phase : collect the infosets fragments
@ -2445,8 +2467,7 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) {
*/ */
for (i = ctxt->incBase;i < ctxt->incNr; i++) { for (i = ctxt->incBase;i < ctxt->incNr; i++) {
if ((ctxt->incTab[i]->inc != NULL) || if ((ctxt->incTab[i]->inc != NULL) ||
(ctxt->incTab[i]->xptr != NULL) || (ctxt->incTab[i]->emptyFb != 0)) /* (empty fallback) */
(ctxt->incTab[i]->emptyFb != 0)) /* (empty fallback) */
xmlXIncludeIncludeNode(ctxt, i); xmlXIncludeIncludeNode(ctxt, i);
} }
@ -2500,7 +2521,7 @@ xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) {
ctxt->_private = data; ctxt->_private = data;
ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL); ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL);
xmlXIncludeSetFlags(ctxt, flags); xmlXIncludeSetFlags(ctxt, flags);
ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree); ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree, 0);
if ((ret >= 0) && (ctxt->nbErrors > 0)) if ((ret >= 0) && (ctxt->nbErrors > 0))
ret = -1; ret = -1;
@ -2584,7 +2605,7 @@ xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags) {
return(-1); return(-1);
ctxt->base = xmlNodeGetBase(tree->doc, tree); ctxt->base = xmlNodeGetBase(tree->doc, tree);
xmlXIncludeSetFlags(ctxt, flags); xmlXIncludeSetFlags(ctxt, flags);
ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree); ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree, 0);
if ((ret >= 0) && (ctxt->nbErrors > 0)) if ((ret >= 0) && (ctxt->nbErrors > 0))
ret = -1; ret = -1;
@ -2612,7 +2633,7 @@ xmlXIncludeProcessTree(xmlNodePtr tree) {
* @node: a node in an XML document * @node: a node in an XML document
* *
* Implement the XInclude substitution for the given subtree reusing * Implement the XInclude substitution for the given subtree reusing
* the informations and data coming from the given context. * the information and data coming from the given context.
* *
* Returns 0 if no substitution were done, -1 if some processing failed * Returns 0 if no substitution were done, -1 if some processing failed
* or the number of substitutions done. * or the number of substitutions done.
@ -2624,7 +2645,7 @@ xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
(node->doc == NULL) || (ctxt == NULL)) (node->doc == NULL) || (ctxt == NULL))
return(-1); return(-1);
ret = xmlXIncludeDoProcess(ctxt, node->doc, node); ret = xmlXIncludeDoProcess(ctxt, node->doc, node, 0);
if ((ret >= 0) && (ctxt->nbErrors > 0)) if ((ret >= 0) && (ctxt->nbErrors > 0))
ret = -1; ret = -1;
return(ret); return(ret);

View file

@ -228,7 +228,7 @@ __xmlIOWin32UTF8ToWChar(const char *u8String)
/** /**
* xmlIOErrMemory: * xmlIOErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -242,7 +242,7 @@ xmlIOErrMemory(const char *extra)
* __xmlIOErr: * __xmlIOErr:
* @code: the error number * @code: the error number
* @ * @
* @extra: extra informations * @extra: extra information
* *
* Handle an I/O error * Handle an I/O error
*/ */
@ -420,7 +420,7 @@ __xmlIOErr(int domain, int code, const char *extra)
/** /**
* xmlIOErr: * xmlIOErr:
* @code: the error number * @code: the error number
* @extra: extra informations * @extra: extra information
* *
* Handle an I/O error * Handle an I/O error
*/ */
@ -433,7 +433,7 @@ xmlIOErr(int code, const char *extra)
/** /**
* __xmlLoaderErr: * __xmlLoaderErr:
* @ctx: the parser context * @ctx: the parser context
* @extra: extra informations * @extra: extra information
* *
* Handle a resource access error * Handle a resource access error
*/ */
@ -564,6 +564,33 @@ xmlCleanupOutputCallbacks(void)
xmlOutputCallbackNr = 0; xmlOutputCallbackNr = 0;
xmlOutputCallbackInitialized = 0; xmlOutputCallbackInitialized = 0;
} }
/**
* xmlPopOutputCallbacks:
*
* Remove the top output callbacks from the output stack. This includes the
* compiled-in I/O.
*
* Returns the number of output callback registered or -1 in case of error.
*/
int
xmlPopOutputCallbacks(void)
{
if (!xmlOutputCallbackInitialized)
return(-1);
if (xmlOutputCallbackNr <= 0)
return(-1);
xmlOutputCallbackNr--;
xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = NULL;
xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = NULL;
xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = NULL;
xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = NULL;
return(xmlOutputCallbackNr);
}
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************ /************************************************************************
@ -3378,18 +3405,12 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
out->error = XML_IO_ENCODER; out->error = XML_IO_ENCODER;
return(-1); return(-1);
} }
if (out->writecallback) nbchars = ret >= 0 ? ret : 0;
nbchars = xmlBufUse(out->conv);
else
nbchars = ret;
} else { } else {
ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk); ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
if (ret != 0) if (ret != 0)
return(-1); return(-1);
if (out->writecallback) nbchars = chunk;
nbchars = xmlBufUse(out->buffer);
else
nbchars = chunk;
} }
buf += chunk; buf += chunk;
len -= chunk; len -= chunk;
@ -3576,19 +3597,13 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
out->error = XML_IO_ENCODER; out->error = XML_IO_ENCODER;
return(-1); return(-1);
} }
if (out->writecallback) nbchars = ret >= 0 ? ret : 0;
nbchars = xmlBufUse(out->conv);
else
nbchars = ret;
} else { } else {
ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons); ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons);
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */ if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
return(-1); return(-1);
xmlBufAddLen(out->buffer, chunk); xmlBufAddLen(out->buffer, chunk);
if (out->writecallback) nbchars = chunk;
nbchars = xmlBufUse(out->buffer);
else
nbchars = chunk;
} }
str += cons; str += cons;
len -= cons; len -= cons;

View file

@ -325,7 +325,7 @@ Usage : %s [options] catalogfile entities...\n\
\t used with --add or --del, it saves the catalog changes\n\ \t used with --add or --del, it saves the catalog changes\n\
\t and with --sgml it automatically updates the super catalog\n\ \t and with --sgml it automatically updates the super catalog\n\
\t--no-super-update: do not update the SGML super catalog\n\ \t--no-super-update: do not update the SGML super catalog\n\
\t-v --verbose : provide debug informations\n"); \t-v --verbose : provide debug information\n");
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
int i; int i;

View file

@ -165,6 +165,7 @@ static int xinclude = 0;
static int dtdattrs = 0; static int dtdattrs = 0;
static int loaddtd = 0; static int loaddtd = 0;
static xmllintReturnCode progresult = XMLLINT_RETURN_OK; static xmllintReturnCode progresult = XMLLINT_RETURN_OK;
static int quiet = 0;
static int timing = 0; static int timing = 0;
static int generate = 0; static int generate = 0;
static int dropdtd = 0; static int dropdtd = 0;
@ -528,6 +529,12 @@ static void
xmlHTMLEncodeSend(void) { xmlHTMLEncodeSend(void) {
char *result; char *result;
/*
* xmlEncodeEntitiesReentrant assumes valid UTF-8, but the buffer might
* end with a truncated UTF-8 sequence. This is a hack to at least avoid
* an out-of-bounds read.
*/
memset(&buffer[sizeof(buffer)-4], 0, 4);
result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer); result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
if (result) { if (result) {
xmlGenericError(xmlGenericErrorContext, "%s", result); xmlGenericError(xmlGenericErrorContext, "%s", result);
@ -540,7 +547,7 @@ xmlHTMLEncodeSend(void) {
* xmlHTMLPrintFileInfo: * xmlHTMLPrintFileInfo:
* @input: an xmlParserInputPtr input * @input: an xmlParserInputPtr input
* *
* Displays the associated file and line informations for the current input * Displays the associated file and line information for the current input
*/ */
static void static void
@ -1659,7 +1666,9 @@ testSAX(const char *filename) {
(void *)user_data); (void *)user_data);
if (repeat == 0) { if (repeat == 0) {
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); if (!quiet) {
fprintf(stderr, "%s validates\n", filename);
}
} else if (ret > 0) { } else if (ret > 0) {
fprintf(stderr, "%s fails to validate\n", filename); fprintf(stderr, "%s fails to validate\n", filename);
progresult = XMLLINT_ERR_VALID; progresult = XMLLINT_ERR_VALID;
@ -1942,7 +1951,9 @@ static void streamFile(char *filename) {
fprintf(stderr, "%s fails to validate\n", filename); fprintf(stderr, "%s fails to validate\n", filename);
progresult = XMLLINT_ERR_VALID; progresult = XMLLINT_ERR_VALID;
} else { } else {
fprintf(stderr, "%s validates\n", filename); if (!quiet) {
fprintf(stderr, "%s validates\n", filename);
}
} }
} }
#endif #endif
@ -2182,13 +2193,17 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
else if ((html) && (push)) { else if ((html) && (push)) {
FILE *f; FILE *f;
if ((filename[0] == '-') && (filename[1] == 0)) {
f = stdin;
} else {
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__) #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
f = fopen(filename, "rb"); f = fopen(filename, "rb");
#elif defined(__OS400__) #elif defined(__OS400__)
f = fopen(filename, "rb"); f = fopen(filename, "rb");
#else #else
f = fopen(filename, "r"); f = fopen(filename, "r");
#endif #endif
}
if (f != NULL) { if (f != NULL) {
int res; int res;
char chars[4096]; char chars[4096];
@ -2198,7 +2213,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (res > 0) { if (res > 0) {
ctxt = htmlCreatePushParserCtxt(NULL, NULL, ctxt = htmlCreatePushParserCtxt(NULL, NULL,
chars, res, filename, XML_CHAR_ENCODING_NONE); chars, res, filename, XML_CHAR_ENCODING_NONE);
xmlCtxtUseOptions(ctxt, options); htmlCtxtUseOptions(ctxt, options);
while ((res = fread(chars, 1, pushsize, f)) > 0) { while ((res = fread(chars, 1, pushsize, f)) > 0) {
htmlParseChunk(ctxt, chars, res, 0); htmlParseChunk(ctxt, chars, res, 0);
} }
@ -2277,7 +2292,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
doc = ctxt->myDoc; doc = ctxt->myDoc;
ret = ctxt->wellFormed; ret = ctxt->wellFormed;
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
if (!ret) { if ((!ret) && (!recovery)) {
xmlFreeDoc(doc); xmlFreeDoc(doc);
doc = NULL; doc = NULL;
} }
@ -2411,6 +2426,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
dtd = xmlGetIntSubset(doc); dtd = xmlGetIntSubset(doc);
if (dtd != NULL) { if (dtd != NULL) {
xmlUnlinkNode((xmlNodePtr)dtd); xmlUnlinkNode((xmlNodePtr)dtd);
doc->intSubset = NULL;
xmlFreeDtd(dtd); xmlFreeDtd(dtd);
} }
} }
@ -2830,7 +2846,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
#endif #endif
ret = xmlSchematronValidateDoc(ctxt, doc); ret = xmlSchematronValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); if (!quiet) {
fprintf(stderr, "%s validates\n", filename);
}
} else if (ret > 0) { } else if (ret > 0) {
fprintf(stderr, "%s fails to validate\n", filename); fprintf(stderr, "%s fails to validate\n", filename);
progresult = XMLLINT_ERR_VALID; progresult = XMLLINT_ERR_VALID;
@ -2858,7 +2876,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
ret = xmlRelaxNGValidateDoc(ctxt, doc); ret = xmlRelaxNGValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); if (!quiet) {
fprintf(stderr, "%s validates\n", filename);
}
} else if (ret > 0) { } else if (ret > 0) {
fprintf(stderr, "%s fails to validate\n", filename); fprintf(stderr, "%s fails to validate\n", filename);
progresult = XMLLINT_ERR_VALID; progresult = XMLLINT_ERR_VALID;
@ -2883,7 +2903,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL); xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
ret = xmlSchemaValidateDoc(ctxt, doc); ret = xmlSchemaValidateDoc(ctxt, doc);
if (ret == 0) { if (ret == 0) {
fprintf(stderr, "%s validates\n", filename); if (!quiet) {
fprintf(stderr, "%s validates\n", filename);
}
} else if (ret > 0) { } else if (ret > 0) {
fprintf(stderr, "%s fails to validate\n", filename); fprintf(stderr, "%s fails to validate\n", filename);
progresult = XMLLINT_ERR_VALID; progresult = XMLLINT_ERR_VALID;
@ -3000,6 +3022,7 @@ static void usage(FILE *f, const char *name) {
fprintf(f, "\t--dtdvalid URL : do a posteriori validation against a given DTD\n"); fprintf(f, "\t--dtdvalid URL : do a posteriori validation against a given DTD\n");
fprintf(f, "\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n"); fprintf(f, "\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n");
#endif /* LIBXML_VALID_ENABLED */ #endif /* LIBXML_VALID_ENABLED */
fprintf(f, "\t--quiet : be quiet when succeeded\n");
fprintf(f, "\t--timing : print some timings\n"); fprintf(f, "\t--timing : print some timings\n");
fprintf(f, "\t--output file or -o file: save to a given file\n"); fprintf(f, "\t--output file or -o file: save to a given file\n");
fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n"); fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n");
@ -3234,6 +3257,9 @@ main(int argc, char **argv) {
else if ((!strcmp(argv[i], "-insert")) || else if ((!strcmp(argv[i], "-insert")) ||
(!strcmp(argv[i], "--insert"))) (!strcmp(argv[i], "--insert")))
insert++; insert++;
else if ((!strcmp(argv[i], "-quiet")) ||
(!strcmp(argv[i], "--quiet")))
quiet++;
else if ((!strcmp(argv[i], "-timing")) || else if ((!strcmp(argv[i], "-timing")) ||
(!strcmp(argv[i], "--timing"))) (!strcmp(argv[i], "--timing")))
timing++; timing++;

View file

@ -75,7 +75,7 @@ void xmlMallocBreakpoint(void);
#endif #endif
/* /*
* Each of the blocks allocated begin with a header containing informations * Each of the blocks allocated begin with a header containing information
*/ */
#define MEMTAG 0x5aa5 #define MEMTAG 0x5aa5

View file

@ -48,6 +48,13 @@
#define MAX_ERR_MSG_SIZE 64000 #define MAX_ERR_MSG_SIZE 64000
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Keeping free objects can hide memory errors. */
#define MAX_FREE_NODES 1
#else
#define MAX_FREE_NODES 100
#endif
/* /*
* The following VA_COPY was coded following an example in * The following VA_COPY was coded following an example in
* the Samba project. It may not be sufficient for some * the Samba project. It may not be sufficient for some
@ -278,6 +285,59 @@ xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
return(0); return(0);
} }
/**
* xmlTextReaderWalkRemoveRef:
* @data: Contents of current link
* @user: Value supplied by the user
*
* Returns 0 to abort the walk or 1 to continue
*/
static int
xmlTextReaderWalkRemoveRef(const void *data, void *user)
{
xmlRefPtr ref = (xmlRefPtr)data;
xmlAttrPtr attr = (xmlAttrPtr)user;
if (ref->attr == attr) { /* Matched: remove and terminate walk */
ref->name = xmlStrdup(attr->name);
ref->attr = NULL;
return 0;
}
return 1;
}
/**
* xmlTextReaderRemoveRef:
* @doc: the document
* @attr: the attribute
*
* Remove the given attribute from the Ref table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
*/
static int
xmlTextReaderRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
xmlListPtr ref_list;
xmlRefTablePtr table;
xmlChar *ID;
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
table = (xmlRefTablePtr) doc->refs;
if (table == NULL)
return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
ref_list = xmlHashLookup(table, ID);
xmlFree(ID);
if(ref_list == NULL)
return (-1);
xmlListWalk(ref_list, xmlTextReaderWalkRemoveRef, attr);
return(0);
}
/** /**
* xmlTextReaderFreeProp: * xmlTextReaderFreeProp:
* @reader: the xmlTextReaderPtr used * @reader: the xmlTextReaderPtr used
@ -299,18 +359,20 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlDeregisterNodeDefaultValue((xmlNodePtr) cur); xmlDeregisterNodeDefaultValue((xmlNodePtr) cur);
/* Check for ID removal -> leading to invalid references ! */ /* Check for ID removal -> leading to invalid references ! */
if ((cur->parent != NULL) && (cur->parent->doc != NULL) && if ((cur->parent != NULL) && (cur->parent->doc != NULL)) {
((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL))) {
if (xmlIsID(cur->parent->doc, cur->parent, cur)) if (xmlIsID(cur->parent->doc, cur->parent, cur))
xmlTextReaderRemoveID(cur->parent->doc, cur); xmlTextReaderRemoveID(cur->parent->doc, cur);
if (((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL)) &&
(xmlIsRef(cur->parent->doc, cur->parent, cur)))
xmlTextReaderRemoveRef(cur->parent->doc, cur);
} }
if (cur->children != NULL) if (cur->children != NULL)
xmlTextReaderFreeNodeList(reader, cur->children); xmlTextReaderFreeNodeList(reader, cur->children);
DICT_FREE(cur->name); DICT_FREE(cur->name);
if ((reader != NULL) && (reader->ctxt != NULL) && if ((reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeAttrsNr < 100)) { (reader->ctxt->freeAttrsNr < MAX_FREE_NODES)) {
cur->next = reader->ctxt->freeAttrs; cur->next = reader->ctxt->freeAttrs;
reader->ctxt->freeAttrs = cur; reader->ctxt->freeAttrs = cur;
reader->ctxt->freeAttrsNr++; reader->ctxt->freeAttrsNr++;
@ -411,7 +473,7 @@ xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
if (((cur->type == XML_ELEMENT_NODE) || if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE)) && (cur->type == XML_TEXT_NODE)) &&
(reader != NULL) && (reader->ctxt != NULL) && (reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeElemsNr < 100)) { (reader->ctxt->freeElemsNr < MAX_FREE_NODES)) {
cur->next = reader->ctxt->freeElems; cur->next = reader->ctxt->freeElems;
reader->ctxt->freeElems = cur; reader->ctxt->freeElems = cur;
reader->ctxt->freeElemsNr++; reader->ctxt->freeElemsNr++;
@ -499,7 +561,7 @@ xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
if (((cur->type == XML_ELEMENT_NODE) || if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE)) && (cur->type == XML_TEXT_NODE)) &&
(reader != NULL) && (reader->ctxt != NULL) && (reader != NULL) && (reader->ctxt != NULL) &&
(reader->ctxt->freeElemsNr < 100)) { (reader->ctxt->freeElemsNr < MAX_FREE_NODES)) {
cur->next = reader->ctxt->freeElems; cur->next = reader->ctxt->freeElems;
reader->ctxt->freeElems = cur; reader->ctxt->freeElems = cur;
reader->ctxt->freeElemsNr++; reader->ctxt->freeElemsNr++;
@ -1106,20 +1168,9 @@ static void
xmlTextReaderValidateEntity(xmlTextReaderPtr reader) { xmlTextReaderValidateEntity(xmlTextReaderPtr reader) {
xmlNodePtr oldnode = reader->node; xmlNodePtr oldnode = reader->node;
xmlNodePtr node = reader->node; xmlNodePtr node = reader->node;
xmlParserCtxtPtr ctxt = reader->ctxt;
do { do {
if (node->type == XML_ENTITY_REF_NODE) { if (node->type == XML_ENTITY_REF_NODE) {
/*
* Case where the underlying tree is not available, lookup the entity
* and walk it.
*/
if ((node->children == NULL) && (ctxt->sax != NULL) &&
(ctxt->sax->getEntity != NULL)) {
node->children = (xmlNodePtr)
ctxt->sax->getEntity(ctxt, node->name);
}
if ((node->children != NULL) && if ((node->children != NULL) &&
(node->children->type == XML_ENTITY_DECL) && (node->children->type == XML_ENTITY_DECL) &&
(node->children->children != NULL)) { (node->children->children != NULL)) {
@ -1447,6 +1498,8 @@ get_next_node:
(reader->node->prev->type != XML_DTD_NODE)) { (reader->node->prev->type != XML_DTD_NODE)) {
xmlNodePtr tmp = reader->node->prev; xmlNodePtr tmp = reader->node->prev;
if ((tmp->extra & NODE_IS_PRESERVED) == 0) { if ((tmp->extra & NODE_IS_PRESERVED) == 0) {
if (oldnode == tmp)
oldnode = NULL;
xmlUnlinkNode(tmp); xmlUnlinkNode(tmp);
xmlTextReaderFreeNode(reader, tmp); xmlTextReaderFreeNode(reader, tmp);
} }
@ -1532,7 +1585,8 @@ node_found:
/* /*
* Handle XInclude if asked for * Handle XInclude if asked for
*/ */
if ((reader->xinclude) && (reader->node != NULL) && if ((reader->xinclude) && (reader->in_xinclude == 0) &&
(reader->node != NULL) &&
(reader->node->type == XML_ELEMENT_NODE) && (reader->node->type == XML_ELEMENT_NODE) &&
(reader->node->ns != NULL) && (reader->node->ns != NULL) &&
((xmlStrEqual(reader->node->ns->href, XINCLUDE_NS)) || ((xmlStrEqual(reader->node->ns->href, XINCLUDE_NS)) ||
@ -1564,16 +1618,6 @@ node_found:
if ((reader->node != NULL) && if ((reader->node != NULL) &&
(reader->node->type == XML_ENTITY_REF_NODE) && (reader->node->type == XML_ENTITY_REF_NODE) &&
(reader->ctxt != NULL) && (reader->ctxt->replaceEntities == 1)) { (reader->ctxt != NULL) && (reader->ctxt->replaceEntities == 1)) {
/*
* Case where the underlying tree is not available, lookup the entity
* and walk it.
*/
if ((reader->node->children == NULL) && (reader->ctxt->sax != NULL) &&
(reader->ctxt->sax->getEntity != NULL)) {
reader->node->children = (xmlNodePtr)
reader->ctxt->sax->getEntity(reader->ctxt, reader->node->name);
}
if ((reader->node->children != NULL) && if ((reader->node->children != NULL) &&
(reader->node->children->type == XML_ENTITY_DECL) && (reader->node->children->type == XML_ENTITY_DECL) &&
(reader->node->children->children != NULL)) { (reader->node->children->children != NULL)) {
@ -2281,14 +2325,18 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
if (reader->ctxt != NULL) { if (reader->ctxt != NULL) {
if (reader->dict == reader->ctxt->dict) if (reader->dict == reader->ctxt->dict)
reader->dict = NULL; reader->dict = NULL;
#ifdef LIBXML_VALID_ENABLED
if ((reader->ctxt->vctxt.vstateTab != NULL) && if ((reader->ctxt->vctxt.vstateTab != NULL) &&
(reader->ctxt->vctxt.vstateMax > 0)){ (reader->ctxt->vctxt.vstateMax > 0)){
#ifdef LIBXML_REGEXP_ENABLED
while (reader->ctxt->vctxt.vstateNr > 0) while (reader->ctxt->vctxt.vstateNr > 0)
xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL); xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
#endif /* LIBXML_REGEXP_ENABLED */
xmlFree(reader->ctxt->vctxt.vstateTab); xmlFree(reader->ctxt->vctxt.vstateTab);
reader->ctxt->vctxt.vstateTab = NULL; reader->ctxt->vctxt.vstateTab = NULL;
reader->ctxt->vctxt.vstateMax = 0; reader->ctxt->vctxt.vstateMax = 0;
} }
#endif /* LIBXML_VALID_ENABLED */
if (reader->ctxt->myDoc != NULL) { if (reader->ctxt->myDoc != NULL) {
if (reader->preserve == 0) if (reader->preserve == 0)
xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc); xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc);
@ -2971,7 +3019,7 @@ xmlTextReaderConstEncoding(xmlTextReaderPtr reader) {
/************************************************************************ /************************************************************************
* * * *
* Acces API to the current node * * Access API to the current node *
* * * *
************************************************************************/ ************************************************************************/
/** /**
@ -3786,7 +3834,7 @@ xmlTextReaderConstString(xmlTextReaderPtr reader, const xmlChar *str) {
* *
* The value indicating whether to normalize white space and attribute values. * The value indicating whether to normalize white space and attribute values.
* Since attribute value and end of line normalizations are a MUST in the XML * Since attribute value and end of line normalizations are a MUST in the XML
* specification only the value true is accepted. The broken bahaviour of * specification only the value true is accepted. The broken behaviour of
* accepting out of range character entities like &#0; is of course not * accepting out of range character entities like &#0; is of course not
* supported either. * supported either.
* *
@ -3848,16 +3896,20 @@ xmlTextReaderSetParserProp(xmlTextReaderPtr reader, int prop, int value) {
return(0); return(0);
case XML_PARSER_VALIDATE: case XML_PARSER_VALIDATE:
if (value != 0) { if (value != 0) {
ctxt->options |= XML_PARSE_DTDVALID;
ctxt->validate = 1; ctxt->validate = 1;
reader->validate = XML_TEXTREADER_VALIDATE_DTD; reader->validate = XML_TEXTREADER_VALIDATE_DTD;
} else { } else {
ctxt->options &= ~XML_PARSE_DTDVALID;
ctxt->validate = 0; ctxt->validate = 0;
} }
return(0); return(0);
case XML_PARSER_SUBST_ENTITIES: case XML_PARSER_SUBST_ENTITIES:
if (value != 0) { if (value != 0) {
ctxt->options |= XML_PARSE_NOENT;
ctxt->replaceEntities = 1; ctxt->replaceEntities = 1;
} else { } else {
ctxt->options &= ~XML_PARSE_NOENT;
ctxt->replaceEntities = 0; ctxt->replaceEntities = 0;
} }
return(0); return(0);

View file

@ -26,6 +26,9 @@
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
@ -36,6 +39,9 @@
#ifndef INT_MAX #ifndef INT_MAX
#define INT_MAX 123456789 /* easy to flag and big enough for our needs */ #define INT_MAX 123456789 /* easy to flag and big enough for our needs */
#endif #endif
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t) -1)
#endif
/* #define DEBUG_REGEXP_GRAPH */ /* #define DEBUG_REGEXP_GRAPH */
/* #define DEBUG_REGEXP_EXEC */ /* #define DEBUG_REGEXP_EXEC */
@ -267,6 +273,8 @@ struct _xmlAutomata {
int determinist; int determinist;
int negs; int negs;
int flags; int flags;
int depth;
}; };
struct _xmlRegexp { struct _xmlRegexp {
@ -418,6 +426,32 @@ xmlRegexpErrCompile(xmlRegParserCtxtPtr ctxt, const char *extra)
************************************************************************/ ************************************************************************/
static int xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt); static int xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt);
/**
* xmlRegCalloc2:
* @dim1: size of first dimension
* @dim2: size of second dimension
* @elemSize: size of element
*
* Allocate a two-dimensional array and set all elements to zero.
*
* Returns the new array or NULL in case of error.
*/
static void*
xmlRegCalloc2(size_t dim1, size_t dim2, size_t elemSize) {
size_t totalSize;
void *ret;
/* Check for overflow */
if (dim1 > SIZE_MAX / dim2 / elemSize)
return (NULL);
totalSize = dim1 * dim2 * elemSize;
ret = xmlMalloc(totalSize);
if (ret != NULL)
memset(ret, 0, totalSize);
return (ret);
}
/** /**
* xmlRegEpxFromParse: * xmlRegEpxFromParse:
* @ctxt: the parser context used to build it * @ctxt: the parser context used to build it
@ -540,8 +574,8 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
#ifdef DEBUG_COMPACTION #ifdef DEBUG_COMPACTION
printf("Final: %d atoms\n", nbatoms); printf("Final: %d atoms\n", nbatoms);
#endif #endif
transitions = (int *) xmlMalloc((nbstates + 1) * transitions = (int *) xmlRegCalloc2(nbstates + 1, nbatoms + 1,
(nbatoms + 1) * sizeof(int)); sizeof(int));
if (transitions == NULL) { if (transitions == NULL) {
xmlFree(stateRemap); xmlFree(stateRemap);
xmlFree(stringRemap); xmlFree(stringRemap);
@ -551,7 +585,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
xmlFree(ret); xmlFree(ret);
return(NULL); return(NULL);
} }
memset(transitions, 0, (nbstates + 1) * (nbatoms + 1) * sizeof(int));
/* /*
* Allocate the transition table. The first entry for each * Allocate the transition table. The first entry for each
@ -577,12 +610,9 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
continue; continue;
atomno = stringRemap[trans->atom->no]; atomno = stringRemap[trans->atom->no];
if ((trans->atom->data != NULL) && (transdata == NULL)) { if ((trans->atom->data != NULL) && (transdata == NULL)) {
transdata = (void **) xmlMalloc(nbstates * nbatoms * transdata = (void **) xmlRegCalloc2(nbstates, nbatoms,
sizeof(void *)); sizeof(void *));
if (transdata != NULL) if (transdata == NULL) {
memset(transdata, 0,
nbstates * nbatoms * sizeof(void *));
else {
xmlRegexpErrMemory(ctxt, "compiling regexp"); xmlRegexpErrMemory(ctxt, "compiling regexp");
break; break;
} }
@ -2628,7 +2658,6 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
state->markd = XML_REGEXP_MARK_VISITED; state->markd = XML_REGEXP_MARK_VISITED;
res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to], res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
to, atom); to, atom);
state->markd = 0;
if (res == 0) { if (res == 0) {
ret = 0; ret = 0;
/* t1->nd = 1; */ /* t1->nd = 1; */
@ -2646,6 +2675,30 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
return(ret); return(ret);
} }
/**
* xmlFAFinishRecurseDeterminism:
* @ctxt: a regexp parser context
*
* Reset flags after checking determinism.
*/
static void
xmlFAFinishRecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
int transnr, nbTrans;
if (state == NULL)
return;
if (state->markd != XML_REGEXP_MARK_VISITED)
return;
state->markd = 0;
nbTrans = state->nbTrans;
for (transnr = 0; transnr < nbTrans; transnr++) {
xmlRegTransPtr t1 = &state->trans[transnr];
if ((t1->atom == NULL) && (t1->to >= 0))
xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t1->to]);
}
}
/** /**
* xmlFAComputesDeterminism: * xmlFAComputesDeterminism:
* @ctxt: a regexp parser context * @ctxt: a regexp parser context
@ -2759,6 +2812,7 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
*/ */
ret = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to], ret = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
t2->to, t2->atom); t2->to, t2->atom);
xmlFAFinishRecurseDeterminism(ctxt, ctxt->states[t1->to]);
/* don't shortcut the computation so all non deterministic /* don't shortcut the computation so all non deterministic
transition get marked down transition get marked down
if (ret == 0) if (ret == 0)
@ -4221,7 +4275,7 @@ xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
* @values: pointer to the array of acceptable values * @values: pointer to the array of acceptable values
* @terminal: return value if this was a terminal state * @terminal: return value if this was a terminal state
* *
* Extract informations from the regexp execution, internal routine to * Extract information from the regexp execution, internal routine to
* implement xmlRegExecNextValues() and xmlRegExecErrInfo() * implement xmlRegExecNextValues() and xmlRegExecErrInfo()
* *
* Returns: 0 in case of success or -1 in case of error. * Returns: 0 in case of success or -1 in case of error.
@ -4380,7 +4434,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
* @values: pointer to the array of acceptable values * @values: pointer to the array of acceptable values
* @terminal: return value if this was a terminal state * @terminal: return value if this was a terminal state
* *
* Extract informations from the regexp execution, * Extract information from the regexp execution,
* the parameter @values must point to an array of @nbval string pointers * the parameter @values must point to an array of @nbval string pointers
* on return nbval will contain the number of possible strings in that * on return nbval will contain the number of possible strings in that
* state and the @values array will be updated with them. The string values * state and the @values array will be updated with them. The string values
@ -4404,7 +4458,7 @@ xmlRegExecNextValues(xmlRegExecCtxtPtr exec, int *nbval, int *nbneg,
* @values: pointer to the array of acceptable values * @values: pointer to the array of acceptable values
* @terminal: return value if this was a terminal state * @terminal: return value if this was a terminal state
* *
* Extract error informations from the regexp execution, the parameter * Extract error information from the regexp execution, the parameter
* @string will be updated with the value pushed and not accepted, * @string will be updated with the value pushed and not accepted,
* the parameter @values must point to an array of @nbval string pointers * the parameter @values must point to an array of @nbval string pointers
* on return nbval will contain the number of possible strings in that * on return nbval will contain the number of possible strings in that
@ -5101,7 +5155,7 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
} else { } else {
xmlFAParseCharRange(ctxt); xmlFAParseCharRange(ctxt);
} }
} while ((CUR != ']') && (CUR != '^') && (CUR != '-') && } while ((CUR != ']') && (CUR != '-') &&
(CUR != 0) && (ctxt->error == 0)); (CUR != 0) && (ctxt->error == 0));
} }
@ -5116,34 +5170,31 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
*/ */
static void static void
xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) { xmlFAParseCharGroup(xmlRegParserCtxtPtr ctxt) {
int n = ctxt->neg; int neg = ctxt->neg;
while ((CUR != ']') && (ctxt->error == 0)) {
if (CUR == '^') {
int neg = ctxt->neg;
NEXT; if (CUR == '^') {
ctxt->neg = !ctxt->neg; NEXT;
xmlFAParsePosCharGroup(ctxt); ctxt->neg = !ctxt->neg;
ctxt->neg = neg; xmlFAParsePosCharGroup(ctxt);
} else if ((CUR == '-') && (NXT(1) == '[')) { ctxt->neg = neg;
int neg = ctxt->neg; }
ctxt->neg = 2; while ((CUR != ']') && (ctxt->error == 0)) {
if ((CUR == '-') && (NXT(1) == '[')) {
NEXT; /* eat the '-' */ NEXT; /* eat the '-' */
NEXT; /* eat the '[' */ NEXT; /* eat the '[' */
ctxt->neg = 2;
xmlFAParseCharGroup(ctxt); xmlFAParseCharGroup(ctxt);
ctxt->neg = neg;
if (CUR == ']') { if (CUR == ']') {
NEXT; NEXT;
} else { } else {
ERROR("charClassExpr: ']' expected"); ERROR("charClassExpr: ']' expected");
break;
} }
ctxt->neg = neg;
break; break;
} else if (CUR != ']') { } else {
xmlFAParsePosCharGroup(ctxt); xmlFAParsePosCharGroup(ctxt);
} }
} }
ctxt->neg = n;
} }
/** /**
@ -5183,13 +5234,24 @@ static int
xmlFAParseQuantExact(xmlRegParserCtxtPtr ctxt) { xmlFAParseQuantExact(xmlRegParserCtxtPtr ctxt) {
int ret = 0; int ret = 0;
int ok = 0; int ok = 0;
int overflow = 0;
while ((CUR >= '0') && (CUR <= '9')) { while ((CUR >= '0') && (CUR <= '9')) {
ret = ret * 10 + (CUR - '0'); if (ret > INT_MAX / 10) {
overflow = 1;
} else {
int digit = CUR - '0';
ret *= 10;
if (ret > INT_MAX - digit)
overflow = 1;
else
ret += digit;
}
ok = 1; ok = 1;
NEXT; NEXT;
} }
if (ok != 1) { if ((ok != 1) || (overflow == 1)) {
return(-1); return(-1);
} }
return(ret); return(ret);
@ -5229,6 +5291,9 @@ xmlFAParseQuantifier(xmlRegParserCtxtPtr ctxt) {
cur = xmlFAParseQuantExact(ctxt); cur = xmlFAParseQuantExact(ctxt);
if (cur >= 0) if (cur >= 0)
min = cur; min = cur;
else {
ERROR("Improper quantifier");
}
if (CUR == ',') { if (CUR == ',') {
NEXT; NEXT;
if (CUR == '}') if (CUR == '}')
@ -5288,6 +5353,10 @@ xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
xmlRegStatePtr start, oldend, start0; xmlRegStatePtr start, oldend, start0;
NEXT; NEXT;
if (ctxt->depth >= 50) {
ERROR("xmlFAParseAtom: maximum nesting depth exceeded");
return(-1);
}
/* /*
* this extra Epsilon transition is needed if we count with 0 allowed * this extra Epsilon transition is needed if we count with 0 allowed
* unfortunately this can't be known at that point * unfortunately this can't be known at that point
@ -5299,7 +5368,9 @@ xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
oldend = ctxt->end; oldend = ctxt->end;
ctxt->end = NULL; ctxt->end = NULL;
ctxt->atom = NULL; ctxt->atom = NULL;
ctxt->depth++;
xmlFAParseRegExp(ctxt, 0); xmlFAParseRegExp(ctxt, 0);
ctxt->depth--;
if (CUR == ')') { if (CUR == ')') {
NEXT; NEXT;
} else { } else {
@ -6055,7 +6126,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
return(NULL); return(NULL);
if (min < 1) if (min < 1)
return(NULL); return(NULL);
if ((max < min) || (max < 1)) if (max < min)
return(NULL); return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING); atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL) if (atom == NULL)
@ -6134,7 +6205,7 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
return(NULL); return(NULL);
if (min < 1) if (min < 1)
return(NULL); return(NULL);
if ((max < min) || (max < 1)) if (max < min)
return(NULL); return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING); atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL) if (atom == NULL)

File diff suppressed because it is too large Load diff

View file

@ -860,6 +860,7 @@ struct _xmlSchemaIDCMatcher {
int sizeKeySeqs; int sizeKeySeqs;
xmlSchemaItemListPtr targets; /* list of target-node xmlSchemaItemListPtr targets; /* list of target-node
(xmlSchemaPSVIIDCNodePtr) entries */ (xmlSchemaPSVIIDCNodePtr) entries */
xmlHashTablePtr htab;
}; };
/* /*
@ -1002,11 +1003,11 @@ struct _xmlSchemaValidCtxt {
int xsiAssemble; int xsiAssemble;
int depth; int depth;
xmlSchemaNodeInfoPtr *elemInfos; /* array of element informations */ xmlSchemaNodeInfoPtr *elemInfos; /* array of element information */
int sizeElemInfos; int sizeElemInfos;
xmlSchemaNodeInfoPtr inode; /* the current element information */ xmlSchemaNodeInfoPtr inode; /* the current element information */
xmlSchemaIDCAugPtr aidcs; /* a list of augmented IDC informations */ xmlSchemaIDCAugPtr aidcs; /* a list of augmented IDC information */
xmlSchemaIDCStateObjPtr xpathStates; /* first active state object. */ xmlSchemaIDCStateObjPtr xpathStates; /* first active state object. */
xmlSchemaIDCStateObjPtr xpathStatePool; /* first stored state object. */ xmlSchemaIDCStateObjPtr xpathStatePool; /* first stored state object. */
@ -1055,6 +1056,18 @@ struct _xmlSchemaSubstGroup {
xmlSchemaItemListPtr members; xmlSchemaItemListPtr members;
}; };
/**
* xmlIDCHashEntry:
*
* an entry in hash tables to quickly look up keys/uniques
*/
typedef struct _xmlIDCHashEntry xmlIDCHashEntry;
typedef xmlIDCHashEntry *xmlIDCHashEntryPtr;
struct _xmlIDCHashEntry {
xmlIDCHashEntryPtr next; /* next item with same hash */
int index; /* index into associated item list */
};
/************************************************************************ /************************************************************************
* * * *
* Some predeclarations * * Some predeclarations *
@ -1478,6 +1491,7 @@ xmlSchemaWildcardPCToString(int pc)
* @val: the precomputed value * @val: the precomputed value
* @retValue: the returned value * @retValue: the returned value
* @ws: the whitespace type of the value * @ws: the whitespace type of the value
* @for_hash: non-zero if this is supposed to generate a string for hashing
* *
* Get a the canonical representation of the value. * Get a the canonical representation of the value.
* The caller has to free the returned retValue. * The caller has to free the returned retValue.
@ -1486,9 +1500,10 @@ xmlSchemaWildcardPCToString(int pc)
* API errors or if the value type is not supported yet. * API errors or if the value type is not supported yet.
*/ */
static int static int
xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val, xmlSchemaGetCanonValueWhtspExt_1(xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws, xmlSchemaWhitespaceValueType ws,
xmlChar **retValue) xmlChar **retValue,
int for_hash)
{ {
int list; int list;
xmlSchemaValType valType; xmlSchemaValType valType;
@ -1522,6 +1537,20 @@ xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,
xmlFree((xmlChar *) value2); xmlFree((xmlChar *) value2);
goto internal_error; goto internal_error;
} }
if (for_hash && valType == XML_SCHEMAS_DECIMAL) {
/* We can mostly use the canonical value for hashing,
except in the case of decimal. There the canonical
representation requires a trailing '.0' even for
non-fractional numbers, but for the derived integer
types it forbids any decimal point. Nevertheless they
compare equal if the value is equal. We need to generate
the same hash value for this to work, and it's easiest
to just cut off the useless '.0' suffix for the
decimal type. */
int len = xmlStrlen(value2);
if (len > 2 && value2[len-1] == '0' && value2[len-2] == '.')
((xmlChar*)value2)[len-2] = 0;
}
value = value2; value = value2;
} }
if (*retValue == NULL) if (*retValue == NULL)
@ -1548,6 +1577,22 @@ internal_error:
return (-1); return (-1);
} }
static int
xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws,
xmlChar **retValue)
{
return xmlSchemaGetCanonValueWhtspExt_1(val, ws, retValue, 0);
}
static int
xmlSchemaGetCanonValueHash(xmlSchemaValPtr val,
xmlChar **retValue)
{
return xmlSchemaGetCanonValueWhtspExt_1(val, XML_SCHEMA_WHITESPACE_COLLAPSE,
retValue, 1);
}
/** /**
* xmlSchemaFormatItemForReport: * xmlSchemaFormatItemForReport:
* @buf: the string buffer * @buf: the string buffer
@ -1873,7 +1918,7 @@ xmlSchemaPSimpleErr(const char *msg)
/** /**
* xmlSchemaPErrMemory: * xmlSchemaPErrMemory:
* @node: a context node * @node: a context node
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -1995,7 +2040,7 @@ xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
/** /**
* xmlSchemaVTypeErrMemory: * xmlSchemaVTypeErrMemory:
* @node: a context node * @node: a context node
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -6031,7 +6076,7 @@ xmlSchemaPValAttrID(xmlSchemaParserCtxtPtr ctxt,
/** /**
* xmlGetMaxOccurs: * xmlGetMaxOccurs:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Get the maxOccurs property * Get the maxOccurs property
* *
@ -6074,7 +6119,16 @@ xmlGetMaxOccurs(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
return (def); return (def);
} }
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
ret = ret * 10 + (*cur - '0'); if (ret > INT_MAX / 10) {
ret = INT_MAX;
} else {
int digit = *cur - '0';
ret *= 10;
if (ret > INT_MAX - digit)
ret = INT_MAX;
else
ret += digit;
}
cur++; cur++;
} }
while (IS_BLANK_CH(*cur)) while (IS_BLANK_CH(*cur))
@ -6096,7 +6150,7 @@ xmlGetMaxOccurs(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
/** /**
* xmlGetMinOccurs: * xmlGetMinOccurs:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Get the minOccurs property * Get the minOccurs property
* *
@ -6126,7 +6180,16 @@ xmlGetMinOccurs(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
return (def); return (def);
} }
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
ret = ret * 10 + (*cur - '0'); if (ret > INT_MAX / 10) {
ret = INT_MAX;
} else {
int digit = *cur - '0';
ret *= 10;
if (ret > INT_MAX - digit)
ret = INT_MAX;
else
ret += digit;
}
cur++; cur++;
} }
while (IS_BLANK_CH(*cur)) while (IS_BLANK_CH(*cur))
@ -6193,7 +6256,7 @@ xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt,
/** /**
* xmlGetBooleanProp: * xmlGetBooleanProp:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* @name: the attribute name * @name: the attribute name
* @def: the default value * @def: the default value
* *
@ -6481,7 +6544,7 @@ xmlSchemaCheckReference(xmlSchemaParserCtxtPtr pctxt,
* xmlSchemaParseLocalAttributes: * xmlSchemaParseLocalAttributes:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* @type: the hosting type where the attributes will be anchored * @type: the hosting type where the attributes will be anchored
* *
* Parses attribute uses and attribute declarations and * Parses attribute uses and attribute declarations and
@ -6523,7 +6586,7 @@ xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseAnnotation: * xmlSchemaParseAnnotation:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Attribute declaration * parse a XML schema Attribute declaration
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -6643,7 +6706,7 @@ xmlSchemaParseAnnotation(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int neede
* xmlSchemaParseFacet: * xmlSchemaParseFacet:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Facet declaration * parse a XML schema Facet declaration
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -6734,7 +6797,7 @@ xmlSchemaParseFacet(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseWildcardNs: * xmlSchemaParseWildcardNs:
* @ctxt: a schema parser context * @ctxt: a schema parser context
* @wildc: the wildcard, already created * @wildc: the wildcard, already created
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parses the attribute "processContents" and "namespace" * Parses the attribute "processContents" and "namespace"
* of a xsd:anyAttribute and xsd:any. * of a xsd:anyAttribute and xsd:any.
@ -6901,7 +6964,7 @@ xmlSchemaPCheckParticleCorrect_2(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseAny: * xmlSchemaParseAny:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parsea a XML schema <any> element. A particle and wildcard * Parsea a XML schema <any> element. A particle and wildcard
* will be created (except if minOccurs==maxOccurs==0, in this case * will be created (except if minOccurs==maxOccurs==0, in this case
@ -6996,7 +7059,7 @@ xmlSchemaParseAny(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseNotation: * xmlSchemaParseNotation:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Notation declaration * parse a XML schema Notation declaration
* *
@ -7043,7 +7106,7 @@ xmlSchemaParseNotation(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseAnyAttribute: * xmlSchemaParseAnyAttribute:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema AnyAttribute declaration * parse a XML schema AnyAttribute declaration
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -7113,7 +7176,7 @@ xmlSchemaParseAnyAttribute(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseAttribute: * xmlSchemaParseAttribute:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Attribute declaration * parse a XML schema Attribute declaration
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -7656,7 +7719,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
* xmlSchemaParseAttributeGroupRef: * xmlSchemaParseAttributeGroupRef:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parse an attribute group definition reference. * Parse an attribute group definition reference.
* Note that a reference to an attribute group does not * Note that a reference to an attribute group does not
@ -7789,7 +7852,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
* xmlSchemaParseAttributeGroupDefinition: * xmlSchemaParseAttributeGroupDefinition:
* @pctxt: a schema validation context * @pctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Attribute Group declaration * parse a XML schema Attribute Group declaration
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -8220,7 +8283,7 @@ xmlSchemaAddAnnotation(xmlSchemaAnnotItemPtr annItem,
* xmlSchemaParseIDCSelectorAndField: * xmlSchemaParseIDCSelectorAndField:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parses a XML Schema identity-constraint definition's * Parses a XML Schema identity-constraint definition's
* <selector> and <field> elements. * <selector> and <field> elements.
@ -8318,7 +8381,7 @@ xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseIDC: * xmlSchemaParseIDC:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parses a XML Schema identity-constraint definition. * Parses a XML Schema identity-constraint definition.
* *
@ -8465,7 +8528,7 @@ xmlSchemaParseIDC(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseElement: * xmlSchemaParseElement:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* @topLevel: indicates if this is global declaration * @topLevel: indicates if this is global declaration
* *
* Parses a XML schema element declaration. * Parses a XML schema element declaration.
@ -8864,7 +8927,7 @@ return_null:
* xmlSchemaParseUnion: * xmlSchemaParseUnion:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Union definition * parse a XML schema Union definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -9033,7 +9096,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseList: * xmlSchemaParseList:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema List definition * parse a XML schema List definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -9144,7 +9207,7 @@ xmlSchemaParseList(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseSimpleType: * xmlSchemaParseSimpleType:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Simple Type definition * parse a XML schema Simple Type definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -9455,7 +9518,7 @@ xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseModelGroupDefinition: * xmlSchemaParseModelGroupDefinition:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parses a XML schema model group definition. * Parses a XML schema model group definition.
* *
@ -10293,7 +10356,7 @@ xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location,
* xmlSchemaAddSchemaDoc: * xmlSchemaAddSchemaDoc:
* @pctxt: a schema validation context * @pctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parse an included (and to-be-redefined) XML schema document. * Parse an included (and to-be-redefined) XML schema document.
* *
@ -10717,7 +10780,7 @@ exit_failure:
* xmlSchemaParseImport: * xmlSchemaParseImport:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Import definition * parse a XML schema Import definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -11209,7 +11272,7 @@ xmlSchemaParseInclude(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
* xmlSchemaParseModelGroup: * xmlSchemaParseModelGroup:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* @type: the "compositor" type * @type: the "compositor" type
* @particleNeeded: if a a model group with a particle * @particleNeeded: if a a model group with a particle
* *
@ -11489,7 +11552,7 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseRestriction: * xmlSchemaParseRestriction:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Restriction definition * parse a XML schema Restriction definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -11792,7 +11855,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseExtension: * xmlSchemaParseExtension:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* Parses an <extension>, which is found inside a * Parses an <extension>, which is found inside a
* <simpleContent> or <complexContent>. * <simpleContent> or <complexContent>.
@ -11928,7 +11991,7 @@ xmlSchemaParseExtension(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* xmlSchemaParseSimpleContent: * xmlSchemaParseSimpleContent:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema SimpleContent definition * parse a XML schema SimpleContent definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -12018,7 +12081,7 @@ xmlSchemaParseSimpleContent(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseComplexContent: * xmlSchemaParseComplexContent:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema ComplexContent definition * parse a XML schema ComplexContent definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -12113,7 +12176,7 @@ xmlSchemaParseComplexContent(xmlSchemaParserCtxtPtr ctxt,
* xmlSchemaParseComplexType: * xmlSchemaParseComplexType:
* @ctxt: a schema validation context * @ctxt: a schema validation context
* @schema: the schema being built * @schema: the schema being built
* @node: a subtree containing XML Schema informations * @node: a subtree containing XML Schema information
* *
* parse a XML schema Complex Type definition * parse a XML schema Complex Type definition
* *WARNING* this interface is highly subject to change * *WARNING* this interface is highly subject to change
@ -14658,6 +14721,7 @@ xmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type)
return (NULL); return (NULL);
} }
#if 0
/** /**
* xmlSchemaGetParticleTotalRangeMin: * xmlSchemaGetParticleTotalRangeMin:
* @particle: the particle * @particle: the particle
@ -14713,7 +14777,6 @@ xmlSchemaGetParticleTotalRangeMin(xmlSchemaParticlePtr particle)
} }
} }
#if 0
/** /**
* xmlSchemaGetParticleTotalRangeMax: * xmlSchemaGetParticleTotalRangeMax:
* @particle: the particle * @particle: the particle
@ -14775,6 +14838,48 @@ xmlSchemaGetParticleTotalRangeMax(xmlSchemaParticlePtr particle)
} }
#endif #endif
/**
* xmlSchemaGetParticleEmptiable:
* @particle: the particle
*
* Returns 1 if emptiable, 0 otherwise.
*/
static int
xmlSchemaGetParticleEmptiable(xmlSchemaParticlePtr particle)
{
xmlSchemaParticlePtr part;
int emptiable;
if ((particle->children == NULL) || (particle->minOccurs == 0))
return (1);
part = (xmlSchemaParticlePtr) particle->children->children;
if (part == NULL)
return (1);
while (part != NULL) {
if ((part->children->type == XML_SCHEMA_TYPE_ELEMENT) ||
(part->children->type == XML_SCHEMA_TYPE_ANY))
emptiable = (part->minOccurs == 0);
else
emptiable = xmlSchemaGetParticleEmptiable(part);
if (particle->children->type == XML_SCHEMA_TYPE_CHOICE) {
if (emptiable)
return (1);
} else {
/* <all> and <sequence> */
if (!emptiable)
return (0);
}
part = (xmlSchemaParticlePtr) part->next;
}
if (particle->children->type == XML_SCHEMA_TYPE_CHOICE)
return (0);
else
return (1);
}
/** /**
* xmlSchemaIsParticleEmptiable: * xmlSchemaIsParticleEmptiable:
* @particle: the particle * @particle: the particle
@ -14797,10 +14902,8 @@ xmlSchemaIsParticleEmptiable(xmlSchemaParticlePtr particle)
* SPEC (2) "Its {term} is a group and the minimum part of the * SPEC (2) "Its {term} is a group and the minimum part of the
* effective total range of that group, [...] is 0." * effective total range of that group, [...] is 0."
*/ */
if (WXS_IS_MODEL_GROUP(particle->children)) { if (WXS_IS_MODEL_GROUP(particle->children))
if (xmlSchemaGetParticleTotalRangeMin(particle) == 0) return (xmlSchemaGetParticleEmptiable(particle));
return (1);
}
return (0); return (0);
} }
@ -14938,7 +15041,7 @@ xmlSchemaCheckTypeDefCircularInternal(xmlSchemaParserCtxtPtr pctxt,
} }
if (ancestor->flags & XML_SCHEMAS_TYPE_MARKED) { if (ancestor->flags & XML_SCHEMAS_TYPE_MARKED) {
/* /*
* Avoid inifinite recursion on circular types not yet checked. * Avoid infinite recursion on circular types not yet checked.
*/ */
return (0); return (0);
} }
@ -20961,7 +21064,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
break; break;
case XML_SCHEMA_EXTRA_ATTR_USE_PROHIB: case XML_SCHEMA_EXTRA_ATTR_USE_PROHIB:
/* /*
* Handle attribue prohibition which had a * Handle attribute prohibition which had a
* "ref" attribute. * "ref" attribute.
*/ */
xmlSchemaResolveAttrUseProhibReferences( xmlSchemaResolveAttrUseProhibReferences(
@ -22293,6 +22396,17 @@ xmlSchemaIDCFreeIDCTable(xmlSchemaPSVIIDCBindingPtr bind)
} }
} }
static void
xmlFreeIDCHashEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
{
xmlIDCHashEntryPtr e = payload, n;
while (e) {
n = e->next;
xmlFree(e);
e = n;
}
}
/** /**
* xmlSchemaIDCFreeMatcherList: * xmlSchemaIDCFreeMatcherList:
* @matcher: the first IDC matcher in the list * @matcher: the first IDC matcher in the list
@ -22331,6 +22445,8 @@ xmlSchemaIDCFreeMatcherList(xmlSchemaIDCMatcherPtr matcher)
} }
xmlSchemaItemListFree(matcher->targets); xmlSchemaItemListFree(matcher->targets);
} }
if (matcher->htab != NULL)
xmlHashFree(matcher->htab, xmlFreeIDCHashEntry);
xmlFree(matcher); xmlFree(matcher);
matcher = next; matcher = next;
} }
@ -22381,6 +22497,10 @@ xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt,
xmlSchemaItemListFree(matcher->targets); xmlSchemaItemListFree(matcher->targets);
matcher->targets = NULL; matcher->targets = NULL;
} }
if (matcher->htab != NULL) {
xmlHashFree(matcher->htab, xmlFreeIDCHashEntry);
matcher->htab = NULL;
}
matcher->next = NULL; matcher->next = NULL;
/* /*
* Cache the matcher. * Cache the matcher.
@ -22615,10 +22735,10 @@ next_sto:
} }
static const xmlChar * static const xmlChar *
xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt, xmlSchemaFormatIDCKeySequence_1(xmlSchemaValidCtxtPtr vctxt,
xmlChar **buf, xmlChar **buf,
xmlSchemaPSVIIDCKeyPtr *seq, xmlSchemaPSVIIDCKeyPtr *seq,
int count) int count, int for_hash)
{ {
int i, res; int i, res;
xmlChar *value = NULL; xmlChar *value = NULL;
@ -22626,9 +22746,13 @@ xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt,
*buf = xmlStrdup(BAD_CAST "["); *buf = xmlStrdup(BAD_CAST "[");
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
*buf = xmlStrcat(*buf, BAD_CAST "'"); *buf = xmlStrcat(*buf, BAD_CAST "'");
res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val, if (!for_hash)
xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type), res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val,
&value); xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type),
&value);
else {
res = xmlSchemaGetCanonValueHash(seq[i]->val, &value);
}
if (res == 0) if (res == 0)
*buf = xmlStrcat(*buf, BAD_CAST value); *buf = xmlStrcat(*buf, BAD_CAST value);
else { else {
@ -22650,6 +22774,24 @@ xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt,
return (BAD_CAST *buf); return (BAD_CAST *buf);
} }
static const xmlChar *
xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt,
xmlChar **buf,
xmlSchemaPSVIIDCKeyPtr *seq,
int count)
{
return xmlSchemaFormatIDCKeySequence_1(vctxt, buf, seq, count, 0);
}
static const xmlChar *
xmlSchemaHashKeySequence(xmlSchemaValidCtxtPtr vctxt,
xmlChar **buf,
xmlSchemaPSVIIDCKeyPtr *seq,
int count)
{
return xmlSchemaFormatIDCKeySequence_1(vctxt, buf, seq, count, 1);
}
/** /**
* xmlSchemaXPathPop: * xmlSchemaXPathPop:
* @vctxt: the WXS validation context * @vctxt: the WXS validation context
@ -23011,15 +23153,25 @@ create_key:
if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) && if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) &&
(targets->nbItems != 0)) { (targets->nbItems != 0)) {
xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq; xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq;
xmlIDCHashEntryPtr e;
i = 0;
res = 0; res = 0;
if (!matcher->htab)
e = NULL;
else {
xmlChar *value = NULL;
xmlSchemaHashKeySequence(vctxt, &value, *keySeq, nbKeys);
e = xmlHashLookup(matcher->htab, value);
FREE_AND_NULL(value);
}
/* /*
* Compare the key-sequences, key by key. * Compare the key-sequences, key by key.
*/ */
do { for (;e; e = e->next) {
bkeySeq = bkeySeq =
((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys; ((xmlSchemaPSVIIDCNodePtr) targets->items[e->index])->keys;
for (j = 0; j < nbKeys; j++) { for (j = 0; j < nbKeys; j++) {
ckey = (*keySeq)[j]; ckey = (*keySeq)[j];
bkey = bkeySeq[j]; bkey = bkeySeq[j];
@ -23040,9 +23192,8 @@ create_key:
*/ */
break; break;
} }
i++; }
} while (i < targets->nbItems); if (e) {
if (i != targets->nbItems) {
xmlChar *str = NULL, *strB = NULL; xmlChar *str = NULL, *strB = NULL;
/* /*
* TODO: Try to report the key-sequence. * TODO: Try to report the key-sequence.
@ -23120,6 +23271,24 @@ create_key:
} }
return (-1); return (-1);
} }
if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) {
xmlChar *value = NULL;
xmlIDCHashEntryPtr r, e;
if (!matcher->htab)
matcher->htab = xmlHashCreate(4);
xmlSchemaHashKeySequence(vctxt, &value, ntItem->keys, nbKeys);
e = xmlMalloc(sizeof *e);
e->index = targets->nbItems - 1;
r = xmlHashLookup(matcher->htab, value);
if (r) {
e->next = r->next;
r->next = e;
} else {
e->next = NULL;
xmlHashAddEntry(matcher->htab, value, e);
}
FREE_AND_NULL(value);
}
goto selector_leave; goto selector_leave;
selector_key_error: selector_key_error:
@ -23376,6 +23545,10 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
matcher->targets->items = NULL; matcher->targets->items = NULL;
matcher->targets->sizeItems = 0; matcher->targets->sizeItems = 0;
matcher->targets->nbItems = 0; matcher->targets->nbItems = 0;
if (matcher->htab) {
xmlHashFree(matcher->htab, xmlFreeIDCHashEntry);
matcher->htab = NULL;
}
} else { } else {
/* /*
* Compare the key-sequences and add to the IDC node-table. * Compare the key-sequences and add to the IDC node-table.
@ -23823,6 +23996,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
int i, j, k, res, nbFields, hasDupls; int i, j, k, res, nbFields, hasDupls;
xmlSchemaPSVIIDCKeyPtr *refKeys, *keys; xmlSchemaPSVIIDCKeyPtr *refKeys, *keys;
xmlSchemaPSVIIDCNodePtr refNode = NULL; xmlSchemaPSVIIDCNodePtr refNode = NULL;
xmlHashTablePtr table = NULL;
nbFields = matcher->aidc->def->nbFields; nbFields = matcher->aidc->def->nbFields;
@ -23840,26 +24014,52 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
/* /*
* Search for a matching key-sequences. * Search for a matching key-sequences.
*/ */
if (bind) {
table = xmlHashCreate(bind->nbNodes * 2);
for (j = 0; j < bind->nbNodes; j++) {
xmlChar *value;
xmlIDCHashEntryPtr r, e;
keys = bind->nodeTable[j]->keys;
xmlSchemaHashKeySequence(vctxt, &value, keys, nbFields);
e = xmlMalloc(sizeof *e);
e->index = j;
r = xmlHashLookup(table, value);
if (r) {
e->next = r->next;
r->next = e;
} else {
e->next = NULL;
xmlHashAddEntry(table, value, e);
}
FREE_AND_NULL(value);
}
}
for (i = 0; i < matcher->targets->nbItems; i++) { for (i = 0; i < matcher->targets->nbItems; i++) {
res = 0; res = 0;
refNode = matcher->targets->items[i]; refNode = matcher->targets->items[i];
if (bind != NULL) { if (bind != NULL) {
xmlChar *value;
xmlIDCHashEntryPtr e;
refKeys = refNode->keys; refKeys = refNode->keys;
for (j = 0; j < bind->nbNodes; j++) { xmlSchemaHashKeySequence(vctxt, &value, refKeys, nbFields);
keys = bind->nodeTable[j]->keys; e = xmlHashLookup(table, value);
FREE_AND_NULL(value);
res = 0;
for (;e; e = e->next) {
keys = bind->nodeTable[e->index]->keys;
for (k = 0; k < nbFields; k++) { for (k = 0; k < nbFields; k++) {
res = xmlSchemaAreValuesEqual(keys[k]->val, res = xmlSchemaAreValuesEqual(keys[k]->val,
refKeys[k]->val); refKeys[k]->val);
if (res == 0) if (res == 0)
break; break;
else if (res == -1) { else if (res == -1) {
return (-1); return (-1);
} }
} }
if (res == 1) { if (res == 1) {
/* /*
* Match found. * Match found.
*/ */
break; break;
} }
} }
@ -23914,6 +24114,9 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
FREE_AND_NULL(strB); FREE_AND_NULL(strB);
} }
} }
if (table) {
xmlHashFree(table, xmlFreeIDCHashEntry);
}
} }
matcher = matcher->next; matcher = matcher->next;
} }
@ -24184,7 +24387,7 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt,
unsigned long length, unsigned long length,
int fireErrors) int fireErrors)
{ {
int ret, error = 0; int ret, error = 0, found;
xmlSchemaTypePtr tmpType; xmlSchemaTypePtr tmpType;
xmlSchemaFacetLinkPtr facetLink; xmlSchemaFacetLinkPtr facetLink;
@ -24308,103 +24511,98 @@ WXS_IS_LIST:
} }
pattern_and_enum: pattern_and_enum:
if (error >= 0) { found = 0;
int found = 0; /*
/* * Process enumerations. Facet values are in the value space
* Process enumerations. Facet values are in the value space * of the defining type's base type. This seems to be a bug in the
* of the defining type's base type. This seems to be a bug in the * XML Schema 1.0 spec. Use the whitespace type of the base type.
* XML Schema 1.0 spec. Use the whitespace type of the base type. * Only the first set of enumerations in the ancestor-or-self axis
* Only the first set of enumerations in the ancestor-or-self axis * is used for validation.
* is used for validation. */
*/ ret = 0;
ret = 0; tmpType = type;
tmpType = type; do {
do { for (facet = tmpType->facets; facet != NULL; facet = facet->next) {
for (facet = tmpType->facets; facet != NULL; facet = facet->next) { if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
if (facet->type != XML_SCHEMA_FACET_ENUMERATION) continue;
continue; found = 1;
found = 1; ret = xmlSchemaAreValuesEqual(facet->val, val);
ret = xmlSchemaAreValuesEqual(facet->val, val); if (ret == 1)
if (ret == 1) break;
break; else if (ret < 0) {
else if (ret < 0) { AERROR_INT("xmlSchemaValidateFacets",
AERROR_INT("xmlSchemaValidateFacets", "validating against an enumeration facet");
"validating against an enumeration facet"); return (-1);
return (-1); }
} }
} if (ret != 0)
if (ret != 0) break;
break; /*
/* * Break on the first set of enumerations. Any additional
* Break on the first set of enumerations. Any additional * enumerations which might be existent on the ancestors
* enumerations which might be existent on the ancestors * of the current type are restricted by this set; thus
* of the current type are restricted by this set; thus * *must* *not* be taken into account.
* *must* *not* be taken into account. */
*/ if (found)
if (found) break;
break; tmpType = tmpType->baseType;
tmpType = tmpType->baseType; } while ((tmpType != NULL) &&
} while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
(tmpType->type != XML_SCHEMA_TYPE_BASIC)); if (found && (ret == 0)) {
if (found && (ret == 0)) { ret = XML_SCHEMAV_CVC_ENUMERATION_VALID;
ret = XML_SCHEMAV_CVC_ENUMERATION_VALID; if (fireErrors) {
if (fireErrors) { xmlSchemaFacetErr(actxt, ret, node,
xmlSchemaFacetErr(actxt, ret, node, value, 0, type, NULL, NULL, NULL, NULL);
value, 0, type, NULL, NULL, NULL, NULL); } else
} else return (ret);
return (ret); if (error == 0)
if (error == 0) error = ret;
error = ret;
}
} }
if (error >= 0) { /*
int found; * Process patters. Pattern facets are ORed at type level
/* * and ANDed if derived. Walk the base type axis.
* Process patters. Pattern facets are ORed at type level */
* and ANDed if derived. Walk the base type axis. tmpType = type;
*/ facet = NULL;
tmpType = type; do {
facet = NULL; found = 0;
do { for (facetLink = tmpType->facetSet; facetLink != NULL;
found = 0; facetLink = facetLink->next) {
for (facetLink = tmpType->facetSet; facetLink != NULL; if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
facetLink = facetLink->next) { continue;
if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN) found = 1;
continue; /*
found = 1; * NOTE that for patterns, @value needs to be the
/* * normalized value.
* NOTE that for patterns, @value needs to be the */
* normalized value. ret = xmlRegexpExec(facetLink->facet->regexp, value);
*/ if (ret == 1)
ret = xmlRegexpExec(facetLink->facet->regexp, value); break;
if (ret == 1) else if (ret < 0) {
break; AERROR_INT("xmlSchemaValidateFacets",
else if (ret < 0) { "validating against a pattern facet");
AERROR_INT("xmlSchemaValidateFacets", return (-1);
"validating against a pattern facet"); } else {
return (-1); /*
} else { * Save the last non-validating facet.
/* */
* Save the last non-validating facet. facet = facetLink->facet;
*/ }
facet = facetLink->facet; }
} if (found && (ret != 1)) {
} ret = XML_SCHEMAV_CVC_PATTERN_VALID;
if (found && (ret != 1)) { if (fireErrors) {
ret = XML_SCHEMAV_CVC_PATTERN_VALID; xmlSchemaFacetErr(actxt, ret, node,
if (fireErrors) { value, 0, type, facet, NULL, NULL, NULL);
xmlSchemaFacetErr(actxt, ret, node, } else
value, 0, type, facet, NULL, NULL, NULL); return (ret);
} else if (error == 0)
return (ret); error = ret;
if (error == 0) break;
error = ret; }
break; tmpType = tmpType->baseType;
} } while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
tmpType = tmpType->baseType;
} while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
}
return (error); return (error);
} }
@ -27802,7 +28000,7 @@ xmlSchemaIsValid(xmlSchemaValidCtxtPtr ctxt)
* @warn: the warning function * @warn: the warning function
* @ctx: the functions context * @ctx: the functions context
* *
* Set the error and warning callback informations * Set the error and warning callback information
*/ */
void void
xmlSchemaSetValidErrors(xmlSchemaValidCtxtPtr ctxt, xmlSchemaSetValidErrors(xmlSchemaValidCtxtPtr ctxt,
@ -27847,7 +28045,7 @@ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
* @warn: the warning function result * @warn: the warning function result
* @ctx: the functions context result * @ctx: the functions context result
* *
* Get the error and warning callback informations * Get the error and warning callback information
* *
* Returns -1 in case of error and 0 otherwise * Returns -1 in case of error and 0 otherwise
*/ */
@ -27938,6 +28136,10 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
VERROR(1, NULL, "The document has no document element"); VERROR(1, NULL, "The document has no document element");
return (1); return (1);
} }
for (node = valRoot->next; node != NULL; node = node->next) {
if (node->type == XML_ELEMENT_NODE)
VERROR(1, NULL, "The document has more than one top element");
}
vctxt->depth = -1; vctxt->depth = -1;
vctxt->validationRoot = valRoot; vctxt->validationRoot = valRoot;
node = valRoot; node = valRoot;
@ -28095,7 +28297,6 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
vctxt->nberrors = 0; vctxt->nberrors = 0;
vctxt->depth = -1; vctxt->depth = -1;
vctxt->skipDepth = -1; vctxt->skipDepth = -1;
vctxt->xsiAssemble = 0;
vctxt->hasKeyrefs = 0; vctxt->hasKeyrefs = 0;
#ifdef ENABLE_IDC_NODE_TABLES_TEST #ifdef ENABLE_IDC_NODE_TABLES_TEST
vctxt->createIDCNodeTables = 1; vctxt->createIDCNodeTables = 1;
@ -28273,13 +28474,13 @@ struct _xmlSchemaSplitSAXData {
struct _xmlSchemaSAXPlug { struct _xmlSchemaSAXPlug {
unsigned int magic; unsigned int magic;
/* the original callbacks informations */ /* the original callbacks information */
xmlSAXHandlerPtr *user_sax_ptr; xmlSAXHandlerPtr *user_sax_ptr;
xmlSAXHandlerPtr user_sax; xmlSAXHandlerPtr user_sax;
void **user_data_ptr; void **user_data_ptr;
void *user_data; void *user_data;
/* the block plugged back and validation informations */ /* the block plugged back and validation information */
xmlSAXHandler schemas_sax; xmlSAXHandler schemas_sax;
xmlSchemaValidCtxtPtr ctxt; xmlSchemaValidCtxtPtr ctxt;
}; };

View file

@ -199,7 +199,7 @@ static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef = NULL;
************************************************************************/ ************************************************************************/
/** /**
* xmlSchemaTypeErrMemory: * xmlSchemaTypeErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle an out of memory condition * Handle an out of memory condition
*/ */
@ -1160,9 +1160,12 @@ static const unsigned int daysInMonthLeap[12] =
#define VALID_DATETIME(dt) \ #define VALID_DATETIME(dt) \
(VALID_DATE(dt) && VALID_TIME(dt)) (VALID_DATE(dt) && VALID_TIME(dt))
#define SECS_PER_MIN (60) #define SECS_PER_MIN 60
#define SECS_PER_HOUR (60 * SECS_PER_MIN) #define MINS_PER_HOUR 60
#define SECS_PER_DAY (24 * SECS_PER_HOUR) #define HOURS_PER_DAY 24
#define SECS_PER_HOUR (MINS_PER_HOUR * SECS_PER_MIN)
#define SECS_PER_DAY (HOURS_PER_DAY * SECS_PER_HOUR)
#define MINS_PER_DAY (HOURS_PER_DAY * MINS_PER_HOUR)
static const long dayInYearByMonth[12] = static const long dayInYearByMonth[12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
@ -1222,7 +1225,14 @@ _xmlSchemaParseGYear (xmlSchemaValDatePtr dt, const xmlChar **str) {
firstChar = cur; firstChar = cur;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
dt->year = dt->year * 10 + (*cur - '0'); int digit = *cur - '0';
if (dt->year > LONG_MAX / 10)
return 2;
dt->year *= 10;
if (dt->year > LONG_MAX - digit)
return 2;
dt->year += digit;
cur++; cur++;
digcnt++; digcnt++;
} }
@ -1791,10 +1801,8 @@ xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
xmlSchemaValPtr dur; xmlSchemaValPtr dur;
int isneg = 0; int isneg = 0;
unsigned int seq = 0; unsigned int seq = 0;
double num; long days, secs = 0;
int num_type = 0; /* -1 = invalid, 0 = int, 1 = floating */ double sec_frac = 0.0;
const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'};
const double multi[] = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0};
if (duration == NULL) if (duration == NULL)
return -1; return -1;
@ -1819,6 +1827,10 @@ xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
return -1; return -1;
while (*cur != 0) { while (*cur != 0) {
long num = 0;
size_t has_digits = 0;
int has_frac = 0;
const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'};
/* input string should be empty or invalid date/time item */ /* input string should be empty or invalid date/time item */
if (seq >= sizeof(desig)) if (seq >= sizeof(desig))
@ -1826,53 +1838,104 @@ xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
/* T designator must be present for time items */ /* T designator must be present for time items */
if (*cur == 'T') { if (*cur == 'T') {
if (seq <= 3) { if (seq > 3)
seq = 3; goto error;
cur++; cur++;
} else seq = 3;
return 1;
} else if (seq == 3) } else if (seq == 3)
goto error; goto error;
/* parse the number portion of the item */ /* Parse integral part. */
PARSE_NUM(num, cur, num_type); while (*cur >= '0' && *cur <= '9') {
long digit = *cur - '0';
if ((num_type == -1) || (*cur == 0)) if (num > LONG_MAX / 10)
goto error; goto error;
num *= 10;
if (num > LONG_MAX - digit)
goto error;
num += digit;
/* update duration based on item type */ has_digits = 1;
while (seq < sizeof(desig)) { cur++;
if (*cur == desig[seq]) { }
/* verify numeric type; only seconds can be float */ if (*cur == '.') {
if ((num_type != 0) && (seq < (sizeof(desig)-1))) /* Parse fractional part. */
goto error; double mult = 1.0;
cur++;
switch (seq) { has_frac = 1;
case 0: while (*cur >= '0' && *cur <= '9') {
dur->value.dur.mon = (long)num * 12; mult /= 10.0;
break; sec_frac += (*cur - '0') * mult;
case 1: has_digits = 1;
dur->value.dur.mon += (long)num; cur++;
break;
default:
/* convert to seconds using multiplier */
dur->value.dur.sec += num * multi[seq];
seq++;
break;
}
break; /* exit loop */
} }
/* no date designators found? */ }
if ((++seq == 3) || (seq == 6))
while (*cur != desig[seq]) {
seq++;
/* No T designator or invalid char. */
if (seq == 3 || seq == sizeof(desig))
goto error; goto error;
} }
cur++; cur++;
if (collapse)
while IS_WSP_BLANK_CH(*cur) cur++; if (!has_digits || (has_frac && (seq != 5)))
goto error;
switch (seq) {
case 0:
/* Year */
if (num > LONG_MAX / 12)
goto error;
dur->value.dur.mon = num * 12;
break;
case 1:
/* Month */
if (dur->value.dur.mon > LONG_MAX - num)
goto error;
dur->value.dur.mon += num;
break;
case 2:
/* Day */
dur->value.dur.day = num;
break;
case 3:
/* Hour */
days = num / HOURS_PER_DAY;
if (dur->value.dur.day > LONG_MAX - days)
goto error;
dur->value.dur.day += days;
secs = (num % HOURS_PER_DAY) * SECS_PER_HOUR;
break;
case 4:
/* Minute */
days = num / MINS_PER_DAY;
if (dur->value.dur.day > LONG_MAX - days)
goto error;
dur->value.dur.day += days;
secs += (num % MINS_PER_DAY) * SECS_PER_MIN;
break;
case 5:
/* Second */
days = num / SECS_PER_DAY;
if (dur->value.dur.day > LONG_MAX - days)
goto error;
dur->value.dur.day += days;
secs += num % SECS_PER_DAY;
break;
}
seq++;
} }
days = secs / SECS_PER_DAY;
if (dur->value.dur.day > LONG_MAX - days)
goto error;
dur->value.dur.day += days;
dur->value.dur.sec = (secs % SECS_PER_DAY) + sec_frac;
if (isneg) { if (isneg) {
dur->value.dur.mon = -dur->value.dur.mon; dur->value.dur.mon = -dur->value.dur.mon;
dur->value.dur.day = -dur->value.dur.day; dur->value.dur.day = -dur->value.dur.day;
@ -2124,6 +2187,44 @@ xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,
return(ret); return(ret);
} }
/*
* xmlSchemaCheckLanguageType
* @value: the value to check
*
* Check that a value conforms to the lexical space of the language datatype.
* Must conform to [a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
*
* Returns 1 if this validates, 0 otherwise.
*/
static int
xmlSchemaCheckLanguageType(const xmlChar* value) {
int first = 1, len = 0;
const xmlChar* cur = value;
if (value == NULL)
return (0);
while (cur[0] != 0) {
if (!( ((cur[0] >= 'a') && (cur[0] <= 'z')) || ((cur[0] >= 'A') && (cur[0] <= 'Z'))
|| (cur[0] == '-')
|| ((first == 0) && (xmlIsDigit_ch(cur[0]))) ))
return (0);
if (cur[0] == '-') {
if ((len < 1) || (len > 8))
return (0);
len = 0;
first = 0;
}
else
len++;
cur++;
}
if ((len < 1) || (len > 8))
return (0);
return (1);
}
/** /**
* xmlSchemaValAtomicType: * xmlSchemaValAtomicType:
* @type: the predefined type * @type: the predefined type
@ -2636,12 +2737,13 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
goto return0; goto return0;
} }
case XML_SCHEMAS_LANGUAGE: case XML_SCHEMAS_LANGUAGE:
if (normOnTheFly) { if ((norm == NULL) && (normOnTheFly)) {
norm = xmlSchemaCollapseString(value); norm = xmlSchemaCollapseString(value);
if (norm != NULL) if (norm != NULL)
value = norm; value = norm;
} }
if (xmlCheckLanguageID(value) == 1) {
if (xmlSchemaCheckLanguageType(value) == 1) {
if (val != NULL) { if (val != NULL) {
v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE); v = xmlSchemaNewValue(XML_SCHEMAS_LANGUAGE);
if (v != NULL) { if (v != NULL) {
@ -3628,6 +3730,8 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
minday = 0; minday = 0;
maxday = 0; maxday = 0;
} else { } else {
if (myear > LONG_MAX / 366)
return -2;
/* FIXME: This doesn't take leap year exceptions every 100/400 years /* FIXME: This doesn't take leap year exceptions every 100/400 years
into account. */ into account. */
maxday = 365 * myear + (myear + 3) / 4; maxday = 365 * myear + (myear + 3) / 4;
@ -4016,6 +4120,14 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
if ((x == NULL) || (y == NULL)) if ((x == NULL) || (y == NULL))
return -2; return -2;
if ((x->value.date.year > LONG_MAX / 366) ||
(x->value.date.year < LONG_MIN / 366) ||
(y->value.date.year > LONG_MAX / 366) ||
(y->value.date.year < LONG_MIN / 366)) {
/* Possible overflow when converting to days. */
return -2;
}
if (x->value.date.tz_flag) { if (x->value.date.tz_flag) {
if (!y->value.date.tz_flag) { if (!y->value.date.tz_flag) {
@ -5069,7 +5181,7 @@ xmlSchemaGetFacetValueAsULong(xmlSchemaFacetPtr facet)
/* /*
* TODO: Check if this is a decimal. * TODO: Check if this is a decimal.
*/ */
if (facet == NULL) if (facet == NULL || facet->val == NULL)
return 0; return 0;
return ((unsigned long) facet->val->value.decimal.lo); return ((unsigned long) facet->val->value.decimal.lo);
} }
@ -6003,13 +6115,13 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
* recoverable timezone and not "Z". * recoverable timezone and not "Z".
*/ */
snprintf(buf, 30, snprintf(buf, 30,
"%04ld:%02u:%02uZ", "%04ld-%02u-%02uZ",
norm->value.date.year, norm->value.date.mon, norm->value.date.year, norm->value.date.mon,
norm->value.date.day); norm->value.date.day);
xmlSchemaFreeValue(norm); xmlSchemaFreeValue(norm);
} else { } else {
snprintf(buf, 30, snprintf(buf, 30,
"%04ld:%02u:%02u", "%04ld-%02u-%02u",
val->value.date.year, val->value.date.mon, val->value.date.year, val->value.date.mon,
val->value.date.day); val->value.date.day);
} }
@ -6030,14 +6142,14 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
* TODO: Check if "%.14g" is portable. * TODO: Check if "%.14g" is portable.
*/ */
snprintf(buf, 50, snprintf(buf, 50,
"%04ld:%02u:%02uT%02u:%02u:%02.14gZ", "%04ld-%02u-%02uT%02u:%02u:%02.14gZ",
norm->value.date.year, norm->value.date.mon, norm->value.date.year, norm->value.date.mon,
norm->value.date.day, norm->value.date.hour, norm->value.date.day, norm->value.date.hour,
norm->value.date.min, norm->value.date.sec); norm->value.date.min, norm->value.date.sec);
xmlSchemaFreeValue(norm); xmlSchemaFreeValue(norm);
} else { } else {
snprintf(buf, 50, snprintf(buf, 50,
"%04ld:%02u:%02uT%02u:%02u:%02.14g", "%04ld-%02u-%02uT%02u:%02u:%02.14g",
val->value.date.year, val->value.date.mon, val->value.date.year, val->value.date.mon,
val->value.date.day, val->value.date.hour, val->value.date.day, val->value.date.hour,
val->value.date.min, val->value.date.sec); val->value.date.min, val->value.date.sec);

View file

@ -130,16 +130,18 @@ xmlCharStrdup(const char *cur) {
int int
xmlStrcmp(const xmlChar *str1, const xmlChar *str2) { xmlStrcmp(const xmlChar *str1, const xmlChar *str2) {
register int tmp;
if (str1 == str2) return(0); if (str1 == str2) return(0);
if (str1 == NULL) return(-1); if (str1 == NULL) return(-1);
if (str2 == NULL) return(1); if (str2 == NULL) return(1);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return(strcmp((const char *)str1, (const char *)str2));
#else
do { do {
tmp = *str1++ - *str2; int tmp = *str1++ - *str2;
if (tmp != 0) return(tmp); if (tmp != 0) return(tmp);
} while (*str2++ != 0); } while (*str2++ != 0);
return 0; return 0;
#endif
} }
/** /**
@ -158,10 +160,14 @@ xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
if (str1 == str2) return(1); if (str1 == str2) return(1);
if (str1 == NULL) return(0); if (str1 == NULL) return(0);
if (str2 == NULL) return(0); if (str2 == NULL) return(0);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return(strcmp((const char *)str1, (const char *)str2) == 0);
#else
do { do {
if (*str1++ != *str2) return(0); if (*str1++ != *str2) return(0);
} while (*str2++); } while (*str2++);
return(1); return(1);
#endif
} }
/** /**
@ -204,18 +210,15 @@ xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) {
int int
xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len) { xmlStrncmp(const xmlChar *str1, const xmlChar *str2, int len) {
register int tmp;
if (len <= 0) return(0); if (len <= 0) return(0);
if (str1 == str2) return(0); if (str1 == str2) return(0);
if (str1 == NULL) return(-1); if (str1 == NULL) return(-1);
if (str2 == NULL) return(1); if (str2 == NULL) return(1);
#ifdef __GNUC__ #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
tmp = strncmp((const char *)str1, (const char *)str2, len); return(strncmp((const char *)str1, (const char *)str2, len));
return tmp;
#else #else
do { do {
tmp = *str1++ - *str2; int tmp = *str1++ - *str2;
if (tmp != 0 || --len == 0) return(tmp); if (tmp != 0 || --len == 0) return(tmp);
} while (*str2++ != 0); } while (*str2++ != 0);
return 0; return 0;

View file

@ -135,6 +135,17 @@
*/ */
#define XPATH_MAX_NODESET_LENGTH 10000000 #define XPATH_MAX_NODESET_LENGTH 10000000
/*
* XPATH_MAX_RECRUSION_DEPTH:
* Maximum amount of nested functions calls when parsing or evaluating
* expressions
*/
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#define XPATH_MAX_RECURSION_DEPTH 500
#else
#define XPATH_MAX_RECURSION_DEPTH 5000
#endif
/* /*
* TODO: * TODO:
* There are a few spots where some tests are done which depend upon ascii * There are a few spots where some tests are done which depend upon ascii
@ -477,14 +488,6 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
* * * *
************************************************************************/ ************************************************************************/
#ifndef INFINITY
#define INFINITY (DBL_MAX * DBL_MAX)
#endif
#ifndef NAN
#define NAN (INFINITY / INFINITY)
#endif
double xmlXPathNAN; double xmlXPathNAN;
double xmlXPathPINF; double xmlXPathPINF;
double xmlXPathNINF; double xmlXPathNINF;
@ -494,11 +497,14 @@ double xmlXPathNINF;
* *
* Initialize the XPath environment * Initialize the XPath environment
*/ */
ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
void void
xmlXPathInit(void) { xmlXPathInit(void) {
xmlXPathNAN = NAN; /* MSVC doesn't allow division by zero in constant expressions. */
xmlXPathPINF = INFINITY; double zero = 0.0;
xmlXPathNINF = -INFINITY; xmlXPathNAN = 0.0 / zero;
xmlXPathPINF = 1.0 / zero;
xmlXPathNINF = -xmlXPathPINF;
} }
/** /**
@ -527,9 +533,9 @@ xmlXPathIsInf(double val) {
#ifdef isinf #ifdef isinf
return isinf(val) ? (val > 0 ? 1 : -1) : 0; return isinf(val) ? (val > 0 ? 1 : -1) : 0;
#else #else
if (val >= INFINITY) if (val >= xmlXPathPINF)
return 1; return 1;
if (val <= -INFINITY) if (val <= -xmlXPathPINF)
return -1; return -1;
return 0; return 0;
#endif #endif
@ -619,7 +625,7 @@ static const char *xmlXPathErrorMessages[] = {
/** /**
* xmlXPathErrMemory: * xmlXPathErrMemory:
* @ctxt: an XPath context * @ctxt: an XPath context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -662,7 +668,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
/** /**
* xmlXPathPErrMemory: * xmlXPathPErrMemory:
* @ctxt: an XPath parser context * @ctxt: an XPath parser context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -1746,7 +1752,6 @@ static int xmlXPathDebugObjMaxUsers = 0;
static int xmlXPathDebugObjMaxXSLTTree = 0; static int xmlXPathDebugObjMaxXSLTTree = 0;
static int xmlXPathDebugObjMaxAll = 0; static int xmlXPathDebugObjMaxAll = 0;
/* REVISIT TODO: Make this static when committing */
static void static void
xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt) xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
{ {
@ -2061,7 +2066,6 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
xmlXPathDebugObjCounterAll--; xmlXPathDebugObjCounterAll--;
} }
/* REVISIT TODO: Make this static when committing */
static void static void
xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt) xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
{ {
@ -5864,10 +5868,10 @@ xmlXPathCastNodeToNumber (xmlNodePtr node) {
double ret; double ret;
if (node == NULL) if (node == NULL)
return(NAN); return(xmlXPathNAN);
strval = xmlXPathCastNodeToString(node); strval = xmlXPathCastNodeToString(node);
if (strval == NULL) if (strval == NULL)
return(NAN); return(xmlXPathNAN);
ret = xmlXPathCastStringToNumber(strval); ret = xmlXPathCastStringToNumber(strval);
xmlFree(strval); xmlFree(strval);
@ -5888,7 +5892,7 @@ xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns) {
double ret; double ret;
if (ns == NULL) if (ns == NULL)
return(NAN); return(xmlXPathNAN);
str = xmlXPathCastNodeSetToString(ns); str = xmlXPathCastNodeSetToString(ns);
ret = xmlXPathCastStringToNumber(str); ret = xmlXPathCastStringToNumber(str);
xmlFree(str); xmlFree(str);
@ -5908,13 +5912,13 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
double ret = 0.0; double ret = 0.0;
if (val == NULL) if (val == NULL)
return(NAN); return(xmlXPathNAN);
switch (val->type) { switch (val->type) {
case XPATH_UNDEFINED: case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR #ifdef DEBUG_EXPR
xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n"); xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
#endif #endif
ret = NAN; ret = xmlXPathNAN;
break; break;
case XPATH_NODESET: case XPATH_NODESET:
case XPATH_XSLT_TREE: case XPATH_XSLT_TREE:
@ -5934,7 +5938,7 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
TODO; TODO;
ret = NAN; ret = xmlXPathNAN;
break; break;
} }
return(ret); return(ret);
@ -6120,9 +6124,6 @@ xmlXPathNewContext(xmlDocPtr doc) {
ret->contextSize = -1; ret->contextSize = -1;
ret->proximityPosition = -1; ret->proximityPosition = -1;
ret->maxDepth = INT_MAX;
ret->maxParserDepth = INT_MAX;
#ifdef XP_DEFAULT_CACHE_ON #ifdef XP_DEFAULT_CACHE_ON
if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) { if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) {
xmlXPathFreeContext(ret); xmlXPathFreeContext(ret);
@ -7564,7 +7565,7 @@ xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
CHECK_TYPE(XPATH_NUMBER); CHECK_TYPE(XPATH_NUMBER);
arg1 = ctxt->value->floatval; arg1 = ctxt->value->floatval;
if (arg2 == 0) if (arg2 == 0)
ctxt->value->floatval = NAN; ctxt->value->floatval = xmlXPathNAN;
else { else {
ctxt->value->floatval = fmod(arg1, arg2); ctxt->value->floatval = fmod(arg1, arg2);
} }
@ -9994,7 +9995,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
if (cur == NULL) return(0); if (cur == NULL) return(0);
while (IS_BLANK_CH(*cur)) cur++; while (IS_BLANK_CH(*cur)) cur++;
if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) { if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
return(NAN); return(xmlXPathNAN);
} }
if (*cur == '-') { if (*cur == '-') {
isneg = 1; isneg = 1;
@ -10030,7 +10031,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
cur++; cur++;
if (((*cur < '0') || (*cur > '9')) && (!ok)) { if (((*cur < '0') || (*cur > '9')) && (!ok)) {
return(NAN); return(xmlXPathNAN);
} }
while (*cur == '0') { while (*cur == '0') {
frac = frac + 1; frac = frac + 1;
@ -10063,7 +10064,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
} }
} }
while (IS_BLANK_CH(*cur)) cur++; while (IS_BLANK_CH(*cur)) cur++;
if (*cur != 0) return(NAN); if (*cur != 0) return(xmlXPathNAN);
if (isneg) ret = -ret; if (isneg) ret = -ret;
if (is_exponent_negative) exponent = -exponent; if (is_exponent_negative) exponent = -exponent;
ret *= pow(10.0, (double)exponent); ret *= pow(10.0, (double)exponent);
@ -10088,6 +10089,7 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
int ok = 0; int ok = 0;
int exponent = 0; int exponent = 0;
int is_exponent_negative = 0; int is_exponent_negative = 0;
xmlXPathObjectPtr num;
#ifdef __GNUC__ #ifdef __GNUC__
unsigned long tmp = 0; unsigned long tmp = 0;
double temp; double temp;
@ -10160,8 +10162,13 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
exponent = -exponent; exponent = -exponent;
ret *= pow(10.0, (double) exponent); ret *= pow(10.0, (double) exponent);
} }
PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0, num = xmlXPathCacheNewFloat(ctxt->context, ret);
xmlXPathCacheNewFloat(ctxt->context, ret), NULL); if (num == NULL) {
ctxt->error = XPATH_MEMORY_ERROR;
} else if (PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0, num,
NULL) == -1) {
xmlXPathReleaseObject(ctxt->context, num);
}
} }
/** /**
@ -10223,6 +10230,7 @@ static void
xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) { xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
const xmlChar *q; const xmlChar *q;
xmlChar *ret = NULL; xmlChar *ret = NULL;
xmlXPathObjectPtr lit;
if (CUR == '"') { if (CUR == '"') {
NEXT; NEXT;
@ -10250,8 +10258,13 @@ xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
XP_ERROR(XPATH_START_LITERAL_ERROR); XP_ERROR(XPATH_START_LITERAL_ERROR);
} }
if (ret == NULL) return; if (ret == NULL) return;
PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_STRING, 0, 0, lit = xmlXPathCacheNewString(ctxt->context, ret);
xmlXPathCacheNewString(ctxt->context, ret), NULL); if (lit == NULL) {
ctxt->error = XPATH_MEMORY_ERROR;
} else if (PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_STRING, 0, 0, lit,
NULL) == -1) {
xmlXPathReleaseObject(ctxt->context, lit);
}
xmlFree(ret); xmlFree(ret);
} }
@ -10288,8 +10301,10 @@ xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
XP_ERROR(XPATH_VARIABLE_REF_ERROR); XP_ERROR(XPATH_VARIABLE_REF_ERROR);
} }
ctxt->comp->last = -1; ctxt->comp->last = -1;
PUSH_LONG_EXPR(XPATH_OP_VARIABLE, 0, 0, 0, if (PUSH_LONG_EXPR(XPATH_OP_VARIABLE, 0, 0, 0, name, prefix) == -1) {
name, prefix); xmlFree(prefix);
xmlFree(name);
}
SKIP_BLANKS; SKIP_BLANKS;
if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) { if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) {
XP_ERROR(XPATH_FORBID_VARIABLE_ERROR); XP_ERROR(XPATH_FORBID_VARIABLE_ERROR);
@ -10396,8 +10411,10 @@ xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
SKIP_BLANKS; SKIP_BLANKS;
} }
} }
PUSH_LONG_EXPR(XPATH_OP_FUNCTION, nbargs, 0, 0, if (PUSH_LONG_EXPR(XPATH_OP_FUNCTION, nbargs, 0, 0, name, prefix) == -1) {
name, prefix); xmlFree(prefix);
xmlFree(name);
}
NEXT; NEXT;
SKIP_BLANKS; SKIP_BLANKS;
} }
@ -10934,9 +10951,13 @@ xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
xmlXPathContextPtr xpctxt = ctxt->context; xmlXPathContextPtr xpctxt = ctxt->context;
if (xpctxt != NULL) { if (xpctxt != NULL) {
if (xpctxt->depth >= xpctxt->maxParserDepth) if (xpctxt->depth >= XPATH_MAX_RECURSION_DEPTH)
XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED); XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED);
xpctxt->depth += 1; /*
* Parsing a single '(' pushes about 10 functions on the call stack
* before recursing!
*/
xpctxt->depth += 10;
} }
xmlXPathCompAndExpr(ctxt); xmlXPathCompAndExpr(ctxt);
@ -11038,7 +11059,7 @@ xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) {
*/ */
static xmlChar * static xmlChar *
xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
xmlXPathTypeVal *type, const xmlChar **prefix, xmlXPathTypeVal *type, xmlChar **prefix,
xmlChar *name) { xmlChar *name) {
int blanks; int blanks;
@ -11269,7 +11290,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
SKIP_BLANKS; SKIP_BLANKS;
} else { } else {
xmlChar *name = NULL; xmlChar *name = NULL;
const xmlChar *prefix = NULL; xmlChar *prefix = NULL;
xmlXPathTestVal test = (xmlXPathTestVal) 0; xmlXPathTestVal test = (xmlXPathTestVal) 0;
xmlXPathAxisVal axis = (xmlXPathAxisVal) 0; xmlXPathAxisVal axis = (xmlXPathAxisVal) 0;
xmlXPathTypeVal type = (xmlXPathTypeVal) 0; xmlXPathTypeVal type = (xmlXPathTypeVal) 0;
@ -11379,9 +11400,11 @@ eval_predicates:
PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0); PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0);
} else } else
#endif #endif
PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis, if (PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis,
test, type, (void *)prefix, (void *)name); test, type, (void *)prefix, (void *)name) == -1) {
xmlFree(prefix);
xmlFree(name);
}
} }
#ifdef DEBUG_STEP #ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext, "Step : "); xmlGenericError(xmlGenericErrorContext, "Step : ");
@ -11649,11 +11672,11 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1); res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1);
if (ctxt->error != XPATH_EXPRESSION_OK) if (ctxt->error != XPATH_EXPRESSION_OK)
goto exit; break;
if (res < 0) { if (res < 0) {
/* Shouldn't happen */ /* Shouldn't happen */
xmlXPathErr(ctxt, XPATH_EXPR_ERROR); xmlXPathErr(ctxt, XPATH_EXPR_ERROR);
goto exit; break;
} }
if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) { if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) {
@ -11672,15 +11695,7 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
if (res != 0) { if (res != 0) {
if (pos == maxPos) { if (pos == maxPos) {
/* Clear remaining nodes and exit loop. */ i += 1;
if (hasNsNodes) {
for (i++; i < set->nodeNr; i++) {
node = set->nodeTab[i];
if ((node != NULL) &&
(node->type == XML_NAMESPACE_DECL))
xmlXPathNodeSetFreeNs((xmlNsPtr) node);
}
}
break; break;
} }
@ -11688,6 +11703,15 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
} }
} }
/* Free remaining nodes. */
if (hasNsNodes) {
for (; i < set->nodeNr; i++) {
xmlNodePtr node = set->nodeTab[i];
if ((node != NULL) && (node->type == XML_NAMESPACE_DECL))
xmlXPathNodeSetFreeNs((xmlNsPtr) node);
}
}
set->nodeNr = j; set->nodeNr = j;
/* If too many elements were removed, shrink table to preserve memory. */ /* If too many elements were removed, shrink table to preserve memory. */
@ -11708,7 +11732,6 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
} }
} }
exit:
xpctxt->node = oldnode; xpctxt->node = oldnode;
xpctxt->doc = olddoc; xpctxt->doc = olddoc;
xpctxt->contextSize = oldcs; xpctxt->contextSize = oldcs;
@ -11773,11 +11796,11 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1); res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1);
if (ctxt->error != XPATH_EXPRESSION_OK) if (ctxt->error != XPATH_EXPRESSION_OK)
goto exit; break;
if (res < 0) { if (res < 0) {
/* Shouldn't happen */ /* Shouldn't happen */
xmlXPathErr(ctxt, XPATH_EXPR_ERROR); xmlXPathErr(ctxt, XPATH_EXPR_ERROR);
goto exit; break;
} }
if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) { if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) {
@ -11795,10 +11818,7 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
if (res != 0) { if (res != 0) {
if (pos == maxPos) { if (pos == maxPos) {
/* Clear remaining nodes and exit loop. */ i += 1;
for (i++; i < locset->locNr; i++) {
xmlXPathFreeObject(locset->locTab[i]);
}
break; break;
} }
@ -11806,6 +11826,10 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
} }
} }
/* Free remaining nodes. */
for (; i < locset->locNr; i++)
xmlXPathFreeObject(locset->locTab[i]);
locset->locNr = j; locset->locNr = j;
/* If too many elements were removed, shrink table to preserve memory. */ /* If too many elements were removed, shrink table to preserve memory. */
@ -11826,7 +11850,6 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
} }
} }
exit:
xpctxt->node = oldnode; xpctxt->node = oldnode;
xpctxt->doc = olddoc; xpctxt->doc = olddoc;
xpctxt->contextSize = oldcs; xpctxt->contextSize = oldcs;
@ -11864,7 +11887,7 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
"xmlXPathCompOpEvalPredicate: Expected a predicate\n"); "xmlXPathCompOpEvalPredicate: Expected a predicate\n");
XP_ERROR(XPATH_INVALID_OPERAND); XP_ERROR(XPATH_INVALID_OPERAND);
} }
if (ctxt->context->depth >= ctxt->context->maxDepth) if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH)
XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED); XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED);
ctxt->context->depth += 1; ctxt->context->depth += 1;
xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set, xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set,
@ -12580,7 +12603,7 @@ xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
CHECK_ERROR0; CHECK_ERROR0;
if (OP_LIMIT_EXCEEDED(ctxt, 1)) if (OP_LIMIT_EXCEEDED(ctxt, 1))
return(0); return(0);
if (ctxt->context->depth >= ctxt->context->maxDepth) if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH)
XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED); XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
ctxt->context->depth += 1; ctxt->context->depth += 1;
comp = ctxt->comp; comp = ctxt->comp;
@ -12721,7 +12744,7 @@ xmlXPathCompOpEvalLast(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op,
CHECK_ERROR0; CHECK_ERROR0;
if (OP_LIMIT_EXCEEDED(ctxt, 1)) if (OP_LIMIT_EXCEEDED(ctxt, 1))
return(0); return(0);
if (ctxt->context->depth >= ctxt->context->maxDepth) if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH)
XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED); XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
ctxt->context->depth += 1; ctxt->context->depth += 1;
comp = ctxt->comp; comp = ctxt->comp;
@ -12939,7 +12962,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
CHECK_ERROR0; CHECK_ERROR0;
if (OP_LIMIT_EXCEEDED(ctxt, 1)) if (OP_LIMIT_EXCEEDED(ctxt, 1))
return(0); return(0);
if (ctxt->context->depth >= ctxt->context->maxDepth) if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH)
XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED); XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
ctxt->context->depth += 1; ctxt->context->depth += 1;
comp = ctxt->comp; comp = ctxt->comp;
@ -13815,7 +13838,8 @@ scan_children:
do { do {
cur = cur->parent; cur = cur->parent;
depth--; depth--;
if ((cur == NULL) || (cur == limit)) if ((cur == NULL) || (cur == limit) ||
(cur->type == XML_DOCUMENT_NODE))
goto done; goto done;
if (cur->type == XML_ELEMENT_NODE) { if (cur->type == XML_ELEMENT_NODE) {
ret = xmlStreamPop(patstream); ret = xmlStreamPop(patstream);
@ -14086,8 +14110,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
} }
} }
stream = xmlPatterncompile(str, dict, XML_PATTERN_XPATH, stream = xmlPatterncompile(str, dict, XML_PATTERN_XPATH, namespaces);
&namespaces[0]);
if (namespaces != NULL) { if (namespaces != NULL) {
xmlFree((xmlChar **)namespaces); xmlFree((xmlChar **)namespaces);
} }
@ -14173,7 +14196,7 @@ xmlXPathOptimizeExpression(xmlXPathParserContextPtr pctxt,
/* Recurse */ /* Recurse */
ctxt = pctxt->context; ctxt = pctxt->context;
if (ctxt != NULL) { if (ctxt != NULL) {
if (ctxt->depth >= ctxt->maxDepth) if (ctxt->depth >= XPATH_MAX_RECURSION_DEPTH)
return; return;
ctxt->depth += 1; ctxt->depth += 1;
} }
@ -14206,7 +14229,7 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
return(comp); return(comp);
#endif #endif
xmlXPathInit(); xmlInitParser();
pctxt = xmlXPathNewParserContext(str, ctxt); pctxt = xmlXPathNewParserContext(str, ctxt);
if (pctxt == NULL) if (pctxt == NULL)
@ -14295,7 +14318,7 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
if (comp == NULL) if (comp == NULL)
return(-1); return(-1);
xmlXPathInit(); xmlInitParser();
#ifndef LIBXML_THREAD_ENABLED #ifndef LIBXML_THREAD_ENABLED
reentance++; reentance++;
@ -14440,7 +14463,7 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
CHECK_CTXT(ctx) CHECK_CTXT(ctx)
xmlXPathInit(); xmlInitParser();
ctxt = xmlXPathNewParserContext(str, ctx); ctxt = xmlXPathNewParserContext(str, ctx);
if (ctxt == NULL) if (ctxt == NULL)

View file

@ -70,7 +70,7 @@
/** /**
* xmlXPtrErrMemory: * xmlXPtrErrMemory:
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -86,7 +86,7 @@ xmlXPtrErrMemory(const char *extra)
/** /**
* xmlXPtrErr: * xmlXPtrErr:
* @ctxt: an XPTR evaluation context * @ctxt: an XPTR evaluation context
* @extra: extra informations * @extra: extra information
* *
* Handle a redefinition of attribute error * Handle a redefinition of attribute error
*/ */
@ -1005,7 +1005,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
/* /*
* To evaluate an xpointer scheme element (4.3) we need: * To evaluate an xpointer scheme element (4.3) we need:
* context initialized to the root * context initialized to the root
* context position initalized to 1 * context position initialized to 1
* context size initialized to 1 * context size initialized to 1
*/ */
ctxt->context->node = (xmlNodePtr)ctxt->context->doc; ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
@ -1352,7 +1352,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPathObjectPtr init = NULL; xmlXPathObjectPtr init = NULL;
int stack = 0; int stack = 0;
xmlXPathInit(); xmlInitParser();
if ((ctx == NULL) || (str == NULL)) if ((ctx == NULL) || (str == NULL))
return(NULL); return(NULL);
@ -1536,7 +1536,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
case XML_ELEMENT_DECL: case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL: case XML_ATTRIBUTE_DECL:
case XML_ENTITY_NODE: case XML_ENTITY_NODE:
/* Do not copy DTD informations */ /* Do not copy DTD information */
break; break;
case XML_ENTITY_DECL: case XML_ENTITY_DECL:
TODO /* handle crossing entities -> stack needed */ TODO /* handle crossing entities -> stack needed */
@ -2200,7 +2200,6 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
XP_ERROR(XPATH_MEMORY_ERROR) XP_ERROR(XPATH_MEMORY_ERROR)
set = tmp; set = tmp;
} }
oldset = (xmlLocationSetPtr) set->user;
/* /*
* The loop is to compute the covering range for each item and add it * The loop is to compute the covering range for each item and add it
@ -2210,9 +2209,12 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathFreeObject(set); xmlXPathFreeObject(set);
XP_ERROR(XPATH_MEMORY_ERROR); XP_ERROR(XPATH_MEMORY_ERROR);
} }
for (i = 0;i < oldset->locNr;i++) { oldset = (xmlLocationSetPtr) set->user;
xmlXPtrLocationSetAdd(newset, if (oldset != NULL) {
xmlXPtrInsideRange(ctxt, oldset->locTab[i])); for (i = 0;i < oldset->locNr;i++) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrInsideRange(ctxt, oldset->locTab[i]));
}
} }
/* /*
@ -2706,10 +2708,10 @@ static void
xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i, startindex, endindex = 0, fendindex; int i, startindex, endindex = 0, fendindex;
xmlNodePtr start, end = 0, fend; xmlNodePtr start, end = 0, fend;
xmlXPathObjectPtr set; xmlXPathObjectPtr set = NULL;
xmlLocationSetPtr oldset; xmlLocationSetPtr oldset;
xmlLocationSetPtr newset; xmlLocationSetPtr newset = NULL;
xmlXPathObjectPtr string; xmlXPathObjectPtr string = NULL;
xmlXPathObjectPtr position = NULL; xmlXPathObjectPtr position = NULL;
xmlXPathObjectPtr number = NULL; xmlXPathObjectPtr number = NULL;
int found, pos = 0, num = 0; int found, pos = 0, num = 0;
@ -2721,29 +2723,39 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
XP_ERROR(XPATH_INVALID_ARITY); XP_ERROR(XPATH_INVALID_ARITY);
if (nargs >= 4) { if (nargs >= 4) {
CHECK_TYPE(XPATH_NUMBER); if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
number = valuePop(ctxt); number = valuePop(ctxt);
if (number != NULL) if (number != NULL)
num = (int) number->floatval; num = (int) number->floatval;
} }
if (nargs >= 3) { if (nargs >= 3) {
CHECK_TYPE(XPATH_NUMBER); if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
position = valuePop(ctxt); position = valuePop(ctxt);
if (position != NULL) if (position != NULL)
pos = (int) position->floatval; pos = (int) position->floatval;
} }
CHECK_TYPE(XPATH_STRING); if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
string = valuePop(ctxt); string = valuePop(ctxt);
if ((ctxt->value == NULL) || if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_LOCATIONSET) && ((ctxt->value->type != XPATH_LOCATIONSET) &&
(ctxt->value->type != XPATH_NODESET))) (ctxt->value->type != XPATH_NODESET))) {
XP_ERROR(XPATH_INVALID_TYPE) xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
set = valuePop(ctxt); set = valuePop(ctxt);
newset = xmlXPtrLocationSetCreate(NULL); newset = xmlXPtrLocationSetCreate(NULL);
if (newset == NULL) { if (newset == NULL) {
xmlXPathFreeObject(set); xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
XP_ERROR(XPATH_MEMORY_ERROR); goto error;
} }
if (set->nodesetval == NULL) { if (set->nodesetval == NULL) {
goto error; goto error;
@ -2756,8 +2768,10 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/ */
tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval); tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
xmlXPathFreeObject(set); xmlXPathFreeObject(set);
if (tmp == NULL) if (tmp == NULL) {
XP_ERROR(XPATH_MEMORY_ERROR) xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
goto error;
}
set = tmp; set = tmp;
} }
oldset = (xmlLocationSetPtr) set->user; oldset = (xmlLocationSetPtr) set->user;
@ -2830,7 +2844,8 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* Save the new value and cleanup * Save the new value and cleanup
*/ */
error: error:
valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); if (newset != NULL)
valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
xmlXPathFreeObject(set); xmlXPathFreeObject(set);
xmlXPathFreeObject(string); xmlXPathFreeObject(string);
if (position) xmlXPathFreeObject(position); if (position) xmlXPathFreeObject(position);