ReactOS 0.4.16-dev-2207-geb15453
parserInternals.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#include <libxml/chvalid.h>
#include <libxml/SAX2.h>
Include dependency graph for parserInternals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XML_MAX_TEXT_LENGTH   10000000
 
#define XML_MAX_HUGE_LENGTH   1000000000
 
#define XML_MAX_NAME_LENGTH   50000
 
#define XML_MAX_DICTIONARY_LIMIT   10000000
 
#define XML_MAX_LOOKUP_LIMIT   10000000
 
#define XML_MAX_NAMELEN   100
 
#define INPUT_CHUNK   250
 
#define IS_BYTE_CHAR(c)   xmlIsChar_ch(c)
 
#define IS_CHAR(c)   xmlIsCharQ(c)
 
#define IS_CHAR_CH(c)   xmlIsChar_ch(c)
 
#define IS_BLANK(c)   xmlIsBlankQ(c)
 
#define IS_BLANK_CH(c)   xmlIsBlank_ch(c)
 
#define IS_BASECHAR(c)   xmlIsBaseCharQ(c)
 
#define IS_DIGIT(c)   xmlIsDigitQ(c)
 
#define IS_DIGIT_CH(c)   xmlIsDigit_ch(c)
 
#define IS_COMBINING(c)   xmlIsCombiningQ(c)
 
#define IS_COMBINING_CH(c)   0
 
#define IS_EXTENDER(c)   xmlIsExtenderQ(c)
 
#define IS_EXTENDER_CH(c)   xmlIsExtender_ch(c)
 
#define IS_IDEOGRAPHIC(c)   xmlIsIdeographicQ(c)
 
#define IS_LETTER(c)   (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
 
#define IS_LETTER_CH(c)   xmlIsBaseChar_ch(c)
 
#define IS_ASCII_LETTER(c)
 
#define IS_ASCII_DIGIT(c)   ((0x30 <= (c)) && ((c) <= 0x39))
 
#define IS_PUBIDCHAR(c)   xmlIsPubidCharQ(c)
 
#define IS_PUBIDCHAR_CH(c)   xmlIsPubidChar_ch(c)
 
#define XML_SUBSTITUTE_NONE   0
 
#define XML_SUBSTITUTE_REF   1
 
#define XML_SUBSTITUTE_PEREF   2
 
#define XML_SUBSTITUTE_BOTH   3
 

Functions

XMLPUBFUN int xmlIsLetter (int c)
 
XMLPUBFUN xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename)
 
XMLPUBFUN xmlParserCtxtPtr xmlCreateURLParserCtxt (const char *filename, int options)
 
XMLPUBFUN xmlParserCtxtPtr xmlCreateMemoryParserCtxt (const char *buffer, int size)
 
XMLPUBFUN xmlParserCtxtPtr xmlCreateEntityParserCtxt (const xmlChar *URL, const xmlChar *ID, const xmlChar *base)
 
XMLPUBFUN int xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
 
XMLPUBFUN int xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 
XML_DEPRECATED XMLPUBFUN int xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
 
XMLPUBFUN xmlParserInputPtr xmlNewStringInputStream (xmlParserCtxtPtr ctxt, const xmlChar *buffer)
 
XML_DEPRECATED XMLPUBFUN xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
 
XMLPUBFUN int xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
 
XMLPUBFUN xmlChar xmlPopInput (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void xmlFreeInputStream (xmlParserInputPtr input)
 
XMLPUBFUN xmlParserInputPtr xmlNewInputFromFile (xmlParserCtxtPtr ctxt, const char *filename)
 
XMLPUBFUN xmlParserInputPtr xmlNewInputStream (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlCharxmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
 
XML_DEPRECATED XMLPUBFUN const xmlCharxmlParseName (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseNmtoken (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseAttValue (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseSystemLiteral (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParsePubidLiteral (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
 
XML_DEPRECATED XMLPUBFUN void xmlParseComment (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN const xmlCharxmlParsePITarget (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParsePI (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseNotationDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseEntityDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value)
 
XML_DEPRECATED XMLPUBFUN xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XML_DEPRECATED XMLPUBFUN int xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XML_DEPRECATED XMLPUBFUN void xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlElementContentPtr xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XML_DEPRECATED XMLPUBFUN xmlElementContentPtr xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XML_DEPRECATED XMLPUBFUN int xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
 
XML_DEPRECATED XMLPUBFUN int xmlParseElementDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlParseCharRef (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlEntityPtr xmlParseEntityRef (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseReference (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParsePEReference (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void xmlParseContent (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseElement (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseVersionNum (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseVersionInfo (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlParseEncName (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN const xmlCharxmlParseEncodingDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlParseSDDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseXMLDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseTextDecl (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParseMisc (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XML_DEPRECATED XMLPUBFUN xmlCharxmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XML_DEPRECATED XMLPUBFUN int nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value)
 
XML_DEPRECATED XMLPUBFUN xmlNodePtr nodePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
 
XMLPUBFUN xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN const xmlCharnamePop (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int namePush (xmlParserCtxtPtr ctxt, const xmlChar *value)
 
XML_DEPRECATED XMLPUBFUN int xmlSkipBlankChars (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlStringCurrentChar (xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len)
 
XML_DEPRECATED XMLPUBFUN void xmlParserHandlePEReference (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN int xmlCheckLanguageID (const xmlChar *lang)
 
XML_DEPRECATED XMLPUBFUN int xmlCurrentChar (xmlParserCtxtPtr ctxt, int *len)
 
XMLPUBFUN int xmlCopyCharMultiByte (xmlChar *out, int val)
 
XMLPUBFUN int xmlCopyChar (int len, xmlChar *out, int val)
 
XML_DEPRECATED XMLPUBFUN void xmlNextChar (xmlParserCtxtPtr ctxt)
 
XML_DEPRECATED XMLPUBFUN void xmlParserInputShrink (xmlParserInputPtr in)
 

Variables

XMLPUBVAR unsigned int xmlParserMaxDepth
 
XMLPUBVAR const xmlChar xmlStringText []
 
XMLPUBVAR const xmlChar xmlStringTextNoenc []
 
XMLPUBVAR const xmlChar xmlStringComment []
 

Macro Definition Documentation

◆ INPUT_CHUNK

#define INPUT_CHUNK   250

INPUT_CHUNK:

The parser tries to always have that amount of input ready. One of the point is providing context when reporting errors.

Definition at line 97 of file parserInternals.h.

◆ IS_ASCII_DIGIT

#define IS_ASCII_DIGIT (   c)    ((0x30 <= (c)) && ((c) <= 0x39))

IS_ASCII_DIGIT: : an xmlChar value

Macro to check [0-9]

Definition at line 268 of file parserInternals.h.

◆ IS_ASCII_LETTER

#define IS_ASCII_LETTER (   c)
Value:
(((0x41 <= (c)) && ((c) <= 0x5a)) || \
((0x61 <= (c)) && ((c) <= 0x7a)))
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

IS_ASCII_LETTER: : an xmlChar value

Macro to check [a-zA-Z]

Definition at line 258 of file parserInternals.h.

◆ IS_BASECHAR

#define IS_BASECHAR (   c)    xmlIsBaseCharQ(c)

IS_BASECHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[85] BaseChar ::= ... long list see REC ...

Definition at line 161 of file parserInternals.h.

◆ IS_BLANK

#define IS_BLANK (   c)    xmlIsBlankQ(c)

IS_BLANK: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[3] S ::= (#x20 | x9 | #xD | #xA)+

Definition at line 143 of file parserInternals.h.

◆ IS_BLANK_CH

#define IS_BLANK_CH (   c)    xmlIsBlank_ch(c)

IS_BLANK_CH: : an xmlChar value (normally unsigned char)

Behaviour same as IS_BLANK

Definition at line 151 of file parserInternals.h.

◆ IS_BYTE_CHAR

#define IS_BYTE_CHAR (   c)    xmlIsChar_ch(c)

IS_BYTE_CHAR: : an byte value (int)

Macro to check the following production in the XML spec:

[2] Char ::= x9 | #xA | #xD | [#x20...] any byte character in the accepted range

Definition at line 113 of file parserInternals.h.

◆ IS_CHAR

#define IS_CHAR (   c)    xmlIsCharQ(c)

IS_CHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[2] Char ::= x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.

Definition at line 125 of file parserInternals.h.

◆ IS_CHAR_CH

#define IS_CHAR_CH (   c)    xmlIsChar_ch(c)

IS_CHAR_CH: : an xmlChar (usually an unsigned char)

Behaves like IS_CHAR on single-byte value

Definition at line 133 of file parserInternals.h.

◆ IS_COMBINING

#define IS_COMBINING (   c)    xmlIsCombiningQ(c)

IS_COMBINING: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[87] CombiningChar ::= ... long list see REC ...

Definition at line 189 of file parserInternals.h.

◆ IS_COMBINING_CH

#define IS_COMBINING_CH (   c)    0

IS_COMBINING_CH: : an xmlChar (usually an unsigned char)

Always false (all combining chars > 0xff)

Definition at line 197 of file parserInternals.h.

◆ IS_DIGIT

#define IS_DIGIT (   c)    xmlIsDigitQ(c)

IS_DIGIT: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[88] Digit ::= ... long list see REC ...

Definition at line 171 of file parserInternals.h.

◆ IS_DIGIT_CH

#define IS_DIGIT_CH (   c)    xmlIsDigit_ch(c)

IS_DIGIT_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_DIGIT but with a single byte argument

Definition at line 179 of file parserInternals.h.

◆ IS_EXTENDER

#define IS_EXTENDER (   c)    xmlIsExtenderQ(c)

IS_EXTENDER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]

Definition at line 210 of file parserInternals.h.

◆ IS_EXTENDER_CH

#define IS_EXTENDER_CH (   c)    xmlIsExtender_ch(c)

IS_EXTENDER_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_EXTENDER but with a single-byte argument

Definition at line 218 of file parserInternals.h.

◆ IS_IDEOGRAPHIC

#define IS_IDEOGRAPHIC (   c)    xmlIsIdeographicQ(c)

IS_IDEOGRAPHIC: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]

Definition at line 229 of file parserInternals.h.

◆ IS_LETTER

#define IS_LETTER (   c)    (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))

IS_LETTER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[84] Letter ::= BaseChar | Ideographic

Definition at line 240 of file parserInternals.h.

◆ IS_LETTER_CH

#define IS_LETTER_CH (   c)    xmlIsBaseChar_ch(c)

IS_LETTER_CH: : an xmlChar value (normally unsigned char)

Macro behaves like IS_LETTER, but only check base chars

Definition at line 249 of file parserInternals.h.

◆ IS_PUBIDCHAR

#define IS_PUBIDCHAR (   c)    xmlIsPubidCharQ(c)

IS_PUBIDCHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#$_%]

Definition at line 279 of file parserInternals.h.

◆ IS_PUBIDCHAR_CH

#define IS_PUBIDCHAR_CH (   c)    xmlIsPubidChar_ch(c)

IS_PUBIDCHAR_CH: : an xmlChar value (normally unsigned char)

Same as IS_PUBIDCHAR but for single-byte value

Definition at line 287 of file parserInternals.h.

◆ XML_MAX_DICTIONARY_LIMIT

#define XML_MAX_DICTIONARY_LIMIT   10000000

XML_MAX_DICTIONARY_LIMIT:

Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 71 of file parserInternals.h.

◆ XML_MAX_HUGE_LENGTH

#define XML_MAX_HUGE_LENGTH   1000000000

XML_MAX_HUGE_LENGTH:

Maximum size allowed when XML_PARSE_HUGE is set.

Definition at line 49 of file parserInternals.h.

◆ XML_MAX_LOOKUP_LIMIT

#define XML_MAX_LOOKUP_LIMIT   10000000

XML_MAX_LOOKUP_LIMIT:

Maximum size allowed by the parser for ahead lookup This is an upper boundary enforced by the parser to avoid bad behaviour on "unfriendly' content Introduced in 2.9.0

Definition at line 81 of file parserInternals.h.

◆ XML_MAX_NAME_LENGTH

#define XML_MAX_NAME_LENGTH   50000

XML_MAX_NAME_LENGTH:

Maximum size allowed for a markup identifier. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Note that with the use of parsing dictionaries overriding the limit may result in more runtime memory usage in face of "unfriendly' content Introduced in 2.9.0

Definition at line 61 of file parserInternals.h.

◆ XML_MAX_NAMELEN

#define XML_MAX_NAMELEN   100

XML_MAX_NAMELEN:

Identifiers can be longer, but this will be more costly at runtime.

Definition at line 89 of file parserInternals.h.

◆ XML_MAX_TEXT_LENGTH

#define XML_MAX_TEXT_LENGTH   10000000

XML_MAX_TEXT_LENGTH:

Maximum size allowed for a single text node when building a tree. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 42 of file parserInternals.h.

◆ XML_SUBSTITUTE_BOTH

#define XML_SUBSTITUTE_BOTH   3

XML_SUBSTITUTE_BOTH:

Both general and parameter entities need to be substituted.

Definition at line 533 of file parserInternals.h.

◆ XML_SUBSTITUTE_NONE

#define XML_SUBSTITUTE_NONE   0

XML_SUBSTITUTE_NONE:

If no entities need to be substituted.

Definition at line 515 of file parserInternals.h.

◆ XML_SUBSTITUTE_PEREF

#define XML_SUBSTITUTE_PEREF   2

XML_SUBSTITUTE_PEREF:

Whether parameter entities need to be substituted.

Definition at line 527 of file parserInternals.h.

◆ XML_SUBSTITUTE_REF

#define XML_SUBSTITUTE_REF   1

XML_SUBSTITUTE_REF:

Whether general entities need to be substituted.

Definition at line 521 of file parserInternals.h.

Function Documentation

◆ inputPop()

XMLPUBFUN xmlParserInputPtr inputPop ( xmlParserCtxtPtr  ctxt)

inputPop: @ctxt: an XML parser context

Pops the top parser input from the input stack

Returns the input just removed

Definition at line 1927 of file parser.c.

1928{
1929 xmlParserInputPtr ret;
1930
1931 if (ctxt == NULL)
1932 return(NULL);
1933 if (ctxt->inputNr <= 0)
1934 return (NULL);
1935 ctxt->inputNr--;
1936 if (ctxt->inputNr > 0)
1937 ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1938 else
1939 ctxt->input = NULL;
1940 ret = ctxt->inputTab[ctxt->inputNr];
1941 ctxt->inputTab[ctxt->inputNr] = NULL;
1942 return (ret);
1943}
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:146

Referenced by xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitSAXParserCtxt(), xmlLoadEntityContent(), xmlPopInput(), and xmlPushInput().

◆ inputPush()

XMLPUBFUN int inputPush ( xmlParserCtxtPtr  ctxt,
xmlParserInputPtr  value 
)

inputPush: @ctxt: an XML parser context @value: the parser input

Pushes a new parser input on top of the input stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1897 of file parser.c.

1898{
1899 if ((ctxt == NULL) || (value == NULL))
1900 return(-1);
1901 if (ctxt->inputNr >= ctxt->inputMax) {
1902 size_t newSize = ctxt->inputMax * 2;
1903 xmlParserInputPtr *tmp;
1904
1905 tmp = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab,
1906 newSize * sizeof(*tmp));
1907 if (tmp == NULL) {
1908 xmlErrMemory(ctxt, NULL);
1909 return (-1);
1910 }
1911 ctxt->inputTab = tmp;
1912 ctxt->inputMax = newSize;
1913 }
1914 ctxt->inputTab[ctxt->inputNr] = value;
1915 ctxt->input = value;
1916 return (ctxt->inputNr++);
1917}
xmlReallocFunc xmlRealloc
Definition: globals.c:214
XML_HIDDEN void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
Definition: pdh_main.c:96

Referenced by xmlCreateDocParserCtxt(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlCtxtResetPush(), xmlLoadEntityContent(), xmlPushInput(), xmlReadFd(), xmlReadIO(), xslt_doc_default_loader(), and xsltDocDefaultLoaderFunc().

◆ namePop()

XML_DEPRECATED XMLPUBFUN const xmlChar * namePop ( xmlParserCtxtPtr  ctxt)

namePop: @ctxt: an XML parser context

DEPRECATED: Internal function, do not use.

Pops the top element name from the name stack

Returns the name just removed

Definition at line 2143 of file parser.c.

2144{
2145 const xmlChar *ret;
2146
2147 if ((ctxt == NULL) || (ctxt->nameNr <= 0))
2148 return (NULL);
2149 ctxt->nameNr--;
2150 if (ctxt->nameNr > 0)
2151 ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
2152 else
2153 ctxt->name = NULL;
2154 ret = ctxt->nameTab[ctxt->nameNr];
2155 ctxt->nameTab[ctxt->nameNr] = NULL;
2156 return (ret);
2157}
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlParseElementEnd(), and xmlParseElementStart().

◆ namePush()

XML_DEPRECATED XMLPUBFUN int namePush ( xmlParserCtxtPtr  ctxt,
const xmlChar value 
)

namePush: @ctxt: an XML parser context @value: the element name

DEPRECATED: Internal function, do not use.

Pushes a new element name on top of the name stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 2109 of file parser.c.

2110{
2111 if (ctxt == NULL) return (-1);
2112
2113 if (ctxt->nameNr >= ctxt->nameMax) {
2114 const xmlChar * *tmp;
2115 tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
2116 ctxt->nameMax * 2 *
2117 sizeof(ctxt->nameTab[0]));
2118 if (tmp == NULL) {
2119 goto mem_error;
2120 }
2121 ctxt->nameTab = tmp;
2122 ctxt->nameMax *= 2;
2123 }
2124 ctxt->nameTab[ctxt->nameNr] = value;
2125 ctxt->name = value;
2126 return (ctxt->nameNr++);
2127mem_error:
2128 xmlErrMemory(ctxt, NULL);
2129 return (-1);
2130}

◆ nodePop()

XML_DEPRECATED XMLPUBFUN xmlNodePtr nodePop ( xmlParserCtxtPtr  ctxt)

nodePop: @ctxt: an XML parser context

DEPRECATED: Internal function, do not use.

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1996 of file parser.c.

1997{
1998 xmlNodePtr ret;
1999
2000 if (ctxt == NULL) return(NULL);
2001 if (ctxt->nodeNr <= 0)
2002 return (NULL);
2003 ctxt->nodeNr--;
2004 if (ctxt->nodeNr > 0)
2005 ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
2006 else
2007 ctxt->node = NULL;
2008 ret = ctxt->nodeTab[ctxt->nodeNr];
2009 ctxt->nodeTab[ctxt->nodeNr] = NULL;
2010 return (ret);
2011}

Referenced by xmlParseElementStart(), and xmlSAX2EndElementNs().

◆ nodePush()

XML_DEPRECATED XMLPUBFUN int nodePush ( xmlParserCtxtPtr  ctxt,
xmlNodePtr  value 
)

nodePush: @ctxt: an XML parser context @value: the element node

DEPRECATED: Internal function, do not use.

Pushes a new element node on top of the node stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1956 of file parser.c.

1957{
1958 if (ctxt == NULL) return(0);
1959 if (ctxt->nodeNr >= ctxt->nodeMax) {
1960 xmlNodePtr *tmp;
1961
1962 tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1963 ctxt->nodeMax * 2 *
1964 sizeof(ctxt->nodeTab[0]));
1965 if (tmp == NULL) {
1966 xmlErrMemory(ctxt, NULL);
1967 return (-1);
1968 }
1969 ctxt->nodeTab = tmp;
1970 ctxt->nodeMax *= 2;
1971 }
1972 if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1973 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1974 xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1975 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1977 xmlHaltParser(ctxt);
1978 return(-1);
1979 }
1980 ctxt->nodeTab[ctxt->nodeNr] = value;
1981 ctxt->node = value;
1982 return (ctxt->nodeNr++);
1983}
@ XML_PARSE_HUGE
Definition: parser.h:1251
XML_HIDDEN void XML_HIDDEN void xmlHaltParser(xmlParserCtxtPtr ctxt)
unsigned int xmlParserMaxDepth
Definition: parser.c:162
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseInNodeContext(), and xmlSAX2StartElementNs().

◆ xmlCheckLanguageID()

XML_DEPRECATED XMLPUBFUN int xmlCheckLanguageID ( const xmlChar lang)

xmlCheckLanguageID: @lang: pointer to the string value

DEPRECATED: Internal function, do not use.

Checks that the value conforms to the LanguageID production:

NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition.

[33] LanguageID ::= Langcode ('-' Subcode)* [34] Langcode ::= ISO639Code | IanaCode | UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+ [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+

The current REC reference the successors of RFC 1766, currently 5646

http://www.rfc-editor.org/rfc/rfc5646.txt langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag

extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved

script = 4ALPHA ; ISO 15924 code

region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code

variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum)

extension = singleton 1*("-" (2*8alphanum))

                                ; Single alphanumerics
                                ; "x" reserved for private use

singleton = DIGIT ; 0 - 9 / x41-57 ; A - W / x59-5A ; Y - Z / x61-77 ; a - w / x79-7A ; y - z

it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn't try to cope with extension or privateuse that could be added but that's not interoperable anyway

Returns 1 if correct 0 otherwise

Definition at line 1261 of file parser.c.

1262{
1263 const xmlChar *cur = lang, *nxt;
1264
1265 if (cur == NULL)
1266 return (0);
1267 if (((cur[0] == 'i') && (cur[1] == '-')) ||
1268 ((cur[0] == 'I') && (cur[1] == '-')) ||
1269 ((cur[0] == 'x') && (cur[1] == '-')) ||
1270 ((cur[0] == 'X') && (cur[1] == '-'))) {
1271 /*
1272 * Still allow IANA code and user code which were coming
1273 * from the previous version of the XML-1.0 specification
1274 * it's deprecated but we should not fail
1275 */
1276 cur += 2;
1277 while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1278 ((cur[0] >= 'a') && (cur[0] <= 'z')))
1279 cur++;
1280 return(cur[0] == 0);
1281 }
1282 nxt = cur;
1283 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1284 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1285 nxt++;
1286 if (nxt - cur >= 4) {
1287 /*
1288 * Reserved
1289 */
1290 if ((nxt - cur > 8) || (nxt[0] != 0))
1291 return(0);
1292 return(1);
1293 }
1294 if (nxt - cur < 2)
1295 return(0);
1296 /* we got an ISO 639 code */
1297 if (nxt[0] == 0)
1298 return(1);
1299 if (nxt[0] != '-')
1300 return(0);
1301
1302 nxt++;
1303 cur = nxt;
1304 /* now we can have extlang or script or region or variant */
1305 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1306 goto region_m49;
1307
1308 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1309 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1310 nxt++;
1311 if (nxt - cur == 4)
1312 goto script;
1313 if (nxt - cur == 2)
1314 goto region;
1315 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1316 goto variant;
1317 if (nxt - cur != 3)
1318 return(0);
1319 /* we parsed an extlang */
1320 if (nxt[0] == 0)
1321 return(1);
1322 if (nxt[0] != '-')
1323 return(0);
1324
1325 nxt++;
1326 cur = nxt;
1327 /* now we can have script or region or variant */
1328 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1329 goto region_m49;
1330
1331 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1332 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1333 nxt++;
1334 if (nxt - cur == 2)
1335 goto region;
1336 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1337 goto variant;
1338 if (nxt - cur != 4)
1339 return(0);
1340 /* we parsed a script */
1341script:
1342 if (nxt[0] == 0)
1343 return(1);
1344 if (nxt[0] != '-')
1345 return(0);
1346
1347 nxt++;
1348 cur = nxt;
1349 /* now we can have region or variant */
1350 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1351 goto region_m49;
1352
1353 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1354 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1355 nxt++;
1356
1357 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1358 goto variant;
1359 if (nxt - cur != 2)
1360 return(0);
1361 /* we parsed a region */
1362region:
1363 if (nxt[0] == 0)
1364 return(1);
1365 if (nxt[0] != '-')
1366 return(0);
1367
1368 nxt++;
1369 cur = nxt;
1370 /* now we can just have a variant */
1371 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1372 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1373 nxt++;
1374
1375 if ((nxt - cur < 5) || (nxt - cur > 8))
1376 return(0);
1377
1378 /* we parsed a variant */
1379variant:
1380 if (nxt[0] == 0)
1381 return(1);
1382 if (nxt[0] != '-')
1383 return(0);
1384 /* extensions and private use subtags not checked */
1385 return (1);
1386
1387region_m49:
1388 if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1389 ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1390 nxt += 3;
1391 goto region;
1392 }
1393 return(0);
1394}
FxCollectionEntry * cur
script
Definition: msipriv.h:383
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by xmlParseAttribute2().

◆ xmlCopyChar()

XMLPUBFUN int xmlCopyChar ( int len  ATTRIBUTE_UNUSED,
xmlChar out,
int  val 
)

xmlCopyChar: @len: Ignored, compatibility @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 1057 of file parserInternals.c.

1057 {
1058 if ((out == NULL) || (val < 0)) return(0);
1059 /* the len parameter is ignored */
1060 if (val >= 0x80) {
1061 return(xmlCopyCharMultiByte (out, val));
1062 }
1063 *out = val;
1064 return 1;
1065}
GLuint GLfloat * val
Definition: glext.h:7180
int xmlCopyCharMultiByte(xmlChar *out, int val)
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by xmlParseAttValueComplex().

◆ xmlCopyCharMultiByte()

XMLPUBFUN int xmlCopyCharMultiByte ( xmlChar out,
int  val 
)

xmlCopyCharMultiByte: @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 1014 of file parserInternals.c.

1014 {
1015 if ((out == NULL) || (val < 0)) return(0);
1016 /*
1017 * We are supposed to handle UTF8, check it's valid
1018 * From rfc2044: encoding of the Unicode values on UTF-8:
1019 *
1020 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
1021 * 0000 0000-0000 007F 0xxxxxxx
1022 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
1023 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
1024 */
1025 if (val >= 0x80) {
1026 xmlChar *savedout = out;
1027 int bits;
1028 if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
1029 else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
1030 else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
1031 else {
1032 xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
1033 "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
1034 val);
1035 return(0);
1036 }
1037 for ( ; bits >= 0; bits-= 6)
1038 *out++= ((val >> bits) & 0x3F) | 0x80 ;
1039 return (out - savedout);
1040 }
1041 *out = val;
1042 return 1;
1043}
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
@ XML_ERR_INVALID_CHAR
Definition: xmlerror.h:109

Referenced by xmlCopyChar(), and xsltNumberFormatDecimal().

◆ xmlCreateEntityParserCtxt()

XMLPUBFUN xmlParserCtxtPtr xmlCreateEntityParserCtxt ( const xmlChar URL,
const xmlChar ID,
const xmlChar base 
)

xmlCreateEntityParserCtxt: @URL: the entity URL @ID: the entity PUBLIC ID @base: a possible base for the target URI

Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 13670 of file parser.c.

13671 {
13673
13674}
#define ID
Definition: ruserpass.c:36
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(xmlSAXHandlerPtr sax, void *userData, const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13600

◆ xmlCreateFileParserCtxt()

XMLPUBFUN xmlParserCtxtPtr xmlCreateFileParserCtxt ( const char filename)

Parser context.

xmlCreateFileParserCtxt: @filename: the filename

Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 13736 of file parser.c.

13737{
13738 return(xmlCreateURLParserCtxt(filename, 0));
13739}
const char * filename
Definition: ioapi.h:137
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:13694

◆ xmlCreateMemoryParserCtxt()

XMLPUBFUN xmlParserCtxtPtr xmlCreateMemoryParserCtxt ( const char buffer,
int  size 
)

xmlCreateMemoryParserCtxt: @buffer: a pointer to a char array @size: the size of the array

Create a parser context for an XML in-memory document.

Returns the new parser context or NULL

Definition at line 13996 of file parser.c.

13996 {
13997 xmlParserCtxtPtr ctxt;
13998 xmlParserInputPtr input;
13999 xmlParserInputBufferPtr buf;
14000
14001 if (buffer == NULL)
14002 return(NULL);
14003 if (size <= 0)
14004 return(NULL);
14005
14006 ctxt = xmlNewParserCtxt();
14007 if (ctxt == NULL)
14008 return(NULL);
14009
14011 if (buf == NULL) {
14012 xmlFreeParserCtxt(ctxt);
14013 return(NULL);
14014 }
14015
14016 input = xmlNewInputStream(ctxt);
14017 if (input == NULL) {
14019 xmlFreeParserCtxt(ctxt);
14020 return(NULL);
14021 }
14022
14023 input->filename = NULL;
14024 input->buf = buf;
14025 xmlBufResetInput(input->buf->buffer, input);
14026
14027 inputPush(ctxt, input);
14028 return(ctxt);
14029}
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1019
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:67
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBFUN void xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserCtxtPtr xmlNewParserCtxt(void)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1897
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
XMLPUBFUN void xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)

Referenced by doparse(), internal_parseBuffer(), xmlParseInNodeContext(), and xmlReadMemory().

◆ xmlCreateURLParserCtxt()

XMLPUBFUN xmlParserCtxtPtr xmlCreateURLParserCtxt ( const char filename,
int  options 
)

xmlCreateURLParserCtxt: @filename: the filename or URL @options: a combination of xmlParserOption

Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses

Returns the new parser context or NULL

Definition at line 13694 of file parser.c.

13695{
13696 xmlParserCtxtPtr ctxt;
13697 xmlParserInputPtr inputStream;
13698 char *directory = NULL;
13699
13700 ctxt = xmlNewParserCtxt();
13701 if (ctxt == NULL) {
13702 xmlErrMemory(NULL, "cannot allocate parser context");
13703 return(NULL);
13704 }
13705
13706 if (options)
13708 ctxt->linenumbers = 1;
13709
13710 inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
13711 if (inputStream == NULL) {
13712 xmlFreeParserCtxt(ctxt);
13713 return(NULL);
13714 }
13715
13716 inputPush(ctxt, inputStream);
13717 if ((ctxt->directory == NULL) && (directory == NULL))
13719 if ((ctxt->directory == NULL) && (directory != NULL))
13720 ctxt->directory = directory;
13721
13722 return(ctxt);
13723}
XMLPUBFUN xmlParserInputPtr xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options)
Definition: parser.c:14564
XMLPUBFUN char * xmlParserGetDirectory(const char *filename)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCurrentChar()

XML_DEPRECATED XMLPUBFUN int xmlCurrentChar ( xmlParserCtxtPtr  ctxt,
int len 
)

xmlCurrentChar: @ctxt: the XML parser context @len: pointer to the length of the char read

DEPRECATED: Internal function, do not use.

The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)

Returns the current char value and its length

Definition at line 833 of file parserInternals.c.

833 {
834 const unsigned char *cur;
835 size_t avail;
836 int c;
837
838 if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
839 if (ctxt->instate == XML_PARSER_EOF)
840 return(0);
841
842 avail = ctxt->input->end - ctxt->input->cur;
843
844 if (avail < INPUT_CHUNK) {
845 xmlParserGrow(ctxt);
846 if (ctxt->instate == XML_PARSER_EOF)
847 return(0);
848 avail = ctxt->input->end - ctxt->input->cur;
849 }
850
851 cur = ctxt->input->cur;
852 c = *cur;
853
854 if (c < 0x80) {
855 /* 1-byte code */
856 if (c < 0x20) {
857 /*
858 * 2.11 End-of-Line Handling
859 * the literal two-character sequence "#xD#xA" or a standalone
860 * literal #xD, an XML processor must pass to the application
861 * the single character #xA.
862 */
863 if (c == '\r') {
864 /*
865 * TODO: This function shouldn't change the 'cur' pointer
866 * as side effect, but the NEXTL macro in parser.c relies
867 * on this behavior when incrementing line numbers.
868 */
869 if (cur[1] == '\n')
870 ctxt->input->cur++;
871 *len = 1;
872 c = '\n';
873 } else if (c == 0) {
874 if (ctxt->input->cur >= ctxt->input->end) {
875 *len = 0;
876 } else {
877 *len = 1;
878 /*
879 * TODO: Null bytes should be handled by callers,
880 * but this can be tricky.
881 */
882 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
883 "Char 0x0 out of allowed range\n", c);
884 }
885 } else {
886 *len = 1;
887 }
888 } else {
889 *len = 1;
890 }
891
892 return(c);
893 } else {
894 int val;
895
896 if (avail < 2)
897 goto incomplete_sequence;
898 if ((cur[1] & 0xc0) != 0x80)
899 goto encoding_error;
900
901 if (c < 0xe0) {
902 /* 2-byte code */
903 if (c < 0xc2)
904 goto encoding_error;
905 val = (c & 0x1f) << 6;
906 val |= cur[1] & 0x3f;
907 *len = 2;
908 } else {
909 if (avail < 3)
910 goto incomplete_sequence;
911 if ((cur[2] & 0xc0) != 0x80)
912 goto encoding_error;
913
914 if (c < 0xf0) {
915 /* 3-byte code */
916 val = (c & 0xf) << 12;
917 val |= (cur[1] & 0x3f) << 6;
918 val |= cur[2] & 0x3f;
919 if ((val < 0x800) || ((val >= 0xd800) && (val < 0xe000)))
920 goto encoding_error;
921 *len = 3;
922 } else {
923 if (avail < 4)
924 goto incomplete_sequence;
925 if ((cur[3] & 0xc0) != 0x80)
926 goto encoding_error;
927
928 /* 4-byte code */
929 val = (c & 0x0f) << 18;
930 val |= (cur[1] & 0x3f) << 12;
931 val |= (cur[2] & 0x3f) << 6;
932 val |= cur[3] & 0x3f;
933 if ((val < 0x10000) || (val >= 0x110000))
934 goto encoding_error;
935 *len = 4;
936 }
937 }
938
939 return(val);
940 }
941
942encoding_error:
943 /* Only report the first error */
944 if ((ctxt->input->flags & XML_INPUT_ENCODING_ERROR) == 0) {
945 if (ctxt->input->end - ctxt->input->cur < 4) {
947 "Input is not proper UTF-8, indicate encoding !\n",
948 NULL, NULL);
949 } else {
950 char buffer[150];
951
952 snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
953 ctxt->input->cur[0], ctxt->input->cur[1],
954 ctxt->input->cur[2], ctxt->input->cur[3]);
956 "Input is not proper UTF-8, indicate encoding !\n%s",
958 }
959 ctxt->input->flags |= XML_INPUT_ENCODING_ERROR;
960 }
961 *len = 1;
962 return(0xFFFD); /* U+FFFD Replacement Character */
963
964incomplete_sequence:
965 /*
966 * An encoding problem may arise from a truncated input buffer
967 * splitting a character in the middle. In that case do not raise
968 * an error but return 0. This should only happen when push parsing
969 * char data.
970 */
971 *len = 0;
972 return(0);
973}
static int avail
Definition: adh-main.c:39
GLenum GLsizei len
Definition: glext.h:6722
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
int xmlParserGrow(xmlParserCtxtPtr ctxt)
#define INPUT_CHUNK
@ XML_PARSER_EOF
Definition: parser.h:116
#define XML_INPUT_ENCODING_ERROR
Definition: parser.h:27
#define snprintf
Definition: wintirpc.h:48
#define BAD_CAST
Definition: xmlstring.h:35

◆ xmlFreeInputStream()

XMLPUBFUN void xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1519 of file parserInternals.c.

1519 {
1520 if (input == NULL) return;
1521
1522 if (input->filename != NULL) xmlFree((char *) input->filename);
1523 if (input->directory != NULL) xmlFree((char *) input->directory);
1524 if (input->version != NULL) xmlFree((char *) input->version);
1525 if ((input->free != NULL) && (input->base != NULL))
1526 input->free((xmlChar *) input->base);
1527 if (input->buf != NULL)
1529 xmlFree(input);
1530}
xmlFreeFunc xmlFree
Definition: globals.c:184

Referenced by xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitSAXParserCtxt(), xmlLoadEntityContent(), xmlParsePEReference(), xmlPopInput(), xmlPushInput(), and xmlSAX2ExternalSubset().

◆ xmlIsLetter()

XMLPUBFUN int xmlIsLetter ( int  c)

xmlIsLetter: : an unicode character (int)

Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic

Returns 0 if not, non-zero otherwise

Definition at line 440 of file parserInternals.c.

440 {
441 return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
442}
#define IS_IDEOGRAPHIC(c)
#define IS_BASECHAR(c)

◆ xmlNewEntityInputStream()

XML_DEPRECATED XMLPUBFUN xmlParserInputPtr xmlNewEntityInputStream ( xmlParserCtxtPtr  ctxt,
xmlEntityPtr  entity 
)

xmlNewEntityInputStream: @ctxt: an XML parser context @entity: an Entity pointer

DEPRECATED: Internal function, do not use.

Create a new input stream based on an xmlEntityPtr

Returns the new input stream or NULL

Definition at line 1615 of file parserInternals.c.

1615 {
1616 xmlParserInputPtr input;
1617
1618 if (entity == NULL) {
1619 xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1620 NULL);
1621 return(NULL);
1622 }
1625 "new input from entity: %s\n", entity->name);
1626 if (entity->content == NULL) {
1627 switch (entity->etype) {
1629 xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1630 entity->name);
1631 break;
1634 input = xmlLoadExternalEntity((char *) entity->URI,
1635 (char *) entity->ExternalID, ctxt);
1636 if (input != NULL)
1637 input->entity = entity;
1638 return(input);
1640 xmlErrInternal(ctxt,
1641 "Internal entity %s without content !\n",
1642 entity->name);
1643 break;
1645 xmlErrInternal(ctxt,
1646 "Internal parameter entity %s without content !\n",
1647 entity->name);
1648 break;
1650 xmlErrInternal(ctxt,
1651 "Predefined entity %s without content !\n",
1652 entity->name);
1653 break;
1654 }
1655 return(NULL);
1656 }
1657 input = xmlNewInputStream(ctxt);
1658 if (input == NULL) {
1659 return(NULL);
1660 }
1661 if (entity->URI != NULL)
1662 input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1663 input->base = entity->content;
1664 if (entity->length == 0)
1665 entity->length = xmlStrlen(entity->content);
1666 input->cur = entity->content;
1667 input->length = entity->length;
1668 input->end = &entity->content[input->length];
1669 input->entity = entity;
1670 return(input);
1671}
@ XML_EXTERNAL_GENERAL_PARSED_ENTITY
Definition: entities.h:28
@ XML_INTERNAL_PREDEFINED_ENTITY
Definition: entities.h:32
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
Definition: entities.h:29
@ XML_INTERNAL_GENERAL_ENTITY
Definition: entities.h:27
@ XML_INTERNAL_PARAMETER_ENTITY
Definition: entities.h:30
@ XML_EXTERNAL_PARAMETER_ENTITY
Definition: entities.h:31
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396
int xmlParserDebugEntities
Definition: globals.c:277
Definition: actctx.c:446
WCHAR * name
Definition: actctx.c:463
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by xmlParsePEReference().

◆ xmlNewInputFromFile()

XMLPUBFUN xmlParserInputPtr xmlNewInputFromFile ( xmlParserCtxtPtr  ctxt,
const char filename 
)

xmlNewInputFromFile: @ctxt: an XML parser context @filename: the filename to use as entity

Create a new input stream based on a file or an URL.

Returns the new input stream or NULL in case of error

Definition at line 1720 of file parserInternals.c.

1720 {
1721 xmlParserInputBufferPtr buf;
1722 xmlParserInputPtr inputStream;
1723 char *directory = NULL;
1724 xmlChar *URI = NULL;
1725
1728 "new input from file: %s\n", filename);
1729 if (ctxt == NULL) return(NULL);
1731 if (buf == NULL) {
1732 if (filename == NULL)
1733 __xmlLoaderErr(ctxt,
1734 "failed to load external entity: NULL filename \n",
1735 NULL);
1736 else
1737 __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1738 (const char *) filename);
1739 return(NULL);
1740 }
1741
1742 inputStream = xmlNewInputStream(ctxt);
1743 if (inputStream == NULL) {
1745 return(NULL);
1746 }
1747
1748 inputStream->buf = buf;
1749 inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1750 if (inputStream == NULL)
1751 return(NULL);
1752
1753 if (inputStream->filename == NULL)
1754 URI = xmlStrdup((xmlChar *) filename);
1755 else
1756 URI = xmlStrdup((xmlChar *) inputStream->filename);
1757 directory = xmlParserGetDirectory((const char *) URI);
1758 if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1759 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1760 if (URI != NULL) xmlFree((char *) URI);
1761 inputStream->directory = directory;
1762
1763 xmlBufResetInput(inputStream->buf->buffer, inputStream);
1764 if ((ctxt->directory == NULL) && (directory != NULL))
1765 ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1766 return(inputStream);
1767}
XML_HIDDEN void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
XMLPUBFUN xmlChar * xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2394
XMLPUBFUN xmlParserInputPtr xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
XMLPUBFUN xmlParserInputBufferPtr xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)

◆ xmlNewInputStream()

XMLPUBFUN xmlParserInputPtr xmlNewInputStream ( xmlParserCtxtPtr  ctxt)

xmlNewInputStream: @ctxt: an XML parser context

Create a new input stream structure.

Returns the new input stream or NULL

Definition at line 1541 of file parserInternals.c.

1541 {
1542 xmlParserInputPtr input;
1543
1544 input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
1545 if (input == NULL) {
1546 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1547 return(NULL);
1548 }
1549 memset(input, 0, sizeof(xmlParserInput));
1550 input->line = 1;
1551 input->col = 1;
1552
1553 /*
1554 * If the context is NULL the id cannot be initialized, but that
1555 * should not happen while parsing which is the situation where
1556 * the id is actually needed.
1557 */
1558 if (ctxt != NULL) {
1559 if (input->id >= INT_MAX) {
1560 xmlErrMemory(ctxt, "Input ID overflow\n");
1561 return(NULL);
1562 }
1563 input->id = ctxt->input_id++;
1564 }
1565
1566 return(input);
1567}
#define INT_MAX
Definition: limits.h:26
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
xmlMallocFunc xmlMalloc
Definition: globals.c:193
#define memset(x, y, z)
Definition: compat.h:39

Referenced by xmlCreateDocParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCtxtResetPush(), xmlNewEntityInputStream(), xmlNewInputFromFile(), xmlNewIOInputStream(), and xmlNewStringInputStream().

◆ xmlNewStringInputStream()

XMLPUBFUN xmlParserInputPtr xmlNewStringInputStream ( xmlParserCtxtPtr  ctxt,
const xmlChar buffer 
)

Input Streams.

xmlNewStringInputStream: @ctxt: an XML parser context @buffer: an memory buffer

Create a new input stream based on a memory buffer. Returns the new input stream

Definition at line 1682 of file parserInternals.c.

1682 {
1683 xmlParserInputPtr input;
1684 xmlParserInputBufferPtr buf;
1685
1686 if (buffer == NULL) {
1687 xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1688 NULL);
1689 return(NULL);
1690 }
1693 "new fixed input: %.30s\n", buffer);
1695 if (buf == NULL) {
1696 xmlErrMemory(ctxt, NULL);
1697 return(NULL);
1698 }
1699 input = xmlNewInputStream(ctxt);
1700 if (input == NULL) {
1701 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1703 return(NULL);
1704 }
1705 input->buf = buf;
1706 xmlBufResetInput(input->buf->buffer, input);
1707 return(input);
1708}
XML_HIDDEN void xmlParserInputBufferPtr xmlParserInputBufferCreateString(const xmlChar *str)

Referenced by external_entity_loader().

◆ xmlNextChar()

XML_DEPRECATED XMLPUBFUN void xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

DEPRECATED: Internal function, do not use.

Skip to the next char input char.

Definition at line 709 of file parserInternals.c.

710{
711 const unsigned char *cur;
712 size_t avail;
713 int c;
714
715 if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
716 (ctxt->input == NULL))
717 return;
718
719 avail = ctxt->input->end - ctxt->input->cur;
720
721 if (avail < INPUT_CHUNK) {
722 xmlParserGrow(ctxt);
723 if ((ctxt->instate == XML_PARSER_EOF) ||
724 (ctxt->input->cur >= ctxt->input->end))
725 return;
726 avail = ctxt->input->end - ctxt->input->cur;
727 }
728
729 cur = ctxt->input->cur;
730 c = *cur;
731
732 if (c < 0x80) {
733 if (c == '\n') {
734 ctxt->input->cur++;
735 ctxt->input->line++;
736 ctxt->input->col = 1;
737 } else if (c == '\r') {
738 /*
739 * 2.11 End-of-Line Handling
740 * the literal two-character sequence "#xD#xA" or a standalone
741 * literal #xD, an XML processor must pass to the application
742 * the single character #xA.
743 */
744 ctxt->input->cur += ((cur[1] == '\n') ? 2 : 1);
745 ctxt->input->line++;
746 ctxt->input->col = 1;
747 return;
748 } else {
749 ctxt->input->cur++;
750 ctxt->input->col++;
751 }
752 } else {
753 ctxt->input->col++;
754
755 if ((avail < 2) || (cur[1] & 0xc0) != 0x80)
756 goto encoding_error;
757
758 if (c < 0xe0) {
759 /* 2-byte code */
760 if (c < 0xc2)
761 goto encoding_error;
762 ctxt->input->cur += 2;
763 } else {
764 unsigned int val = (c << 8) | cur[1];
765
766 if ((avail < 3) || (cur[2] & 0xc0) != 0x80)
767 goto encoding_error;
768
769 if (c < 0xf0) {
770 /* 3-byte code */
771 if ((val < 0xe0a0) || ((val >= 0xeda0) && (val < 0xee00)))
772 goto encoding_error;
773 ctxt->input->cur += 3;
774 } else {
775 if ((avail < 4) || ((cur[3] & 0xc0) != 0x80))
776 goto encoding_error;
777
778 /* 4-byte code */
779 if ((val < 0xf090) || (val >= 0xf490))
780 goto encoding_error;
781 ctxt->input->cur += 4;
782 }
783 }
784 }
785
786 return;
787
788encoding_error:
789 /* Only report the first error */
790 if ((ctxt->input->flags & XML_INPUT_ENCODING_ERROR) == 0) {
791 if ((ctxt == NULL) || (ctxt->input == NULL) ||
792 (ctxt->input->end - ctxt->input->cur < 4)) {
794 "Input is not proper UTF-8, indicate encoding !\n",
795 NULL, NULL);
796 } else {
797 char buffer[150];
798
799 snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
800 ctxt->input->cur[0], ctxt->input->cur[1],
801 ctxt->input->cur[2], ctxt->input->cur[3]);
803 "Input is not proper UTF-8, indicate encoding !\n%s",
805 }
806 ctxt->input->flags |= XML_INPUT_ENCODING_ERROR;
807 }
808 ctxt->input->cur++;
809 return;
810}

◆ xmlParseAttributeListDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseAttributeListDecl ( xmlParserCtxtPtr  ctxt)

xmlParseAttributeListDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse an attribute list declaration for an element. Always consumes '<!'.

[52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'

[53] AttDef ::= S Name S AttType S DefaultDecl

Definition at line 6130 of file parser.c.

6130 {
6131 const xmlChar *elemName;
6132 const xmlChar *attrName;
6133 xmlEnumerationPtr tree;
6134
6135 if ((CUR != '<') || (NXT(1) != '!'))
6136 return;
6137 SKIP(2);
6138
6139 if (CMP7(CUR_PTR, 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
6140 int inputid = ctxt->input->id;
6141
6142 SKIP(7);
6143 if (SKIP_BLANKS == 0) {
6144 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6145 "Space required after '<!ATTLIST'\n");
6146 }
6147 elemName = xmlParseName(ctxt);
6148 if (elemName == NULL) {
6149 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6150 "ATTLIST: no name for Element\n");
6151 return;
6152 }
6154 GROW;
6155 while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
6156 int type;
6157 int def;
6158 xmlChar *defaultValue = NULL;
6159
6160 GROW;
6161 tree = NULL;
6162 attrName = xmlParseName(ctxt);
6163 if (attrName == NULL) {
6164 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6165 "ATTLIST: no name for Attribute\n");
6166 break;
6167 }
6168 GROW;
6169 if (SKIP_BLANKS == 0) {
6170 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6171 "Space required after the attribute name\n");
6172 break;
6173 }
6174
6176 if (type <= 0) {
6177 break;
6178 }
6179
6180 GROW;
6181 if (SKIP_BLANKS == 0) {
6182 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6183 "Space required after the attribute type\n");
6184 if (tree != NULL)
6186 break;
6187 }
6188
6189 def = xmlParseDefaultDecl(ctxt, &defaultValue);
6190 if (def <= 0) {
6191 if (defaultValue != NULL)
6192 xmlFree(defaultValue);
6193 if (tree != NULL)
6195 break;
6196 }
6197 if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
6198 xmlAttrNormalizeSpace(defaultValue, defaultValue);
6199
6200 GROW;
6201 if (RAW != '>') {
6202 if (SKIP_BLANKS == 0) {
6203 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6204 "Space required after the attribute default value\n");
6205 if (defaultValue != NULL)
6206 xmlFree(defaultValue);
6207 if (tree != NULL)
6209 break;
6210 }
6211 }
6212 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6213 (ctxt->sax->attributeDecl != NULL))
6214 ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6215 type, def, defaultValue, tree);
6216 else if (tree != NULL)
6218
6219 if ((ctxt->sax2) && (defaultValue != NULL) &&
6220 (def != XML_ATTRIBUTE_IMPLIED) &&
6221 (def != XML_ATTRIBUTE_REQUIRED)) {
6222 xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6223 }
6224 if (ctxt->sax2) {
6225 xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6226 }
6227 if (defaultValue != NULL)
6228 xmlFree(defaultValue);
6229 GROW;
6230 }
6231 if (RAW == '>') {
6232 if (inputid != ctxt->input->id) {
6233 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6234 "Attribute list declaration doesn't start and"
6235 " stop in the same entity\n");
6236 }
6237 NEXT;
6238 }
6239 }
6240}
struct _tree tree
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5829
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1017
#define NEXT
Definition: parser.c:2280
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:927
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2239
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3529
#define SKIP_BLANKS
Definition: parser.c:2278
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:6087
#define RAW
Definition: parser.c:2226
#define GROW
Definition: parser.c:2275
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1138
#define SKIP(val)
Definition: parser.c:2250
#define NXT(val)
Definition: parser.c:2228
#define CUR_PTR
Definition: parser.c:2229
#define CUR
Definition: parser.c:2227
XMLPUBFUN void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1662
@ XML_ERR_ENTITY_BOUNDARY
Definition: xmlerror.h:190
@ XML_ERR_SPACE_REQUIRED
Definition: xmlerror.h:165
@ XML_ERR_NAME_REQUIRED
Definition: xmlerror.h:168

Referenced by xmlParseMarkupDecl().

◆ xmlParseAttributeType()

XML_DEPRECATED XMLPUBFUN int xmlParseAttributeType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr *  tree 
)

xmlParseAttributeType: @ctxt: an XML parser context @tree: the enumeration tree built while parsing

DEPRECATED: Internal function, don't use.

parse the Attribute list def for an element

[54] AttType ::= StringType | TokenizedType | EnumeratedType

[55] StringType ::= 'CDATA'

[56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'

Validity constraints for attribute values syntax are checked in xmlValidateAttributeValue()

[ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.

[ VC: One ID per Element Type ] No element type may have more than one ID attribute specified.

[ VC: ID Attribute Default ] An ID attribute must have a declared default of #IMPLIED or #REQUIRED.

[ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID attribute on some element in the XML document; i.e. IDREF values must match the value of some ID attribute.

[ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD.

[ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

Returns the attribute type

Definition at line 6087 of file parser.c.

6087 {
6088 if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
6089 SKIP(5);
6090 return(XML_ATTRIBUTE_CDATA);
6091 } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
6092 SKIP(6);
6093 return(XML_ATTRIBUTE_IDREFS);
6094 } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
6095 SKIP(5);
6096 return(XML_ATTRIBUTE_IDREF);
6097 } else if ((RAW == 'I') && (NXT(1) == 'D')) {
6098 SKIP(2);
6099 return(XML_ATTRIBUTE_ID);
6100 } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
6101 SKIP(6);
6102 return(XML_ATTRIBUTE_ENTITY);
6103 } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
6104 SKIP(8);
6105 return(XML_ATTRIBUTE_ENTITIES);
6106 } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
6107 SKIP(8);
6108 return(XML_ATTRIBUTE_NMTOKENS);
6109 } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
6110 SKIP(7);
6111 return(XML_ATTRIBUTE_NMTOKEN);
6112 }
6113 return(xmlParseEnumeratedType(ctxt, tree));
6114}
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:6022
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2235
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2241
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2237

Referenced by xmlParseAttributeListDecl().

◆ xmlParseAttValue()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseAttValue ( xmlParserCtxtPtr  ctxt)

xmlParseAttValue: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse a value for an attribute Note: the parser won't do substitution of entities here, this will be handled later in xmlStringGetNodeList

[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"

3.3.3 Attribute-Value Normalization: Before the value of an attribute is passed to the application or checked for validity, the XML processor must normalize it as follows:

  • a character reference is processed by appending the referenced character to the attribute value
  • an entity reference is processed by recursively processing the replacement text of the entity
  • a whitespace character (#x20, #xD, #xA, x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a "#xD#xA" sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity
  • other characters are processed by appending them to the normalized value If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by a single space (#x20) character. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.

Returns the AttValue parsed or NULL. The value has to be freed by the caller.

Definition at line 4342 of file parser.c.

4342 {
4343 if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4344 return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4345}
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:9121

Referenced by xmlParseDefaultDecl().

◆ xmlParseCDSect()

XML_DEPRECATED XMLPUBFUN void xmlParseCDSect ( xmlParserCtxtPtr  ctxt)

xmlParseCDSect: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse escaped pure raw content. Always consumes '<!['.

[18] CDSect ::= CDStart CData CDEnd

[19] CDStart ::= ''

[20] Data ::= (Char* - (Char* '' Char*))

[21] CDEnd ::= ']]>'

Definition at line 10117 of file parser.c.

10117 {
10118 xmlChar *buf = NULL;
10119 int len = 0;
10121 int r, rl;
10122 int s, sl;
10123 int cur, l;
10124 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
10127
10128 if ((CUR != '<') || (NXT(1) != '!') || (NXT(2) != '['))
10129 return;
10130 SKIP(3);
10131
10132 if (!CMP6(CUR_PTR, 'C', 'D', 'A', 'T', 'A', '['))
10133 return;
10134 SKIP(6);
10135
10136 ctxt->instate = XML_PARSER_CDATA_SECTION;
10137 r = CUR_CHAR(rl);
10138 if (!IS_CHAR(r)) {
10140 goto out;
10141 }
10142 NEXTL(rl);
10143 s = CUR_CHAR(sl);
10144 if (!IS_CHAR(s)) {
10146 goto out;
10147 }
10148 NEXTL(sl);
10149 cur = CUR_CHAR(l);
10151 if (buf == NULL) {
10152 xmlErrMemory(ctxt, NULL);
10153 goto out;
10154 }
10155 while (IS_CHAR(cur) &&
10156 ((r != ']') || (s != ']') || (cur != '>'))) {
10157 if (len + 5 >= size) {
10158 xmlChar *tmp;
10159
10160 tmp = (xmlChar *) xmlRealloc(buf, size * 2);
10161 if (tmp == NULL) {
10162 xmlErrMemory(ctxt, NULL);
10163 goto out;
10164 }
10165 buf = tmp;
10166 size *= 2;
10167 }
10168 COPY_BUF(buf, len, r);
10169 if (len > maxLength) {
10170 xmlFatalErrMsg(ctxt, XML_ERR_CDATA_NOT_FINISHED,
10171 "CData section too big found\n");
10172 goto out;
10173 }
10174 r = s;
10175 rl = sl;
10176 s = cur;
10177 sl = l;
10178 NEXTL(l);
10179 cur = CUR_CHAR(l);
10180 }
10181 buf[len] = 0;
10182 if (ctxt->instate == XML_PARSER_EOF) {
10183 xmlFree(buf);
10184 return;
10185 }
10186 if (cur != '>') {
10187 xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
10188 "CData section not finished\n%.50s\n", buf);
10189 goto out;
10190 }
10191 NEXTL(l);
10192
10193 /*
10194 * OK the buffer is to be consumed as cdata.
10195 */
10196 if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
10197 if (ctxt->sax->cdataBlock != NULL)
10198 ctxt->sax->cdataBlock(ctxt->userData, buf, len);
10199 else if (ctxt->sax->characters != NULL)
10200 ctxt->sax->characters(ctxt->userData, buf, len);
10201 }
10202
10203out:
10204 if (ctxt->instate != XML_PARSER_EOF)
10205 ctxt->instate = XML_PARSER_CONTENT;
10206 xmlFree(buf);
10207}
r l[0]
Definition: byte_order.h:168
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei maxLength
Definition: glext.h:6877
#define XML_MAX_TEXT_LENGTH
#define IS_CHAR(c)
#define XML_MAX_HUGE_LENGTH
xmlMallocFunc xmlMallocAtomic
Definition: globals.c:204
@ XML_PARSER_CONTENT
Definition: parser.h:124
@ XML_PARSER_CDATA_SECTION
Definition: parser.h:125
XML_HIDDEN void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
#define NEXTL(l)
Definition: parser.c:2289
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:167
#define COPY_BUF(b, i, v)
Definition: parser.c:2299
#define CUR_CHAR(l)
Definition: parser.c:2296
@ XML_ERR_CDATA_NOT_FINISHED
Definition: xmlerror.h:163

Referenced by xmlParseContentInternal().

◆ xmlParseCharData()

XML_DEPRECATED XMLPUBFUN void xmlParseCharData ( xmlParserCtxtPtr  ctxt,
int  cdata 
)

◆ xmlParseCharRef()

XML_DEPRECATED XMLPUBFUN int xmlParseCharRef ( xmlParserCtxtPtr  ctxt)

xmlParseCharRef: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse a numeric character reference. Always consumes '&'.

[66] CharRef ::= '&#' [0-9]+ ';' | '&x' [0-9a-fA-F]+ ';'

[ WFC: Legal Character ] Characters referred to using character references must match the production for Char.

Returns the value parsed (as an int), 0 in case of error

Definition at line 2493 of file parser.c.

2493 {
2494 int val = 0;
2495 int count = 0;
2496
2497 /*
2498 * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2499 */
2500 if ((RAW == '&') && (NXT(1) == '#') &&
2501 (NXT(2) == 'x')) {
2502 SKIP(3);
2503 GROW;
2504 while (RAW != ';') { /* loop blocked by count */
2505 if (count++ > 20) {
2506 count = 0;
2507 GROW;
2508 if (ctxt->instate == XML_PARSER_EOF)
2509 return(0);
2510 }
2511 if ((RAW >= '0') && (RAW <= '9'))
2512 val = val * 16 + (CUR - '0');
2513 else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2514 val = val * 16 + (CUR - 'a') + 10;
2515 else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2516 val = val * 16 + (CUR - 'A') + 10;
2517 else {
2519 val = 0;
2520 break;
2521 }
2522 if (val > 0x110000)
2523 val = 0x110000;
2524
2525 NEXT;
2526 count++;
2527 }
2528 if (RAW == ';') {
2529 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2530 ctxt->input->col++;
2531 ctxt->input->cur++;
2532 }
2533 } else if ((RAW == '&') && (NXT(1) == '#')) {
2534 SKIP(2);
2535 GROW;
2536 while (RAW != ';') { /* loop blocked by count */
2537 if (count++ > 20) {
2538 count = 0;
2539 GROW;
2540 if (ctxt->instate == XML_PARSER_EOF)
2541 return(0);
2542 }
2543 if ((RAW >= '0') && (RAW <= '9'))
2544 val = val * 10 + (CUR - '0');
2545 else {
2547 val = 0;
2548 break;
2549 }
2550 if (val > 0x110000)
2551 val = 0x110000;
2552
2553 NEXT;
2554 count++;
2555 }
2556 if (RAW == ';') {
2557 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2558 ctxt->input->col++;
2559 ctxt->input->cur++;
2560 }
2561 } else {
2562 if (RAW == '&')
2563 SKIP(1);
2565 }
2566
2567 /*
2568 * [ WFC: Legal Character ]
2569 * Characters referred to using character references must match the
2570 * production for Char.
2571 */
2572 if (val >= 0x110000) {
2573 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2574 "xmlParseCharRef: character reference out of bounds\n",
2575 val);
2576 } else if (IS_CHAR(val)) {
2577 return(val);
2578 } else {
2579 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2580 "xmlParseCharRef: invalid xmlChar value %d\n",
2581 val);
2582 }
2583 return(0);
2584}
GLuint GLuint GLsizei count
Definition: gl.h:1545
@ XML_ERR_INVALID_CHARREF
Definition: xmlerror.h:108
@ XML_ERR_INVALID_DEC_CHARREF
Definition: xmlerror.h:107
@ XML_ERR_INVALID_HEX_CHARREF
Definition: xmlerror.h:106

Referenced by xmlParseAttValueComplex(), and xmlParseReference().

◆ xmlParseComment()

XML_DEPRECATED XMLPUBFUN void xmlParseComment ( xmlParserCtxtPtr  ctxt)

xmlParseComment: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse an XML (SGML) comment. Always consumes '<!'.

The spec says that "For compatibility, the string "–" (double-hyphen) must not occur within comments. "

[15] Comment ::= ''

Definition at line 5034 of file parser.c.

5034 {
5035 xmlChar *buf = NULL;
5037 size_t len = 0;
5038 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
5042 const xmlChar *in;
5043 size_t nbchar = 0;
5044 int ccol;
5045 int inputid;
5046
5047 /*
5048 * Check that there is a comment right here.
5049 */
5050 if ((RAW != '<') || (NXT(1) != '!'))
5051 return;
5052 SKIP(2);
5053 if ((RAW != '-') || (NXT(1) != '-'))
5054 return;
5055 state = ctxt->instate;
5056 ctxt->instate = XML_PARSER_COMMENT;
5057 inputid = ctxt->input->id;
5058 SKIP(2);
5059 GROW;
5060
5061 /*
5062 * Accelerated common case where input don't need to be
5063 * modified before passing it to the handler.
5064 */
5065 in = ctxt->input->cur;
5066 do {
5067 if (*in == 0xA) {
5068 do {
5069 ctxt->input->line++; ctxt->input->col = 1;
5070 in++;
5071 } while (*in == 0xA);
5072 }
5073get_more:
5074 ccol = ctxt->input->col;
5075 while (((*in > '-') && (*in <= 0x7F)) ||
5076 ((*in >= 0x20) && (*in < '-')) ||
5077 (*in == 0x09)) {
5078 in++;
5079 ccol++;
5080 }
5081 ctxt->input->col = ccol;
5082 if (*in == 0xA) {
5083 do {
5084 ctxt->input->line++; ctxt->input->col = 1;
5085 in++;
5086 } while (*in == 0xA);
5087 goto get_more;
5088 }
5089 nbchar = in - ctxt->input->cur;
5090 /*
5091 * save current set of data
5092 */
5093 if (nbchar > 0) {
5094 if (buf == NULL) {
5095 if ((*in == '-') && (in[1] == '-'))
5096 size = nbchar + 1;
5097 else
5098 size = XML_PARSER_BUFFER_SIZE + nbchar;
5100 if (buf == NULL) {
5101 xmlErrMemory(ctxt, NULL);
5102 ctxt->instate = state;
5103 return;
5104 }
5105 len = 0;
5106 } else if (len + nbchar + 1 >= size) {
5107 xmlChar *new_buf;
5108 size += len + nbchar + XML_PARSER_BUFFER_SIZE;
5109 new_buf = (xmlChar *) xmlRealloc(buf, size);
5110 if (new_buf == NULL) {
5111 xmlFree (buf);
5112 xmlErrMemory(ctxt, NULL);
5113 ctxt->instate = state;
5114 return;
5115 }
5116 buf = new_buf;
5117 }
5118 memcpy(&buf[len], ctxt->input->cur, nbchar);
5119 len += nbchar;
5120 buf[len] = 0;
5121 }
5122 if (len > maxLength) {
5123 xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
5124 "Comment too big found", NULL);
5125 xmlFree (buf);
5126 return;
5127 }
5128 ctxt->input->cur = in;
5129 if (*in == 0xA) {
5130 in++;
5131 ctxt->input->line++; ctxt->input->col = 1;
5132 }
5133 if (*in == 0xD) {
5134 in++;
5135 if (*in == 0xA) {
5136 ctxt->input->cur = in;
5137 in++;
5138 ctxt->input->line++; ctxt->input->col = 1;
5139 goto get_more;
5140 }
5141 in--;
5142 }
5143 SHRINK;
5144 GROW;
5145 if (ctxt->instate == XML_PARSER_EOF) {
5146 xmlFree(buf);
5147 return;
5148 }
5149 in = ctxt->input->cur;
5150 if (*in == '-') {
5151 if (in[1] == '-') {
5152 if (in[2] == '>') {
5153 if (ctxt->input->id != inputid) {
5154 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5155 "comment doesn't start and stop in the"
5156 " same entity\n");
5157 }
5158 SKIP(3);
5159 if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
5160 (!ctxt->disableSAX)) {
5161 if (buf != NULL)
5162 ctxt->sax->comment(ctxt->userData, buf);
5163 else
5164 ctxt->sax->comment(ctxt->userData, BAD_CAST "");
5165 }
5166 if (buf != NULL)
5167 xmlFree(buf);
5168 if (ctxt->instate != XML_PARSER_EOF)
5169 ctxt->instate = state;
5170 return;
5171 }
5172 if (buf != NULL) {
5173 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5174 "Double hyphen within comment: "
5175 "<!--%.50s\n",
5176 buf);
5177 } else
5178 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5179 "Double hyphen within comment\n", NULL);
5180 if (ctxt->instate == XML_PARSER_EOF) {
5181 xmlFree(buf);
5182 return;
5183 }
5184 in++;
5185 ctxt->input->col++;
5186 }
5187 in++;
5188 ctxt->input->col++;
5189 goto get_more;
5190 }
5191 } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
5193 ctxt->instate = state;
5194 return;
5195}
static int state
Definition: maze.c:121
GLuint in
Definition: glext.h:9616
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
xmlParserInputState
Definition: parser.h:115
@ XML_PARSER_COMMENT
Definition: parser.h:122
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4905
#define SHRINK
Definition: parser.c:2269
@ XML_ERR_HYPHEN_IN_COMMENT
Definition: xmlerror.h:180
@ XML_ERR_COMMENT_NOT_FINISHED
Definition: xmlerror.h:145

Referenced by xmlParseContentInternal(), xmlParseMarkupDecl(), and xmlParseMisc().

◆ xmlParseContent()

XMLPUBFUN void xmlParseContent ( xmlParserCtxtPtr  ctxt)

xmlParseContent: @ctxt: an XML parser context

Parse a content sequence. Stops at EOF or '</'.

[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

Definition at line 10294 of file parser.c.

10294 {
10295 int nameNr = ctxt->nameNr;
10296
10298
10299 if ((ctxt->instate != XML_PARSER_EOF) &&
10300 (ctxt->errNo == XML_ERR_OK) &&
10301 (ctxt->nameNr > nameNr)) {
10302 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
10303 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
10304 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
10305 "Premature end of data in tag %s line %d\n",
10306 name, line, NULL);
10307 }
10308}
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:10218
Definition: parser.c:49
Definition: name.c:39
@ XML_ERR_OK
Definition: xmlerror.h:100
@ XML_ERR_TAG_NOT_FINISHED
Definition: xmlerror.h:177

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseExtParsedEnt(), and xmlParseInNodeContext().

◆ xmlParseDefaultDecl()

XML_DEPRECATED XMLPUBFUN int xmlParseDefaultDecl ( xmlParserCtxtPtr  ctxt,
xmlChar **  value 
)

xmlParseDefaultDecl: @ctxt: an XML parser context @value: Receive a possible fixed default value for the attribute

DEPRECATED: Internal function, don't use.

Parse an attribute default declaration

[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('FIXED' S)? AttValue)

[ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.

[ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared attribute type c.f. xmlValidateAttributeDecl()

[ VC: Fixed Attribute Default ] if an attribute has a default value declared with the FIXED keyword, instances of that attribute must match the default value.

[ WFC: No < in Attribute Values ] handled in xmlParseAttValue()

returns: XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED or XML_ATTRIBUTE_FIXED.

Definition at line 5829 of file parser.c.

5829 {
5830 int val;
5831 xmlChar *ret;
5832
5833 *value = NULL;
5834 if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5835 SKIP(9);
5836 return(XML_ATTRIBUTE_REQUIRED);
5837 }
5838 if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5839 SKIP(8);
5840 return(XML_ATTRIBUTE_IMPLIED);
5841 }
5842 val = XML_ATTRIBUTE_NONE;
5843 if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5844 SKIP(6);
5845 val = XML_ATTRIBUTE_FIXED;
5846 if (SKIP_BLANKS == 0) {
5847 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5848 "Space required after '#FIXED'\n");
5849 }
5850 }
5851 ret = xmlParseAttValue(ctxt);
5852 ctxt->instate = XML_PARSER_DTD;
5853 if (ret == NULL) {
5854 xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5855 "Attribute default value declaration error\n");
5856 } else
5857 *value = ret;
5858 return(val);
5859}
@ XML_PARSER_DTD
Definition: parser.h:120
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4342
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2243
xmlParserErrors
Definition: xmlerror.h:99

Referenced by xmlParseAttributeListDecl().

◆ xmlParseDocTypeDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseDocTypeDecl ( xmlParserCtxtPtr  ctxt)

xmlParseDocTypeDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse a DOCTYPE declaration

[28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'

[ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.

Definition at line 8466 of file parser.c.

8466 {
8467 const xmlChar *name = NULL;
8468 xmlChar *ExternalID = NULL;
8469 xmlChar *URI = NULL;
8470
8471 /*
8472 * We know that '<!DOCTYPE' has been detected.
8473 */
8474 SKIP(9);
8475
8477
8478 /*
8479 * Parse the DOCTYPE name.
8480 */
8481 name = xmlParseName(ctxt);
8482 if (name == NULL) {
8483 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8484 "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8485 }
8486 ctxt->intSubName = name;
8487
8489
8490 /*
8491 * Check for SystemID and ExternalID
8492 */
8493 URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8494
8495 if ((URI != NULL) || (ExternalID != NULL)) {
8496 ctxt->hasExternalSubset = 1;
8497 }
8498 ctxt->extSubURI = URI;
8499 ctxt->extSubSystem = ExternalID;
8500
8502
8503 /*
8504 * Create and update the internal subset.
8505 */
8506 if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8507 (!ctxt->disableSAX))
8508 ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8509 if (ctxt->instate == XML_PARSER_EOF)
8510 return;
8511
8512 /*
8513 * Is there any internal subset declarations ?
8514 * they are handled separately in xmlParseInternalSubset()
8515 */
8516 if (RAW == '[')
8517 return;
8518
8519 /*
8520 * We should be at the end of the DOCTYPE declaration.
8521 */
8522 if (RAW != '>') {
8524 }
8525 NEXT;
8526}
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4840
@ XML_ERR_DOCTYPE_NOT_FINISHED
Definition: xmlerror.h:161

Referenced by xmlParseDocument().

◆ xmlParseElement()

XML_DEPRECATED XMLPUBFUN void xmlParseElement ( xmlParserCtxtPtr  ctxt)

xmlParseElement: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML element

[39] element ::= EmptyElemTag | STag content ETag

[ WFC: Element Type Match ] The Name in an element's end-tag must match the element type in the start-tag.

Definition at line 10327 of file parser.c.

10327 {
10328 if (xmlParseElementStart(ctxt) != 0)
10329 return;
10330
10332 if (ctxt->instate == XML_PARSER_EOF)
10333 return;
10334
10335 if (ctxt->input->cur >= ctxt->input->end) {
10336 if (ctxt->errNo == XML_ERR_OK) {
10337 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
10338 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
10339 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
10340 "Premature end of data in tag %s line %d\n",
10341 name, line, NULL);
10342 }
10343 return;
10344 }
10345
10346 xmlParseElementEnd(ctxt);
10347}
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:10359
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10483

Referenced by xmlParseDocument().

◆ xmlParseElementChildrenContentDecl()

XML_DEPRECATED XMLPUBFUN xmlElementContentPtr xmlParseElementChildrenContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

xmlParseElementChildrenContentDecl: @ctxt: an XML parser context @inputchk: the input used for the current entity, needed for boundary checks

DEPRECATED: Internal function, don't use.

parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in xmlParseElementContentDecl

[47] children ::= (choice | seq) ('?' | '*' | '+')?

[48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?

[49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'

[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'

[ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).

Returns the tree of xmlElementContentPtr describing the element hierarchy.

Definition at line 6693 of file parser.c.

6693 {
6694 /* stub left for API/ABI compat */
6695 return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6696}
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6389

◆ xmlParseElementContentDecl()

XML_DEPRECATED XMLPUBFUN int xmlParseElementContentDecl ( xmlParserCtxtPtr  ctxt,
const xmlChar name,
xmlElementContentPtr *  result 
)

Definition at line 6715 of file parser.c.

6716 {
6717
6718 xmlElementContentPtr tree = NULL;
6719 int inputid = ctxt->input->id;
6720 int res;
6721
6722 *result = NULL;
6723
6724 if (RAW != '(') {
6725 xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6726 "xmlParseElementContentDecl : %s '(' expected\n", name);
6727 return(-1);
6728 }
6729 NEXT;
6730 GROW;
6731 if (ctxt->instate == XML_PARSER_EOF)
6732 return(-1);
6734 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6735 tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6736 res = XML_ELEMENT_TYPE_MIXED;
6737 } else {
6738 tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6739 res = XML_ELEMENT_TYPE_ELEMENT;
6740 }
6742 *result = tree;
6743 return(res);
6744}
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6264
@ XML_ERR_ELEMCONTENT_NOT_STARTED
Definition: xmlerror.h:154

Referenced by xmlParseElementDecl().

◆ xmlParseElementDecl()

XML_DEPRECATED XMLPUBFUN int xmlParseElementDecl ( xmlParserCtxtPtr  ctxt)

xmlParseElementDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse an element declaration. Always consumes '<!'.

[45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'

[ VC: Unique Element Type Declaration ] No element type may be declared more than once

Returns the type of the element, or -1 in case of error

Definition at line 6762 of file parser.c.

6762 {
6763 const xmlChar *name;
6764 int ret = -1;
6765 xmlElementContentPtr content = NULL;
6766
6767 if ((CUR != '<') || (NXT(1) != '!'))
6768 return(ret);
6769 SKIP(2);
6770
6771 /* GROW; done in the caller */
6772 if (CMP7(CUR_PTR, 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6773 int inputid = ctxt->input->id;
6774
6775 SKIP(7);
6776 if (SKIP_BLANKS == 0) {
6777 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6778 "Space required after 'ELEMENT'\n");
6779 return(-1);
6780 }
6781 name = xmlParseName(ctxt);
6782 if (name == NULL) {
6783 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6784 "xmlParseElementDecl: no name for Element\n");
6785 return(-1);
6786 }
6787 if (SKIP_BLANKS == 0) {
6788 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6789 "Space required after the element name\n");
6790 }
6791 if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6792 SKIP(5);
6793 /*
6794 * Element must always be empty.
6795 */
6796 ret = XML_ELEMENT_TYPE_EMPTY;
6797 } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6798 (NXT(2) == 'Y')) {
6799 SKIP(3);
6800 /*
6801 * Element is a generic container.
6802 */
6803 ret = XML_ELEMENT_TYPE_ANY;
6804 } else if (RAW == '(') {
6806 } else {
6807 /*
6808 * [ WFC: PEs in Internal Subset ] error handling.
6809 */
6810 if ((RAW == '%') && (ctxt->external == 0) &&
6811 (ctxt->inputNr == 1)) {
6812 xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6813 "PEReference: forbidden within markup decl in internal subset\n");
6814 } else {
6815 xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6816 "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6817 }
6818 return(-1);
6819 }
6820
6822
6823 if (RAW != '>') {
6825 if (content != NULL) {
6826 xmlFreeDocElementContent(ctxt->myDoc, content);
6827 }
6828 } else {
6829 if (inputid != ctxt->input->id) {
6830 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6831 "Element declaration doesn't start and stop in"
6832 " the same entity\n");
6833 }
6834
6835 NEXT;
6836 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6837 (ctxt->sax->elementDecl != NULL)) {
6838 if (content != NULL)
6839 content->parent = NULL;
6840 ctxt->sax->elementDecl(ctxt->userData, name, ret,
6841 content);
6842 if ((content != NULL) && (content->parent == NULL)) {
6843 /*
6844 * this is a trick: if xmlAddElementDecl is called,
6845 * instead of copying the full tree it is plugged directly
6846 * if called from the parser. Avoid duplicating the
6847 * interfaces or change the API/ABI
6848 */
6849 xmlFreeDocElementContent(ctxt->myDoc, content);
6850 }
6851 } else if (content != NULL) {
6852 xmlFreeDocElementContent(ctxt->myDoc, content);
6853 }
6854 }
6855 }
6856 return(ret);
6857}
content
Definition: atl_ax.c:994
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6715
XMLPUBFUN void xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:934
@ XML_ERR_PEREF_IN_INT_SUBSET
Definition: xmlerror.h:121
@ XML_ERR_GT_REQUIRED
Definition: xmlerror.h:173

Referenced by xmlParseMarkupDecl().

◆ xmlParseElementMixedContentDecl()

XML_DEPRECATED XMLPUBFUN xmlElementContentPtr xmlParseElementMixedContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

xmlParseElementMixedContentDecl: @ctxt: an XML parser context @inputchk: the input used for the current entity, needed for boundary checks

DEPRECATED: Internal function, don't use.

parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in xmlParseElementContentDecl

[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'

[ VC: Proper Group/PE Nesting ] applies to [51] too (see [49])

[ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.

returns: the list of the xmlElementContentPtr describing the element choices

Definition at line 6264 of file parser.c.

6264 {
6265 xmlElementContentPtr ret = NULL, cur = NULL, n;
6266 const xmlChar *elem = NULL;
6267
6268 GROW;
6269 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6270 SKIP(7);
6272 if (RAW == ')') {
6273 if (ctxt->input->id != inputchk) {
6274 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6275 "Element content declaration doesn't start and"
6276 " stop in the same entity\n");
6277 }
6278 NEXT;
6279 ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
6280 if (ret == NULL)
6281 return(NULL);
6282 if (RAW == '*') {
6283 ret->ocur = XML_ELEMENT_CONTENT_MULT;
6284 NEXT;
6285 }
6286 return(ret);
6287 }
6288 if ((RAW == '(') || (RAW == '|')) {
6289 ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
6290 if (ret == NULL) return(NULL);
6291 }
6292 while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6293 NEXT;
6294 if (elem == NULL) {
6295 ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
6296 if (ret == NULL) {
6297 xmlFreeDocElementContent(ctxt->myDoc, cur);
6298 return(NULL);
6299 }
6300 ret->c1 = cur;
6301 if (cur != NULL)
6302 cur->parent = ret;
6303 cur = ret;
6304 } else {
6305 n = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
6306 if (n == NULL) {
6307 xmlFreeDocElementContent(ctxt->myDoc, ret);
6308 return(NULL);
6309 }
6310 n->c1 = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
6311 if (n->c1 != NULL)
6312 n->c1->parent = n;
6313 cur->c2 = n;
6314 if (n != NULL)
6315 n->parent = cur;
6316 cur = n;
6317 }
6319 elem = xmlParseName(ctxt);
6320 if (elem == NULL) {
6321 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6322 "xmlParseElementMixedContentDecl : Name expected\n");
6323 xmlFreeDocElementContent(ctxt->myDoc, ret);
6324 return(NULL);
6325 }
6327 GROW;
6328 }
6329 if ((RAW == ')') && (NXT(1) == '*')) {
6330 if (elem != NULL) {
6331 cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
6332 XML_ELEMENT_CONTENT_ELEMENT);
6333 if (cur->c2 != NULL)
6334 cur->c2->parent = cur;
6335 }
6336 if (ret != NULL)
6337 ret->ocur = XML_ELEMENT_CONTENT_MULT;
6338 if (ctxt->input->id != inputchk) {
6339 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6340 "Element content declaration doesn't start and"
6341 " stop in the same entity\n");
6342 }
6343 SKIP(2);
6344 } else {
6345 xmlFreeDocElementContent(ctxt->myDoc, ret);
6347 return(NULL);
6348 }
6349
6350 } else {
6352 }
6353 return(ret);
6354}
GLdouble n
Definition: glext.h:7729
static size_t elem
Definition: string.c:71
XMLPUBFUN xmlElementContentPtr xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:753
@ XML_ERR_MIXED_NOT_STARTED
Definition: xmlerror.h:152
@ XML_ERR_PCDATA_REQUIRED
Definition: xmlerror.h:169

Referenced by xmlParseElementContentDecl().

◆ xmlParseEncName()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseEncName ( xmlParserCtxtPtr  ctxt)

xmlParseEncName: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the XML encoding name

[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*

Returns the encoding name value or NULL

Definition at line 10643 of file parser.c.

10643 {
10644 xmlChar *buf = NULL;
10645 int len = 0;
10646 int size = 10;
10647 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
10650 xmlChar cur;
10651
10652 cur = CUR;
10653 if (((cur >= 'a') && (cur <= 'z')) ||
10654 ((cur >= 'A') && (cur <= 'Z'))) {
10656 if (buf == NULL) {
10657 xmlErrMemory(ctxt, NULL);
10658 return(NULL);
10659 }
10660
10661 buf[len++] = cur;
10662 NEXT;
10663 cur = CUR;
10664 while (((cur >= 'a') && (cur <= 'z')) ||
10665 ((cur >= 'A') && (cur <= 'Z')) ||
10666 ((cur >= '0') && (cur <= '9')) ||
10667 (cur == '.') || (cur == '_') ||
10668 (cur == '-')) {
10669 if (len + 1 >= size) {
10670 xmlChar *tmp;
10671
10672 size *= 2;
10673 tmp = (xmlChar *) xmlRealloc(buf, size);
10674 if (tmp == NULL) {
10675 xmlErrMemory(ctxt, NULL);
10676 xmlFree(buf);
10677 return(NULL);
10678 }
10679 buf = tmp;
10680 }
10681 buf[len++] = cur;
10682 if (len > maxLength) {
10683 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "EncName");
10684 xmlFree(buf);
10685 return(NULL);
10686 }
10687 NEXT;
10688 cur = CUR;
10689 }
10690 buf[len] = 0;
10691 } else {
10693 }
10694 return(buf);
10695}
#define XML_MAX_NAME_LENGTH
@ XML_ERR_ENCODING_NAME
Definition: xmlerror.h:179
@ XML_ERR_NAME_TOO_LONG
Definition: xmlerror.h:210

Referenced by xmlParseEncodingDecl().

◆ xmlParseEncodingDecl()

XML_DEPRECATED XMLPUBFUN const xmlChar * xmlParseEncodingDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEncodingDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the XML encoding declaration

[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'")

this setups the conversion filters.

Returns the encoding value or NULL

Definition at line 10713 of file parser.c.

10713 {
10714 xmlChar *encoding = NULL;
10715
10717 if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g') == 0)
10718 return(NULL);
10719
10720 SKIP(8);
10722 if (RAW != '=') {
10724 return(NULL);
10725 }
10726 NEXT;
10728 if (RAW == '"') {
10729 NEXT;
10730 encoding = xmlParseEncName(ctxt);
10731 if (RAW != '"') {
10733 xmlFree((xmlChar *) encoding);
10734 return(NULL);
10735 } else
10736 NEXT;
10737 } else if (RAW == '\''){
10738 NEXT;
10739 encoding = xmlParseEncName(ctxt);
10740 if (RAW != '\'') {
10742 xmlFree((xmlChar *) encoding);
10743 return(NULL);
10744 } else
10745 NEXT;
10746 } else {
10748 }
10749
10750 if (encoding == NULL)
10751 return(NULL);
10752
10753 xmlSetDeclaredEncoding(ctxt, encoding);
10754
10755 return(ctxt->encoding);
10756}
XML_HIDDEN void xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding)
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10643
@ XML_ERR_STRING_NOT_CLOSED
Definition: xmlerror.h:134
@ XML_ERR_STRING_NOT_STARTED
Definition: xmlerror.h:133
@ XML_ERR_EQUAL_REQUIRED
Definition: xmlerror.h:175

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseEntityDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseEntityDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEntityDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse an entity declaration. Always consumes '<!'.

[70] EntityDecl ::= GEDecl | PEDecl

[71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'

[72] PEDecl ::= '<!ENTITY' S '' S Name S PEDef S? '>'

[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)

[74] PEDef ::= EntityValue | ExternalID

[76] NDataDecl ::= S 'NDATA' S Name

[ VC: Notation Declared ] The Name must match the declared name of a notation.

Definition at line 5551 of file parser.c.

5551 {
5552 const xmlChar *name = NULL;
5553 xmlChar *value = NULL;
5554 xmlChar *URI = NULL, *literal = NULL;
5555 const xmlChar *ndata = NULL;
5556 int isParameter = 0;
5557 xmlChar *orig = NULL;
5558
5559 if ((CUR != '<') || (NXT(1) != '!'))
5560 return;
5561 SKIP(2);
5562
5563 /* GROW; done in the caller */
5564 if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5565 int inputid = ctxt->input->id;
5566 SKIP(6);
5567 if (SKIP_BLANKS == 0) {
5568 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5569 "Space required after '<!ENTITY'\n");
5570 }
5571
5572 if (RAW == '%') {
5573 NEXT;
5574 if (SKIP_BLANKS == 0) {
5575 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5576 "Space required after '%%'\n");
5577 }
5578 isParameter = 1;
5579 }
5580
5581 name = xmlParseName(ctxt);
5582 if (name == NULL) {
5583 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5584 "xmlParseEntityDecl: no name\n");
5585 return;
5586 }
5587 if (xmlStrchr(name, ':') != NULL) {
5588 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5589 "colons are forbidden from entities names '%s'\n",
5590 name, NULL, NULL);
5591 }
5592 if (SKIP_BLANKS == 0) {
5593 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5594 "Space required after the entity name\n");
5595 }
5596
5597 ctxt->instate = XML_PARSER_ENTITY_DECL;
5598 /*
5599 * handle the various case of definitions...
5600 */
5601 if (isParameter) {
5602 if ((RAW == '"') || (RAW == '\'')) {
5603 value = xmlParseEntityValue(ctxt, &orig);
5604 if (value) {
5605 if ((ctxt->sax != NULL) &&
5606 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5607 ctxt->sax->entityDecl(ctxt->userData, name,
5609 NULL, NULL, value);
5610 }
5611 } else {
5612 URI = xmlParseExternalID(ctxt, &literal, 1);
5613 if ((URI == NULL) && (literal == NULL)) {
5615 }
5616 if (URI) {
5617 xmlURIPtr uri;
5618
5619 uri = xmlParseURI((const char *) URI);
5620 if (uri == NULL) {
5621 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5622 "Invalid URI: %s\n", URI);
5623 /*
5624 * This really ought to be a well formedness error
5625 * but the XML Core WG decided otherwise c.f. issue
5626 * E26 of the XML erratas.
5627 */
5628 } else {
5629 if (uri->fragment != NULL) {
5630 /*
5631 * Okay this is foolish to block those but not
5632 * invalid URIs.
5633 */
5635 } else {
5636 if ((ctxt->sax != NULL) &&
5637 (!ctxt->disableSAX) &&
5638 (ctxt->sax->entityDecl != NULL))
5639 ctxt->sax->entityDecl(ctxt->userData, name,
5641 literal, URI, NULL);
5642 }
5643 xmlFreeURI(uri);
5644 }
5645 }
5646 }
5647 } else {
5648 if ((RAW == '"') || (RAW == '\'')) {
5649 value = xmlParseEntityValue(ctxt, &orig);
5650 if ((ctxt->sax != NULL) &&
5651 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5652 ctxt->sax->entityDecl(ctxt->userData, name,
5654 NULL, NULL, value);
5655 /*
5656 * For expat compatibility in SAX mode.
5657 */
5658 if ((ctxt->myDoc == NULL) ||
5659 (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) {
5660 if (ctxt->myDoc == NULL) {
5661 ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5662 if (ctxt->myDoc == NULL) {
5663 xmlErrMemory(ctxt, "New Doc failed");
5664 goto done;
5665 }
5666 ctxt->myDoc->properties = XML_DOC_INTERNAL;
5667 }
5668 if (ctxt->myDoc->intSubset == NULL)
5669 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5670 BAD_CAST "fake", NULL, NULL);
5671
5673 NULL, NULL, value);
5674 }
5675 } else {
5676 URI = xmlParseExternalID(ctxt, &literal, 1);
5677 if ((URI == NULL) && (literal == NULL)) {
5679 }
5680 if (URI) {
5681 xmlURIPtr uri;
5682
5683 uri = xmlParseURI((const char *)URI);
5684 if (uri == NULL) {
5685 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5686 "Invalid URI: %s\n", URI);
5687 /*
5688 * This really ought to be a well formedness error
5689 * but the XML Core WG decided otherwise c.f. issue
5690 * E26 of the XML erratas.
5691 */
5692 } else {
5693 if (uri->fragment != NULL) {
5694 /*
5695 * Okay this is foolish to block those but not
5696 * invalid URIs.
5697 */
5699 }
5700 xmlFreeURI(uri);
5701 }
5702 }
5703 if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5704 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5705 "Space required before 'NDATA'\n");
5706 }
5707 if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5708 SKIP(5);
5709 if (SKIP_BLANKS == 0) {
5710 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5711 "Space required after 'NDATA'\n");
5712 }
5713 ndata = xmlParseName(ctxt);
5714 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5715 (ctxt->sax->unparsedEntityDecl != NULL))
5716 ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5717 literal, URI, ndata);
5718 } else {
5719 if ((ctxt->sax != NULL) &&
5720 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5721 ctxt->sax->entityDecl(ctxt->userData, name,
5723 literal, URI, NULL);
5724 /*
5725 * For expat compatibility in SAX mode.
5726 * assuming the entity replacement was asked for
5727 */
5728 if ((ctxt->replaceEntities != 0) &&
5729 ((ctxt->myDoc == NULL) ||
5730 (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
5731 if (ctxt->myDoc == NULL) {
5732 ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5733 if (ctxt->myDoc == NULL) {
5734 xmlErrMemory(ctxt, "New Doc failed");
5735 goto done;
5736 }
5737 ctxt->myDoc->properties = XML_DOC_INTERNAL;
5738 }
5739
5740 if (ctxt->myDoc->intSubset == NULL)
5741 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5742 BAD_CAST "fake", NULL, NULL);
5743 xmlSAX2EntityDecl(ctxt, name,
5745 literal, URI, NULL);
5746 }
5747 }
5748 }
5749 }
5750 if (ctxt->instate == XML_PARSER_EOF)
5751 goto done;
5753 if (RAW != '>') {
5754 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
5755 "xmlParseEntityDecl: entity %s not terminated\n", name);
5756 xmlHaltParser(ctxt);
5757 } else {
5758 if (inputid != ctxt->input->id) {
5759 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5760 "Entity declaration doesn't start and stop in"
5761 " the same entity\n");
5762 }
5763 NEXT;
5764 }
5765 if (orig != NULL) {
5766 /*
5767 * Ugly mechanism to save the raw entity value.
5768 */
5769 xmlEntityPtr cur = NULL;
5770
5771 if (isParameter) {
5772 if ((ctxt->sax != NULL) &&
5773 (ctxt->sax->getParameterEntity != NULL))
5774 cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
5775 } else {
5776 if ((ctxt->sax != NULL) &&
5777 (ctxt->sax->getEntity != NULL))
5778 cur = ctxt->sax->getEntity(ctxt->userData, name);
5779 if ((cur == NULL) && (ctxt->userData==ctxt)) {
5780 cur = xmlSAX2GetEntity(ctxt, name);
5781 }
5782 }
5783 if ((cur != NULL) && (cur->orig == NULL)) {
5784 cur->orig = orig;
5785 orig = NULL;
5786 }
5787 }
5788
5789done:
5790 if (value != NULL) xmlFree(value);
5791 if (URI != NULL) xmlFree(URI);
5792 if (literal != NULL) xmlFree(literal);
5793 if (orig != NULL) xmlFree(orig);
5794 }
5795}
XMLPUBFUN void xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:588
XMLPUBFUN xmlEntityPtr xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:518
const char * uri
Definition: sec_mgr.c:1588
@ XML_PARSER_ENTITY_DECL
Definition: parser.h:127
xmlChar * xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig)
Definition: parser.c:3906
#define SAX_COMPAT_MODE
Definition: parser.c:168
Definition: uri.h:34
XMLPUBFUN void xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1396
XMLPUBFUN xmlURIPtr xmlParseURI(const char *str)
Definition: uri.c:947
@ XML_ERR_ENTITY_NOT_FINISHED
Definition: xmlerror.h:137
@ XML_ERR_INVALID_URI
Definition: xmlerror.h:191
@ XML_ERR_URI_FRAGMENT
Definition: xmlerror.h:192
@ XML_ERR_VALUE_REQUIRED
Definition: xmlerror.h:184
@ XML_NS_ERR_COLON
Definition: xmlerror.h:219
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
XMLPUBFUN const xmlChar * xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:327

Referenced by xmlParseMarkupDecl().

◆ xmlParseEntityRef()

XML_DEPRECATED XMLPUBFUN xmlEntityPtr xmlParseEntityRef ( xmlParserCtxtPtr  ctxt)

xmlParseEntityRef: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse an entitiy reference. Always consumes '&'.

[68] EntityRef ::= '&' Name ';'

[ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any reference to it. Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'.

[ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity

Returns the xmlEntityPtr if found, or NULL otherwise.

Definition at line 7683 of file parser.c.

7683 {
7684 const xmlChar *name;
7685 xmlEntityPtr ent = NULL;
7686
7687 GROW;
7688 if (ctxt->instate == XML_PARSER_EOF)
7689 return(NULL);
7690
7691 if (RAW != '&')
7692 return(NULL);
7693 NEXT;
7694 name = xmlParseName(ctxt);
7695 if (name == NULL) {
7696 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
7697 "xmlParseEntityRef: no name\n");
7698 return(NULL);
7699 }
7700 if (RAW != ';') {
7702 return(NULL);
7703 }
7704 NEXT;
7705
7706 /*
7707 * Predefined entities override any extra definition
7708 */
7709 if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
7711 if (ent != NULL)
7712 return(ent);
7713 }
7714
7715 /*
7716 * Ask first SAX for entity resolution, otherwise try the
7717 * entities which may have stored in the parser context.
7718 */
7719 if (ctxt->sax != NULL) {
7720 if (ctxt->sax->getEntity != NULL)
7721 ent = ctxt->sax->getEntity(ctxt->userData, name);
7722 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7723 (ctxt->options & XML_PARSE_OLDSAX))
7725 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7726 (ctxt->userData==ctxt)) {
7727 ent = xmlSAX2GetEntity(ctxt, name);
7728 }
7729 }
7730 if (ctxt->instate == XML_PARSER_EOF)
7731 return(NULL);
7732 /*
7733 * [ WFC: Entity Declared ]
7734 * In a document without any DTD, a document with only an
7735 * internal DTD subset which contains no parameter entity
7736 * references, or a document with "standalone='yes'", the
7737 * Name given in the entity reference must match that in an
7738 * entity declaration, except that well-formed documents
7739 * need not declare any of the following entities: amp, lt,
7740 * gt, apos, quot.
7741 * The declaration of a parameter entity must precede any
7742 * reference to it.
7743 * Similarly, the declaration of a general entity must
7744 * precede any reference to it which appears in a default
7745 * value in an attribute-list declaration. Note that if
7746 * entities are declared in the external subset or in
7747 * external parameter entities, a non-validating processor
7748 * is not obligated to read and process their declarations;
7749 * for such documents, the rule that an entity must be
7750 * declared is a well-formedness constraint only if
7751 * standalone='yes'.
7752 */
7753 if (ent == NULL) {
7754 if ((ctxt->standalone == 1) ||
7755 ((ctxt->hasExternalSubset == 0) &&
7756 (ctxt->hasPErefs == 0))) {
7757 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7758 "Entity '%s' not defined\n", name);
7759 } else {
7760 xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
7761 "Entity '%s' not defined\n", name);
7762 if ((ctxt->inSubset == 0) &&
7763 (ctxt->sax != NULL) &&
7764 (ctxt->disableSAX == 0) &&
7765 (ctxt->sax->reference != NULL)) {
7766 ctxt->sax->reference(ctxt->userData, name);
7767 }
7768 }
7769 ctxt->valid = 0;
7770 }
7771
7772 /*
7773 * [ WFC: Parsed Entity ]
7774 * An entity reference must not contain the name of an
7775 * unparsed entity
7776 */
7777 else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
7778 xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
7779 "Entity reference to unparsed entity %s\n", name);
7780 }
7781
7782 /*
7783 * [ WFC: No External Entity References ]
7784 * Attribute values cannot contain direct or indirect
7785 * entity references to external entities.
7786 */
7787 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7788 (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
7789 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
7790 "Attribute references external entity '%s'\n", name);
7791 }
7792 /*
7793 * [ WFC: No < in Attribute Values ]
7794 * The replacement text of any entity referred to directly or
7795 * indirectly in an attribute value (other than "&lt;") must
7796 * not contain a <.
7797 */
7798 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7799 (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
7800 if ((ent->flags & XML_ENT_CHECKED_LT) == 0) {
7801 if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
7802 ent->flags |= XML_ENT_CONTAINS_LT;
7803 ent->flags |= XML_ENT_CHECKED_LT;
7804 }
7805 if (ent->flags & XML_ENT_CONTAINS_LT)
7806 xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
7807 "'<' in entity '%s' is not allowed in attributes "
7808 "values\n", name);
7809 }
7810
7811 /*
7812 * Internal check, no parameter entities here ...
7813 */
7814 else {
7815 switch (ent->etype) {
7818 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
7819 "Attempt to reference the parameter entity '%s'\n",
7820 name);
7821 break;
7822 default:
7823 break;
7824 }
7825 }
7826
7827 /*
7828 * [ WFC: No Recursion ]
7829 * A parsed entity must not contain a recursive reference
7830 * to itself, either directly or indirectly.
7831 * Done somewhere else
7832 */
7833 return(ent);
7834}
XMLPUBFUN xmlEntityPtr xmlGetPredefinedEntity(const xmlChar *name)
#define XML_ENT_CONTAINS_LT
Definition: entities.h:18
#define XML_ENT_CHECKED_LT
Definition: entities.h:17
@ XML_PARSER_ATTRIBUTE_VALUE
Definition: parser.h:129
@ XML_PARSE_OLDSAX
Definition: parser.h:1252
@ XML_ERR_ENTITYREF_SEMICOL_MISSING
Definition: xmlerror.h:123
@ XML_ERR_LT_IN_ATTRIBUTE
Definition: xmlerror.h:138
@ XML_WAR_UNDECLARED_ENTITY
Definition: xmlerror.h:127
@ XML_ERR_ENTITY_IS_PARAMETER
Definition: xmlerror.h:130
@ XML_ERR_ENTITY_IS_EXTERNAL
Definition: xmlerror.h:129
@ XML_ERR_UNDECLARED_ENTITY
Definition: xmlerror.h:126
@ XML_ERR_UNPARSED_ENTITY
Definition: xmlerror.h:128

Referenced by xmlParseAttValueComplex(), and xmlParseReference().

◆ xmlParseEntityValue()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseEntityValue ( xmlParserCtxtPtr  ctxt,
xmlChar **  orig 
)

xmlParseEntityValue: @ctxt: an XML parser context @orig: if non-NULL store a copy of the original entity value

DEPRECATED: Internal function, don't use.

parse a value for ENTITY declarations

[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'"

Returns the EntityValue parsed with reference substituted or NULL

Definition at line 3906 of file parser.c.

3906 {
3907 xmlChar *buf = NULL;
3908 int len = 0;
3910 int c, l;
3911 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3914 xmlChar stop;
3915 xmlChar *ret = NULL;
3916 const xmlChar *cur = NULL;
3917 xmlParserInputPtr input;
3918
3919 if (RAW == '"') stop = '"';
3920 else if (RAW == '\'') stop = '\'';
3921 else {
3923 return(NULL);
3924 }
3926 if (buf == NULL) {
3927 xmlErrMemory(ctxt, NULL);
3928 return(NULL);
3929 }
3930
3931 /*
3932 * The content of the entity definition is copied in a buffer.
3933 */
3934
3935 ctxt->instate = XML_PARSER_ENTITY_VALUE;
3936 input = ctxt->input;
3937 GROW;
3938 if (ctxt->instate == XML_PARSER_EOF)
3939 goto error;
3940 NEXT;
3941 c = CUR_CHAR(l);
3942 /*
3943 * NOTE: 4.4.5 Included in Literal
3944 * When a parameter entity reference appears in a literal entity
3945 * value, ... a single or double quote character in the replacement
3946 * text is always treated as a normal data character and will not
3947 * terminate the literal.
3948 * In practice it means we stop the loop only when back at parsing
3949 * the initial entity and the quote is found
3950 */
3951 while (((IS_CHAR(c)) && ((c != stop) || /* checked */
3952 (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) {
3953 if (len + 5 >= size) {
3954 xmlChar *tmp;
3955
3956 size *= 2;
3957 tmp = (xmlChar *) xmlRealloc(buf, size);
3958 if (tmp == NULL) {
3959 xmlErrMemory(ctxt, NULL);
3960 goto error;
3961 }
3962 buf = tmp;
3963 }
3964 COPY_BUF(buf, len, c);
3965 NEXTL(l);
3966
3967 GROW;
3968 c = CUR_CHAR(l);
3969 if (c == 0) {
3970 GROW;
3971 c = CUR_CHAR(l);
3972 }
3973
3974 if (len > maxLength) {
3975 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
3976 "entity value too long\n");
3977 goto error;
3978 }
3979 }
3980 buf[len] = 0;
3981 if (ctxt->instate == XML_PARSER_EOF)
3982 goto error;
3983 if (c != stop) {
3985 goto error;
3986 }
3987 NEXT;
3988
3989 /*
3990 * Raise problem w.r.t. '&' and '%' being used in non-entities
3991 * reference constructs. Note Charref will be handled in
3992 * xmlStringDecodeEntities()
3993 */
3994 cur = buf;
3995 while (*cur != 0) { /* non input consuming */
3996 if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) {
3997 xmlChar *name;
3998 xmlChar tmp = *cur;
3999 int nameOk = 0;
4000
4001 cur++;
4002 name = xmlParseStringName(ctxt, &cur);
4003 if (name != NULL) {
4004 nameOk = 1;
4005 xmlFree(name);
4006 }
4007 if ((nameOk == 0) || (*cur != ';')) {
4008 xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR,
4009 "EntityValue: '%c' forbidden except for entities references\n",
4010 tmp);
4011 goto error;
4012 }
4013 if ((tmp == '%') && (ctxt->inSubset == 1) &&
4014 (ctxt->inputNr == 1)) {
4016 goto error;
4017 }
4018 if (*cur == 0)
4019 break;
4020 }
4021 cur++;
4022 }
4023
4024 /*
4025 * Then PEReference entities are substituted.
4026 *
4027 * NOTE: 4.4.7 Bypassed
4028 * When a general entity reference appears in the EntityValue in
4029 * an entity declaration, it is bypassed and left as is.
4030 * so XML_SUBSTITUTE_REF is not set here.
4031 */
4032 ++ctxt->depth;
4034 0, 0, 0, /* check */ 1);
4035 --ctxt->depth;
4036
4037 if (orig != NULL) {
4038 *orig = buf;
4039 buf = NULL;
4040 }
4041
4042error:
4043 if (buf != NULL)
4044 xmlFree(buf);
4045 return(ret);
4046}
#define error(str)
Definition: mkdosfs.c:1605
#define XML_SUBSTITUTE_PEREF
@ XML_PARSER_ENTITY_VALUE
Definition: parser.h:128
static xmlChar * xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:3735
static xmlChar * xmlStringDecodeEntitiesInt(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3, int check)
Definition: parser.c:2801
@ XML_ERR_ENTITY_PE_INTERNAL
Definition: xmlerror.h:188
@ XML_ERR_ENTITY_CHAR_ERROR
Definition: xmlerror.h:187
@ XML_ERR_ENTITY_NOT_STARTED
Definition: xmlerror.h:136

Referenced by xmlParseEntityDecl().

◆ xmlParseEnumeratedType()

XML_DEPRECATED XMLPUBFUN int xmlParseEnumeratedType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr *  tree 
)

xmlParseEnumeratedType: @ctxt: an XML parser context @tree: the enumeration tree built while parsing

DEPRECATED: Internal function, don't use.

parse an Enumerated attribute type.

[57] EnumeratedType ::= NotationType | Enumeration

[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'

Returns: XML_ATTRIBUTE_ENUMERATION or XML_ATTRIBUTE_NOTATION

Definition at line 6022 of file parser.c.

6022 {
6023 if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
6024 SKIP(8);
6025 if (SKIP_BLANKS == 0) {
6026 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6027 "Space required after 'NOTATION'\n");
6028 return(0);
6029 }
6030 *tree = xmlParseNotationType(ctxt);
6031 if (*tree == NULL) return(0);
6032 return(XML_ATTRIBUTE_NOTATION);
6033 }
6035 if (*tree == NULL) return(0);
6036 return(XML_ATTRIBUTE_ENUMERATION);
6037}
xmlEnumerationPtr xmlParseNotationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5881
xmlEnumerationPtr xmlParseEnumerationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5952

Referenced by xmlParseAttributeType().

◆ xmlParseEnumerationType()

XML_DEPRECATED XMLPUBFUN xmlEnumerationPtr xmlParseEnumerationType ( xmlParserCtxtPtr  ctxt)

xmlParseEnumerationType: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an Enumeration attribute type.

[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'

[ VC: Enumeration ] Values of this type must match one of the Nmtoken tokens in the declaration

Returns: the enumeration attribute tree built while parsing

Definition at line 5952 of file parser.c.

5952 {
5953 xmlChar *name;
5954 xmlEnumerationPtr ret = NULL, last = NULL, cur, tmp;
5955
5956 if (RAW != '(') {
5958 return(NULL);
5959 }
5960 do {
5961 NEXT;
5963 name = xmlParseNmtoken(ctxt);
5964 if (name == NULL) {
5966 return(ret);
5967 }
5968 tmp = ret;
5969 while (tmp != NULL) {
5970 if (xmlStrEqual(name, tmp->name)) {
5971 xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
5972 "standalone: attribute enumeration value token %s duplicated\n",
5973 name, NULL);
5974 if (!xmlDictOwns(ctxt->dict, name))
5975 xmlFree(name);
5976 break;
5977 }
5978 tmp = tmp->next;
5979 }
5980 if (tmp == NULL) {
5982 if (!xmlDictOwns(ctxt->dict, name))
5983 xmlFree(name);
5984 if (cur == NULL) {
5986 return(NULL);
5987 }
5988 if (last == NULL) ret = last = cur;
5989 else {
5990 last->next = cur;
5991 last = cur;
5992 }
5993 }
5995 } while (RAW == '|');
5996 if (RAW != ')') {
5998 return(ret);
5999 }
6000 NEXT;
6001 return(ret);
6002}
static UINT UINT last
Definition: font.c:45
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:376
xmlChar * xmlParseNmtoken(xmlParserCtxtPtr ctxt)
Definition: parser.c:3821
WCHAR * name
Definition: name.c:42
XMLPUBFUN xmlEnumerationPtr xmlCreateEnumeration(const xmlChar *name)
Definition: valid.c:1640
@ XML_ERR_ATTLIST_NOT_STARTED
Definition: xmlerror.h:150
@ XML_DTD_DUP_TOKEN
Definition: xmlerror.h:261
@ XML_ERR_NMTOKEN_REQUIRED
Definition: xmlerror.h:167
@ XML_ERR_ATTLIST_NOT_FINISHED
Definition: xmlerror.h:151

Referenced by xmlParseEnumeratedType().

◆ xmlParseExternalID()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseExternalID ( xmlParserCtxtPtr  ctxt,
xmlChar **  publicID,
int  strict 
)

xmlParseExternalID: @ctxt: an XML parser context @publicID: a xmlChar** receiving PubidLiteral @strict: indicate whether we should restrict parsing to only production [75], see NOTE below

DEPRECATED: Internal function, don't use.

Parse an External ID or a Public ID

NOTE: Productions [75] and [83] interact badly since [75] can generate 'PUBLIC' S PubidLiteral S SystemLiteral

[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral

[83] PublicID ::= 'PUBLIC' S PubidLiteral

Returns the function returns SystemLiteral and in the second case publicID receives PubidLiteral, is strict is off it is possible to return NULL and have publicID set.

Definition at line 4840 of file parser.c.

4840 {
4841 xmlChar *URI = NULL;
4842
4843 *publicID = NULL;
4844 if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
4845 SKIP(6);
4846 if (SKIP_BLANKS == 0) {
4847 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4848 "Space required after 'SYSTEM'\n");
4849 }
4850 URI = xmlParseSystemLiteral(ctxt);
4851 if (URI == NULL) {
4853 }
4854 } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) {
4855 SKIP(6);
4856 if (SKIP_BLANKS == 0) {
4857 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4858 "Space required after 'PUBLIC'\n");
4859 }
4860 *publicID = xmlParsePubidLiteral(ctxt);
4861 if (*publicID == NULL) {
4863 }
4864 if (strict) {
4865 /*
4866 * We don't handle [83] so "S SystemLiteral" is required.
4867 */
4868 if (SKIP_BLANKS == 0) {
4869 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4870 "Space required after the Public Identifier\n");
4871 }
4872 } else {
4873 /*
4874 * We handle [83] so we return immediately, if
4875 * "S SystemLiteral" is not detected. We skip blanks if no
4876 * system literal was found, but this is harmless since we must
4877 * be at the end of a NotationDecl.
4878 */
4879 if (SKIP_BLANKS == 0) return(NULL);
4880 if ((CUR != '\'') && (CUR != '"')) return(NULL);
4881 }
4882 URI = xmlParseSystemLiteral(ctxt);
4883 if (URI == NULL) {
4885 }
4886 }
4887 return(URI);
4888}
static int strict
Definition: error.c:51
xmlChar * xmlParsePubidLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4442
xmlChar * xmlParseSystemLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4361
@ XML_ERR_PUBID_REQUIRED
Definition: xmlerror.h:171
@ XML_ERR_URI_REQUIRED
Definition: xmlerror.h:170

Referenced by xmlParseDocTypeDecl(), xmlParseEntityDecl(), and xmlParseNotationDecl().

◆ xmlParseExternalSubset()

XMLPUBFUN void xmlParseExternalSubset ( xmlParserCtxtPtr  ctxt,
const xmlChar ExternalID,
const xmlChar SystemID 
)

xmlParseExternalSubset: @ctxt: an XML parser context @ExternalID: the external identifier @SystemID: the system identifier (or URL)

parse Markup declarations from an external subset

[30] extSubset ::= textDecl? extSubsetDecl

[31] extSubsetDecl ::= (markupdecl | conditionalSect | PEReference | S) *

Definition at line 7160 of file parser.c.

7161 {
7162 xmlDetectSAX2(ctxt);
7163
7164 xmlDetectEncoding(ctxt);
7165
7166 if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
7167 xmlParseTextDecl(ctxt);
7168 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
7169 /*
7170 * The XML REC instructs us to stop parsing right here
7171 */
7172 xmlHaltParser(ctxt);
7173 return;
7174 }
7175 }
7176 if (ctxt->myDoc == NULL) {
7177 ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
7178 if (ctxt->myDoc == NULL) {
7179 xmlErrMemory(ctxt, "New Doc failed");
7180 return;
7181 }
7182 ctxt->myDoc->properties = XML_DOC_INTERNAL;
7183 }
7184 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL))
7185 xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID);
7186
7187 ctxt->instate = XML_PARSER_DTD;
7188 ctxt->external = 1;
7190 while ((ctxt->instate != XML_PARSER_EOF) && (RAW != 0)) {
7191 GROW;
7192 if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
7194 } else if ((RAW == '<') && ((NXT(1) == '!') || (NXT(1) == '?'))) {
7195 xmlParseMarkupDecl(ctxt);
7196 } else {
7198 xmlHaltParser(ctxt);
7199 return;
7200 }
7202 SHRINK;
7203 }
7204
7205 if (RAW != 0) {
7207 }
7208
7209}
XML_HIDDEN void xmlDetectEncoding(xmlParserCtxtPtr ctxt)
static void xmlParseConditionalSections(xmlParserCtxtPtr ctxt)
Definition: parser.c:6873
void xmlParseTextDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:7074
void xmlParseMarkupDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:7020
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:856
@ XML_ERR_EXT_SUBSET_NOT_FINISHED
Definition: xmlerror.h:160
@ XML_ERR_UNSUPPORTED_ENCODING
Definition: xmlerror.h:132

Referenced by xmlSAX2ExternalSubset().

◆ xmlParseMarkupDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseMarkupDecl ( xmlParserCtxtPtr  ctxt)

xmlParseMarkupDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse markup declarations. Always consumes '<!' or '<?'.

[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment

[ VC: Proper Declaration/PE Nesting ] Parameter-entity replacement text must be properly nested with markup declarations. That is to say, if either the first character or the last character of a markup declaration (markupdecl above) is contained in the replacement text for a parameter-entity reference, both must be contained in the same replacement text.

[ WFC: PEs in Internal Subset ] In the internal DTD subset, parameter-entity references can occur only where markup declarations can occur, not within markup declarations. (This does not apply to references that occur in external parameter entities or to the external subset.)

Definition at line 7020 of file parser.c.

7020 {
7021 GROW;
7022 if (CUR == '<') {
7023 if (NXT(1) == '!') {
7024 switch (NXT(2)) {
7025 case 'E':
7026 if (NXT(3) == 'L')
7027 xmlParseElementDecl(ctxt);
7028 else if (NXT(3) == 'N')
7029 xmlParseEntityDecl(ctxt);
7030 else
7031 SKIP(2);
7032 break;
7033 case 'A':
7035 break;
7036 case 'N':
7038 break;
7039 case '-':
7040 xmlParseComment(ctxt);
7041 break;
7042 default:
7043 /* there is an error but it will be detected later */
7044 SKIP(2);
7045 break;
7046 }
7047 } else if (NXT(1) == '?') {
7048 xmlParsePI(ctxt);
7049 }
7050 }
7051
7052 /*
7053 * detect requirement to exit there and act accordingly
7054 * and avoid having instate overridden later on
7055 */
7056 if (ctxt->instate == XML_PARSER_EOF)
7057 return;
7058
7059 ctxt->instate = XML_PARSER_DTD;
7060}
void xmlParsePI(xmlParserCtxtPtr ctxt)
Definition: parser.c:5322
int xmlParseElementDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6762
void xmlParseEntityDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5551
void xmlParseComment(xmlParserCtxtPtr ctxt)
Definition: parser.c:5034
void xmlParseNotationDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5468
void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6130

Referenced by xmlParseConditionalSections(), xmlParseExternalSubset(), and xmlParseInternalSubset().

◆ xmlParseMisc()

XML_DEPRECATED XMLPUBFUN void xmlParseMisc ( xmlParserCtxtPtr  ctxt)

xmlParseMisc: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML Misc* optional field.

[27] Misc ::= Comment | PI | S

Definition at line 10979 of file parser.c.

10979 {
10980 while (ctxt->instate != XML_PARSER_EOF) {
10982 GROW;
10983 if ((RAW == '<') && (NXT(1) == '?')) {
10984 xmlParsePI(ctxt);
10985 } else if (CMP4(CUR_PTR, '<', '!', '-', '-')) {
10986 xmlParseComment(ctxt);
10987 } else {
10988 break;
10989 }
10990 }
10991}
#define CMP4(s, c1, c2, c3, c4)
Definition: parser.c:2232

Referenced by xmlParseDocument().

◆ xmlParseName()

XML_DEPRECATED XMLPUBFUN const xmlChar * xmlParseName ( xmlParserCtxtPtr  ctxt)

Generic production rules.

xmlParseName: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML name.

[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender

[5] Name ::= (Letter | '_' | ':') (NameChar)*

[6] Names ::= Name (#x20 Name)*

Returns the Name parsed or NULL

Definition at line 3529 of file parser.c.

3529 {
3530 const xmlChar *in;
3531 const xmlChar *ret;
3532 size_t count = 0;
3533 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3536
3537 GROW;
3538 if (ctxt->instate == XML_PARSER_EOF)
3539 return(NULL);
3540
3541 /*
3542 * Accelerator for simple ASCII names
3543 */
3544 in = ctxt->input->cur;
3545 if (((*in >= 0x61) && (*in <= 0x7A)) ||
3546 ((*in >= 0x41) && (*in <= 0x5A)) ||
3547 (*in == '_') || (*in == ':')) {
3548 in++;
3549 while (((*in >= 0x61) && (*in <= 0x7A)) ||
3550 ((*in >= 0x41) && (*in <= 0x5A)) ||
3551 ((*in >= 0x30) && (*in <= 0x39)) ||
3552 (*in == '_') || (*in == '-') ||
3553 (*in == ':') || (*in == '.'))
3554 in++;
3555 if ((*in > 0) && (*in < 0x80)) {
3556 count = in - ctxt->input->cur;
3557 if (count > maxLength) {
3558 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
3559 return(NULL);
3560 }
3561 ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
3562 ctxt->input->cur = in;
3563 ctxt->input->col += count;
3564 if (ret == NULL)
3565 xmlErrMemory(ctxt, NULL);
3566 return(ret);
3567 }
3568 }
3569 /* accelerator for special cases */
3570 return(xmlParseNameComplex(ctxt));
3571}
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
static const xmlChar * xmlParseNameComplex(xmlParserCtxtPtr ctxt)
Definition: parser.c:3404

Referenced by xmlParseAttributeListDecl(), xmlParseDocTypeDecl(), xmlParseElementChildrenContentDeclPriv(), xmlParseElementDecl(), xmlParseElementMixedContentDecl(), xmlParseEntityDecl(), xmlParseEntityRef(), xmlParseNameAndCompare(), xmlParseNotationDecl(), xmlParseNotationType(), xmlParsePEReference(), and xmlParsePITarget().

◆ xmlParseNmtoken()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseNmtoken ( xmlParserCtxtPtr  ctxt)

xmlParseNmtoken: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML Nmtoken.

[7] Nmtoken ::= (NameChar)+

[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*

Returns the Nmtoken parsed or NULL

Definition at line 3821 of file parser.c.

3821 {
3823 int len = 0, l;
3824 int c;
3825 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3828
3829 c = CUR_CHAR(l);
3830
3831 while (xmlIsNameChar(ctxt, c)) {
3832 COPY_BUF(buf, len, c);
3833 NEXTL(l);
3834 c = CUR_CHAR(l);
3835 if (len >= XML_MAX_NAMELEN) {
3836 /*
3837 * Okay someone managed to make a huge token, so he's ready to pay
3838 * for the processing speed.
3839 */
3840 xmlChar *buffer;
3841 int max = len * 2;
3842
3844 if (buffer == NULL) {
3845 xmlErrMemory(ctxt, NULL);
3846 return(NULL);
3847 }
3848 memcpy(buffer, buf, len);
3849 while (xmlIsNameChar(ctxt, c)) {
3850 if (len + 10 > max) {
3851 xmlChar *tmp;
3852
3853 max *= 2;
3854 tmp = (xmlChar *) xmlRealloc(buffer, max);
3855 if (tmp == NULL) {
3856 xmlErrMemory(ctxt, NULL);
3857 xmlFree(buffer);
3858 return(NULL);
3859 }
3860 buffer = tmp;
3861 }
3862 COPY_BUF(buffer, len, c);
3863 if (len > maxLength) {
3864 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
3865 xmlFree(buffer);
3866 return(NULL);
3867 }
3868 NEXTL(l);
3869 c = CUR_CHAR(l);
3870 }
3871 buffer[len] = 0;
3872 if (ctxt->instate == XML_PARSER_EOF) {
3873 xmlFree(buffer);
3874 return(NULL);
3875 }
3876 return(buffer);
3877 }
3878 }
3879 if (ctxt->instate == XML_PARSER_EOF)
3880 return(NULL);
3881 if (len == 0)
3882 return(NULL);
3883 if (len > maxLength) {
3884 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
3885 return(NULL);
3886 }
3887 return(xmlStrndup(buf, len));
3888}
#define XML_MAX_NAMELEN
static int xmlIsNameChar(xmlParserCtxtPtr ctxt, int c)
Definition: parser.c:3362
#define max(a, b)
Definition: svc.c:63
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45

Referenced by xmlParseEnumerationType(), and xmlParseQNameHashed().

◆ xmlParseNotationDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseNotationDecl ( xmlParserCtxtPtr  ctxt)

xmlParseNotationDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse a notation declaration. Always consumes '<!'.

[82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'

Hence there is actually 3 choices: 'PUBLIC' S PubidLiteral 'PUBLIC' S PubidLiteral S SystemLiteral and 'SYSTEM' S SystemLiteral

See the NOTE on xmlParseExternalID().

Definition at line 5468 of file parser.c.

5468 {
5469 const xmlChar *name;
5470 xmlChar *Pubid;
5471 xmlChar *Systemid;
5472
5473 if ((CUR != '<') || (NXT(1) != '!'))
5474 return;
5475 SKIP(2);
5476
5477 if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
5478 int inputid = ctxt->input->id;
5479 SKIP(8);
5480 if (SKIP_BLANKS == 0) {
5481 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5482 "Space required after '<!NOTATION'\n");
5483 return;
5484 }
5485
5486 name = xmlParseName(ctxt);
5487 if (name == NULL) {
5489 return;
5490 }
5491 if (xmlStrchr(name, ':') != NULL) {
5492 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5493 "colons are forbidden from notation names '%s'\n",
5494 name, NULL, NULL);
5495 }
5496 if (SKIP_BLANKS == 0) {
5497 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5498 "Space required after the NOTATION name'\n");
5499 return;
5500 }
5501
5502 /*
5503 * Parse the IDs.
5504 */
5505 Systemid = xmlParseExternalID(ctxt, &Pubid, 0);
5507
5508 if (RAW == '>') {
5509 if (inputid != ctxt->input->id) {
5510 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5511 "Notation declaration doesn't start and stop"
5512 " in the same entity\n");
5513 }
5514 NEXT;
5515 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5516 (ctxt->sax->notationDecl != NULL))
5517 ctxt->sax->notationDecl(ctxt->userData, name, Pubid, Systemid);
5518 } else {
5520 }
5521 if (Systemid != NULL) xmlFree(Systemid);
5522 if (Pubid != NULL) xmlFree(Pubid);
5523 }
5524}
@ XML_ERR_NOTATION_NOT_STARTED
Definition: xmlerror.h:148
@ XML_ERR_NOTATION_NOT_FINISHED
Definition: xmlerror.h:149

Referenced by xmlParseMarkupDecl().

◆ xmlParseNotationType()

XML_DEPRECATED XMLPUBFUN xmlEnumerationPtr xmlParseNotationType ( xmlParserCtxtPtr  ctxt)

xmlParseNotationType: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an Notation attribute type.

Note: the leading 'NOTATION' S part has already being parsed...

[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'

[ VC: Notation Attributes ] Values of this type must match one of the notation names included in the declaration; all notation names in the declaration must be declared.

Returns: the notation attribute tree built while parsing

Definition at line 5881 of file parser.c.

5881 {
5882 const xmlChar *name;
5883 xmlEnumerationPtr ret = NULL, last = NULL, cur, tmp;
5884
5885 if (RAW != '(') {
5887 return(NULL);
5888 }
5889 do {
5890 NEXT;
5892 name = xmlParseName(ctxt);
5893 if (name == NULL) {
5894 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5895 "Name expected in NOTATION declaration\n");
5897 return(NULL);
5898 }
5899 tmp = ret;
5900 while (tmp != NULL) {
5901 if (xmlStrEqual(name, tmp->name)) {
5902 xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
5903 "standalone: attribute notation value token %s duplicated\n",
5904 name, NULL);
5905 if (!xmlDictOwns(ctxt->dict, name))
5906 xmlFree((xmlChar *) name);
5907 break;
5908 }
5909 tmp = tmp->next;
5910 }
5911 if (tmp == NULL) {
5913 if (cur == NULL) {
5915 return(NULL);
5916 }
5917 if (last == NULL) ret = last = cur;
5918 else {
5919 last->next = cur;
5920 last = cur;
5921 }
5922 }
5924 } while (RAW == '|');
5925 if (RAW != ')') {
5928 return(NULL);
5929 }
5930 NEXT;
5931 return(ret);
5932}

Referenced by xmlParseEnumeratedType().

◆ xmlParsePEReference()

XML_DEPRECATED XMLPUBFUN void xmlParsePEReference ( xmlParserCtxtPtr  ctxt)

xmlParsePEReference: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

Parse a parameter entity reference. Always consumes ''.

The entity content is handled directly by pushing it's content as a new input stream.

[69] PEReference ::= '' Name ';'

[ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.

[ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any reference to it...

[ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any reference to it...

[ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.

Definition at line 8063 of file parser.c.

8064{
8065 const xmlChar *name;
8066 xmlEntityPtr entity = NULL;
8067 xmlParserInputPtr input;
8068
8069 if (RAW != '%')
8070 return;
8071 NEXT;
8072 name = xmlParseName(ctxt);
8073 if (name == NULL) {
8074 xmlFatalErrMsg(ctxt, XML_ERR_PEREF_NO_NAME, "PEReference: no name\n");
8075 return;
8076 }
8079 "PEReference: %s\n", name);
8080 if (RAW != ';') {
8082 return;
8083 }
8084
8085 NEXT;
8086
8087 /*
8088 * Request the entity from SAX
8089 */
8090 if ((ctxt->sax != NULL) &&
8091 (ctxt->sax->getParameterEntity != NULL))
8092 entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
8093 if (ctxt->instate == XML_PARSER_EOF)
8094 return;
8095 if (entity == NULL) {
8096 /*
8097 * [ WFC: Entity Declared ]
8098 * In a document without any DTD, a document with only an
8099 * internal DTD subset which contains no parameter entity
8100 * references, or a document with "standalone='yes'", ...
8101 * ... The declaration of a parameter entity must precede
8102 * any reference to it...
8103 */
8104 if ((ctxt->standalone == 1) ||
8105 ((ctxt->hasExternalSubset == 0) &&
8106 (ctxt->hasPErefs == 0))) {
8107 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
8108 "PEReference: %%%s; not found\n",
8109 name);
8110 } else {
8111 /*
8112 * [ VC: Entity Declared ]
8113 * In a document with an external subset or external
8114 * parameter entities with "standalone='no'", ...
8115 * ... The declaration of a parameter entity must
8116 * precede any reference to it...
8117 */
8118 if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) {
8119 xmlValidityError(ctxt, XML_WAR_UNDECLARED_ENTITY,
8120 "PEReference: %%%s; not found\n",
8121 name, NULL);
8122 } else
8123 xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
8124 "PEReference: %%%s; not found\n",
8125 name, NULL);
8126 ctxt->valid = 0;
8127 }
8128 } else {
8129 /*
8130 * Internal checking in case the entity quest barfed
8131 */
8132 if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
8134 xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
8135 "Internal: %%%s; is not a parameter entity\n",
8136 name, NULL);
8137 } else {
8138 unsigned long parentConsumed;
8139 xmlEntityPtr oldEnt;
8140
8141 if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
8142 ((ctxt->options & XML_PARSE_NOENT) == 0) &&
8143 ((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
8144 ((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
8145 ((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
8146 (ctxt->replaceEntities == 0) &&
8147 (ctxt->validate == 0))
8148 return;
8149
8152 xmlHaltParser(ctxt);
8153 return;
8154 }
8155
8156 /* Must be computed from old input before pushing new input. */
8157 parentConsumed = ctxt->input->parentConsumed;
8158 oldEnt = ctxt->input->entity;
8159 if ((oldEnt == NULL) ||
8160 ((oldEnt->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
8161 ((oldEnt->flags & XML_ENT_PARSED) == 0))) {
8162 xmlSaturatedAdd(&parentConsumed, ctxt->input->consumed);
8163 xmlSaturatedAddSizeT(&parentConsumed,
8164 ctxt->input->cur - ctxt->input->base);
8165 }
8166
8168 if (xmlPushInput(ctxt, input) < 0) {
8170 return;
8171 }
8172
8174
8175 input->parentConsumed = parentConsumed;
8176
8177 if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {
8178 xmlDetectEncoding(ctxt);
8179
8180 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
8181 (IS_BLANK_CH(NXT(5)))) {
8182 xmlParseTextDecl(ctxt);
8183 }
8184 }
8185 }
8186 }
8187 ctxt->hasPErefs = 1;
8188}
XML_DEPRECATED XMLPUBFUN xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
XMLPUBFUN void xmlFreeInputStream(xmlParserInputPtr input)
#define IS_BLANK_CH(c)
#define XML_ENT_EXPANDING
Definition: entities.h:16
#define XML_ENT_PARSED
Definition: entities.h:14
@ XML_PARSE_DTDVALID
Definition: parser.h:1234
@ XML_PARSE_DTDLOAD
Definition: parser.h:1232
@ XML_PARSE_DTDATTR
Definition: parser.h:1233
@ XML_PARSE_NOENT
Definition: parser.h:1231
int xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2449
static void xmlSaturatedAdd(unsigned long *dst, unsigned long val)
Definition: parser.c:540
static void xmlSaturatedAddSizeT(unsigned long *dst, unsigned long val)
Definition: parser.c:548
WORD flags
Definition: actctx.c:454
@ XML_ERR_PEREF_NO_NAME
Definition: xmlerror.h:124
@ XML_ERR_ENTITY_LOOP
Definition: xmlerror.h:189
@ XML_ERR_PEREF_SEMICOL_MISSING
Definition: xmlerror.h:125

Referenced by xmlParseInternalSubset(), xmlParserHandlePEReference(), and xmlSkipBlankChars().

◆ xmlParsePI()

XML_DEPRECATED XMLPUBFUN void xmlParsePI ( xmlParserCtxtPtr  ctxt)

xmlParsePI: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML Processing Instruction.

[16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'

The processing is transferred to SAX once parsed.

Definition at line 5322 of file parser.c.

5322 {
5323 xmlChar *buf = NULL;
5324 size_t len = 0;
5326 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
5329 int cur, l;
5330 const xmlChar *target;
5332
5333 if ((RAW == '<') && (NXT(1) == '?')) {
5334 int inputid = ctxt->input->id;
5335 state = ctxt->instate;
5336 ctxt->instate = XML_PARSER_PI;
5337 /*
5338 * this is a Processing Instruction.
5339 */
5340 SKIP(2);
5341
5342 /*
5343 * Parse the target name and check for special support like
5344 * namespace.
5345 */
5346 target = xmlParsePITarget(ctxt);
5347 if (target != NULL) {
5348 if ((RAW == '?') && (NXT(1) == '>')) {
5349 if (inputid != ctxt->input->id) {
5350 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5351 "PI declaration doesn't start and stop in"
5352 " the same entity\n");
5353 }
5354 SKIP(2);
5355
5356 /*
5357 * SAX: PI detected.
5358 */
5359 if ((ctxt->sax) && (!ctxt->disableSAX) &&
5360 (ctxt->sax->processingInstruction != NULL))
5361 ctxt->sax->processingInstruction(ctxt->userData,
5362 target, NULL);
5363 if (ctxt->instate != XML_PARSER_EOF)
5364 ctxt->instate = state;
5365 return;
5366 }
5368 if (buf == NULL) {
5369 xmlErrMemory(ctxt, NULL);
5370 ctxt->instate = state;
5371 return;
5372 }
5373 if (SKIP_BLANKS == 0) {
5374 xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED,
5375 "ParsePI: PI %s space expected\n", target);
5376 }
5377 cur = CUR_CHAR(l);
5378 while (IS_CHAR(cur) && /* checked */
5379 ((cur != '?') || (NXT(1) != '>'))) {
5380 if (len + 5 >= size) {
5381 xmlChar *tmp;
5382 size_t new_size = size * 2;
5383 tmp = (xmlChar *) xmlRealloc(buf, new_size);
5384 if (tmp == NULL) {
5385 xmlErrMemory(ctxt, NULL);
5386 xmlFree(buf);
5387 ctxt->instate = state;
5388 return;
5389 }
5390 buf = tmp;
5391 size = new_size;
5392 }
5393 COPY_BUF(buf, len, cur);
5394 if (len > maxLength) {
5395 xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
5396 "PI %s too big found", target);
5397 xmlFree(buf);
5398 ctxt->instate = state;
5399 return;
5400 }
5401 NEXTL(l);
5402 cur = CUR_CHAR(l);
5403 }
5404 buf[len] = 0;
5405 if (ctxt->instate == XML_PARSER_EOF) {
5406 xmlFree(buf);
5407 return;
5408 }
5409 if (cur != '?') {
5410 xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
5411 "ParsePI: PI %s never end ...\n", target);
5412 } else {
5413 if (inputid != ctxt->input->id) {
5414 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5415 "PI declaration doesn't start and stop in"
5416 " the same entity\n");
5417 }
5418 SKIP(2);
5419
5420#ifdef LIBXML_CATALOG_ENABLED
5421 if (((state == XML_PARSER_MISC) ||
5422 (state == XML_PARSER_START)) &&
5423 (xmlStrEqual(target, XML_CATALOG_PI))) {
5424 xmlCatalogAllow allow = xmlCatalogGetDefaults();
5425 if ((allow == XML_CATA_ALLOW_DOCUMENT) ||
5426 (allow == XML_CATA_ALLOW_ALL))
5427 xmlParseCatalogPI(ctxt, buf);
5428 }
5429#endif
5430
5431
5432 /*
5433 * SAX: PI detected.
5434 */
5435 if ((ctxt->sax) && (!ctxt->disableSAX) &&
5436 (ctxt->sax->processingInstruction != NULL))
5437 ctxt->sax->processingInstruction(ctxt->userData,
5438 target, buf);
5439 }
5440 xmlFree(buf);
5441 } else {
5443 }
5444 if (ctxt->instate != XML_PARSER_EOF)
5445 ctxt->instate = state;
5446 }
5447}
size_t const new_size
Definition: expand.cpp:66
@ XML_PARSER_PI
Definition: parser.h:119
@ XML_PARSER_START
Definition: parser.h:117
@ XML_PARSER_MISC
Definition: parser.h:118
const xmlChar * xmlParsePITarget(xmlParserCtxtPtr ctxt)
Definition: parser.c:5212
Definition: tools.h:99
@ XML_ERR_PI_NOT_STARTED
Definition: xmlerror.h:146
@ XML_ERR_PI_NOT_FINISHED
Definition: xmlerror.h:147

Referenced by xmlParseContentInternal(), xmlParseMarkupDecl(), and xmlParseMisc().

◆ xmlParsePITarget()

XML_DEPRECATED XMLPUBFUN const xmlChar * xmlParsePITarget ( xmlParserCtxtPtr  ctxt)

xmlParsePITarget: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the name of a PI

[17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

Returns the PITarget name or NULL

Definition at line 5212 of file parser.c.

5212 {
5213 const xmlChar *name;
5214
5215 name = xmlParseName(ctxt);
5216 if ((name != NULL) &&
5217 ((name[0] == 'x') || (name[0] == 'X')) &&
5218 ((name[1] == 'm') || (name[1] == 'M')) &&
5219 ((name[2] == 'l') || (name[2] == 'L'))) {
5220 int i;
5221 if ((name[0] == 'x') && (name[1] == 'm') &&
5222 (name[2] == 'l') && (name[3] == 0)) {
5223 xmlFatalErrMsg(ctxt, XML_ERR_RESERVED_XML_NAME,
5224 "XML declaration allowed only at the start of the document\n");
5225 return(name);
5226 } else if (name[3] == 0) {
5228 return(name);
5229 }
5230 for (i = 0;;i++) {
5231 if (xmlW3CPIs[i] == NULL) break;
5232 if (xmlStrEqual(name, (const xmlChar *)xmlW3CPIs[i]))
5233 return(name);
5234 }
5235 xmlWarningMsg(ctxt, XML_ERR_RESERVED_XML_NAME,
5236 "xmlParsePITarget: invalid name prefix 'xml'\n",
5237 NULL, NULL);
5238 }
5239 if ((name != NULL) && (xmlStrchr(name, ':') != NULL)) {
5240 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5241 "colons are forbidden from PI names '%s'\n", name, NULL, NULL);
5242 }
5243 return(name);
5244}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const char *const xmlW3CPIs[]
Definition: parser.c:193
@ XML_ERR_RESERVED_XML_NAME
Definition: xmlerror.h:164

Referenced by xmlParsePI().

◆ xmlParsePubidLiteral()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParsePubidLiteral ( xmlParserCtxtPtr  ctxt)

xmlParsePubidLiteral: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML public literal

[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"

Returns the PubidLiteral parsed or NULL.

Definition at line 4442 of file parser.c.

4442 {
4443 xmlChar *buf = NULL;
4444 int len = 0;
4446 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4449 xmlChar cur;
4450 xmlChar stop;
4451 xmlParserInputState oldstate = ctxt->instate;
4452
4453 if (RAW == '"') {
4454 NEXT;
4455 stop = '"';
4456 } else if (RAW == '\'') {
4457 NEXT;
4458 stop = '\'';
4459 } else {
4461 return(NULL);
4462 }
4464 if (buf == NULL) {
4465 xmlErrMemory(ctxt, NULL);
4466 return(NULL);
4467 }
4468 ctxt->instate = XML_PARSER_PUBLIC_LITERAL;
4469 cur = CUR;
4470 while ((IS_PUBIDCHAR_CH(cur)) && (cur != stop)) { /* checked */
4471 if (len + 1 >= size) {
4472 xmlChar *tmp;
4473
4474 size *= 2;
4475 tmp = (xmlChar *) xmlRealloc(buf, size);
4476 if (tmp == NULL) {
4477 xmlErrMemory(ctxt, NULL);
4478 xmlFree(buf);
4479 return(NULL);
4480 }
4481 buf = tmp;
4482 }
4483 buf[len++] = cur;
4484 if (len > maxLength) {
4485 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID");
4486 xmlFree(buf);
4487 return(NULL);
4488 }
4489 NEXT;
4490 cur = CUR;
4491 }
4492 buf[len] = 0;
4493 if (ctxt->instate == XML_PARSER_EOF) {
4494 xmlFree(buf);
4495 return(NULL);
4496 }
4497 if (cur != stop) {
4499 } else {
4500 NEXTL(1);
4501 }
4502 ctxt->instate = oldstate;
4503 return(buf);
4504}
#define IS_PUBIDCHAR_CH(c)
@ XML_PARSER_PUBLIC_LITERAL
Definition: parser.h:133
@ XML_ERR_LITERAL_NOT_FINISHED
Definition: xmlerror.h:144
@ XML_ERR_LITERAL_NOT_STARTED
Definition: xmlerror.h:143

Referenced by xmlParseExternalID().

◆ xmlParseReference()

XML_DEPRECATED XMLPUBFUN void xmlParseReference ( xmlParserCtxtPtr  ctxt)

xmlParseReference: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse and handle entity references in content, depending on the SAX interface, this may end-up in a call to character() if this is a CharRef, a predefined entity, if there is no reference() callback. or if the parser was asked to switch to that mode.

Always consumes '&'.

[67] Reference ::= EntityRef | CharRef

Definition at line 7227 of file parser.c.

7227 {
7228 xmlEntityPtr ent;
7229 xmlChar *val;
7230 int was_checked;
7231 xmlNodePtr list = NULL;
7233
7234
7235 if (RAW != '&')
7236 return;
7237
7238 /*
7239 * Simple case of a CharRef
7240 */
7241 if (NXT(1) == '#') {
7242 int i = 0;
7243 xmlChar out[16];
7244 int value = xmlParseCharRef(ctxt);
7245
7246 if (value == 0)
7247 return;
7248
7249 /*
7250 * Just encode the value in UTF-8
7251 */
7252 COPY_BUF(out, i, value);
7253 out[i] = 0;
7254 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7255 (!ctxt->disableSAX))
7256 ctxt->sax->characters(ctxt->userData, out, i);
7257 return;
7258 }
7259
7260 /*
7261 * We are seeing an entity reference
7262 */
7263 ent = xmlParseEntityRef(ctxt);
7264 if (ent == NULL) return;
7265 if (!ctxt->wellFormed)
7266 return;
7267 was_checked = ent->flags & XML_ENT_PARSED;
7268
7269 /* special case of predefined entities */
7270 if ((ent->name == NULL) ||
7271 (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
7272 val = ent->content;
7273 if (val == NULL) return;
7274 /*
7275 * inline the entity.
7276 */
7277 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7278 (!ctxt->disableSAX))
7279 ctxt->sax->characters(ctxt->userData, val, xmlStrlen(val));
7280 return;
7281 }
7282
7283 /*
7284 * The first reference to the entity trigger a parsing phase
7285 * where the ent->children is filled with the result from
7286 * the parsing.
7287 * Note: external parsed entities will not be loaded, it is not
7288 * required for a non-validating parser, unless the parsing option
7289 * of validating, or substituting entities were given. Doing so is
7290 * far more secure as the parser will only process data coming from
7291 * the document entity by default.
7292 *
7293 * FIXME: This doesn't work correctly since entities can be
7294 * expanded with different namespace declarations in scope.
7295 * For example:
7296 *
7297 * <!DOCTYPE doc [
7298 * <!ENTITY ent "<ns:elem/>">
7299 * ]>
7300 * <doc>
7301 * <decl1 xmlns:ns="urn:ns1">
7302 * &ent;
7303 * </decl1>
7304 * <decl2 xmlns:ns="urn:ns2">
7305 * &ent;
7306 * </decl2>
7307 * </doc>
7308 *
7309 * Proposed fix:
7310 *
7311 * - Remove the ent->owner optimization which tries to avoid the
7312 * initial copy of the entity. Always make entities own the
7313 * subtree.
7314 * - Ignore current namespace declarations when parsing the
7315 * entity. If a prefix can't be resolved, don't report an error
7316 * but mark it as unresolved.
7317 * - Try to resolve these prefixes when expanding the entity.
7318 * This will require a specialized version of xmlStaticCopyNode
7319 * which can also make use of the namespace hash table to avoid
7320 * quadratic behavior.
7321 *
7322 * Alternatively, we could simply reparse the entity on each
7323 * expansion like we already do with custom SAX callbacks.
7324 * External entity content should be cached in this case.
7325 */
7326 if (((ent->flags & XML_ENT_PARSED) == 0) &&
7327 ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
7328 (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
7329 unsigned long oldsizeentcopy = ctxt->sizeentcopy;
7330
7331 /*
7332 * This is a bit hackish but this seems the best
7333 * way to make sure both SAX and DOM entity support
7334 * behaves okay.
7335 */
7336 void *user_data;
7337 if (ctxt->userData == ctxt)
7338 user_data = NULL;
7339 else
7340 user_data = ctxt->userData;
7341
7342 /* Avoid overflow as much as possible */
7343 ctxt->sizeentcopy = 0;
7344
7345 if (ent->flags & XML_ENT_EXPANDING) {
7347 xmlHaltParser(ctxt);
7348 return;
7349 }
7350
7351 ent->flags |= XML_ENT_EXPANDING;
7352
7353 /*
7354 * Check that this entity is well formed
7355 * 4.3.2: An internal general parsed entity is well-formed
7356 * if its replacement text matches the production labeled
7357 * content.
7358 */
7359 if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
7360 ctxt->depth++;
7361 ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content,
7362 user_data, &list);
7363 ctxt->depth--;
7364
7365 } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
7366 ctxt->depth++;
7367 ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax,
7368 user_data, ctxt->depth, ent->URI,
7369 ent->ExternalID, &list);
7370 ctxt->depth--;
7371 } else {
7373 xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
7374 "invalid entity type found\n", NULL);
7375 }
7376
7377 ent->flags &= ~XML_ENT_EXPANDING;
7378 ent->flags |= XML_ENT_PARSED | XML_ENT_CHECKED;
7379 ent->expandedSize = ctxt->sizeentcopy;
7380 if (ret == XML_ERR_ENTITY_LOOP) {
7381 xmlHaltParser(ctxt);
7382 xmlFreeNodeList(list);
7383 return;
7384 }
7385 if (xmlParserEntityCheck(ctxt, oldsizeentcopy)) {
7386 xmlFreeNodeList(list);
7387 return;
7388 }
7389
7390 if ((ret == XML_ERR_OK) && (list != NULL)) {
7391 ent->children = list;
7392 /*
7393 * Prune it directly in the generated document
7394 * except for single text nodes.
7395 */
7396 if ((ctxt->replaceEntities == 0) ||
7397 (ctxt->parseMode == XML_PARSE_READER) ||
7398 ((list->type == XML_TEXT_NODE) &&
7399 (list->next == NULL))) {
7400 ent->owner = 1;
7401 while (list != NULL) {
7402 list->parent = (xmlNodePtr) ent;
7403 if (list->doc != ent->doc)
7404 xmlSetTreeDoc(list, ent->doc);
7405 if (list->next == NULL)
7406 ent->last = list;
7407 list = list->next;
7408 }
7409 list = NULL;
7410 } else {
7411 ent->owner = 0;
7412 while (list != NULL) {
7413 list->parent = (xmlNodePtr) ctxt->node;
7414 list->doc = ctxt->myDoc;
7415 if (list->next == NULL)
7416 ent->last = list;
7417 list = list->next;
7418 }
7419 list = ent->children;
7420#ifdef LIBXML_LEGACY_ENABLED
7421 if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
7422 xmlAddEntityReference(ent, list, NULL);
7423#endif /* LIBXML_LEGACY_ENABLED */
7424 }
7425 } else if ((ret != XML_ERR_OK) &&
7427 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7428 "Entity '%s' failed to parse\n", ent->name);
7429 if (ent->content != NULL)
7430 ent->content[0] = 0;
7431 } else if (list != NULL) {
7432 xmlFreeNodeList(list);
7433 list = NULL;
7434 }
7435
7436 /* Prevent entity from being parsed and expanded twice (Bug 760367). */
7437 was_checked = 0;
7438 }
7439
7440 /*
7441 * Now that the entity content has been gathered
7442 * provide it to the application, this can take different forms based
7443 * on the parsing modes.
7444 */
7445 if (ent->children == NULL) {
7446 /*
7447 * Probably running in SAX mode and the callbacks don't
7448 * build the entity content. So unless we already went
7449 * though parsing for first checking go though the entity
7450 * content to generate callbacks associated to the entity
7451 */
7452 if (was_checked != 0) {
7453 void *user_data;
7454 /*
7455 * This is a bit hackish but this seems the best
7456 * way to make sure both SAX and DOM entity support
7457 * behaves okay.
7458 */
7459 if (ctxt->userData == ctxt)
7460 user_data = NULL;
7461 else
7462 user_data = ctxt->userData;
7463
7464 if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
7465 ctxt->depth++;
7467 ent->content, user_data, NULL);
7468 ctxt->depth--;
7469 } else if (ent->etype ==
7471 unsigned long oldsizeentities = ctxt->sizeentities;
7472
7473 ctxt->depth++;
7474 ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt,
7475 ctxt->sax, user_data, ctxt->depth,
7476 ent->URI, ent->ExternalID, NULL);
7477 ctxt->depth--;
7478
7479 /* Undo the change to sizeentities */
7480 ctxt->sizeentities = oldsizeentities;
7481 } else {
7483 xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
7484 "invalid entity type found\n", NULL);
7485 }
7486 if (ret == XML_ERR_ENTITY_LOOP) {
7488 return;
7489 }
7490 if (xmlParserEntityCheck(ctxt, 0))
7491 return;
7492 }
7493 if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
7494 (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
7495 /*
7496 * Entity reference callback comes second, it's somewhat
7497 * superfluous but a compatibility to historical behaviour
7498 */
7499 ctxt->sax->reference(ctxt->userData, ent->name);
7500 }
7501 return;
7502 }
7503
7504 /*
7505 * We also check for amplification if entities aren't substituted.
7506 * They might be expanded later.
7507 */
7508 if ((was_checked != 0) &&
7509 (xmlParserEntityCheck(ctxt, ent->expandedSize)))
7510 return;
7511
7512 /*
7513 * If we didn't get any children for the entity being built
7514 */
7515 if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
7516 (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
7517 /*
7518 * Create a node.
7519 */
7520 ctxt->sax->reference(ctxt->userData, ent->name);
7521 return;
7522 }
7523
7524 if (ctxt->replaceEntities) {
7525 /*
7526 * There is a problem on the handling of _private for entities
7527 * (bug 155816): Should we copy the content of the field from
7528 * the entity (possibly overwriting some value set by the user
7529 * when a copy is created), should we leave it alone, or should
7530 * we try to take care of different situations? The problem
7531 * is exacerbated by the usage of this field by the xmlReader.
7532 * To fix this bug, we look at _private on the created node
7533 * and, if it's NULL, we copy in whatever was in the entity.
7534 * If it's not NULL we leave it alone. This is somewhat of a
7535 * hack - maybe we should have further tests to determine
7536 * what to do.
7537 */
7538 if (ctxt->node != NULL) {
7539 /*
7540 * Seems we are generating the DOM content, do
7541 * a simple tree copy for all references except the first
7542 * In the first occurrence list contains the replacement.
7543 */
7544 if (((list == NULL) && (ent->owner == 0)) ||
7545 (ctxt->parseMode == XML_PARSE_READER)) {
7546 xmlNodePtr nw = NULL, cur, firstChild = NULL;
7547
7548 /*
7549 * when operating on a reader, the entities definitions
7550 * are always owning the entities subtree.
7551 if (ctxt->parseMode == XML_PARSE_READER)
7552 ent->owner = 1;
7553 */
7554
7555 cur = ent->children;
7556 while (cur != NULL) {
7557 nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
7558 if (nw != NULL) {
7559 if (nw->_private == NULL)
7560 nw->_private = cur->_private;
7561 if (firstChild == NULL){
7562 firstChild = nw;
7563 }
7564 nw = xmlAddChild(ctxt->node, nw);
7565 }
7566 if (cur == ent->last) {
7567 /*
7568 * needed to detect some strange empty
7569 * node cases in the reader tests
7570 */
7571 if ((ctxt->parseMode == XML_PARSE_READER) &&
7572 (nw != NULL) &&
7573 (nw->type == XML_ELEMENT_NODE) &&
7574 (nw->children == NULL))
7575 nw->extra = 1;
7576
7577 break;
7578 }
7579 cur = cur->next;
7580 }
7581#ifdef LIBXML_LEGACY_ENABLED
7582 if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
7583 xmlAddEntityReference(ent, firstChild, nw);
7584#endif /* LIBXML_LEGACY_ENABLED */
7585 } else if ((list == NULL) || (ctxt->inputNr > 0)) {
7586 xmlNodePtr nw = NULL, cur, next, last,
7587 firstChild = NULL;
7588
7589 /*
7590 * Copy the entity child list and make it the new
7591 * entity child list. The goal is to make sure any
7592 * ID or REF referenced will be the one from the
7593 * document content and not the entity copy.
7594 */
7595 cur = ent->children;
7596 ent->children = NULL;
7597 last = ent->last;
7598 ent->last = NULL;
7599 while (cur != NULL) {
7600 next = cur->next;
7601 cur->next = NULL;
7602 cur->parent = NULL;
7603 nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
7604 if (nw != NULL) {
7605 if (nw->_private == NULL)
7606 nw->_private = cur->_private;
7607 if (firstChild == NULL){
7608 firstChild = cur;
7609 }
7610 xmlAddChild((xmlNodePtr) ent, nw);
7611 }
7612 xmlAddChild(ctxt->node, cur);
7613 if (cur == last)
7614 break;
7615 cur = next;
7616 }
7617 if (ent->owner == 0)
7618 ent->owner = 1;
7619#ifdef LIBXML_LEGACY_ENABLED
7620 if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
7621 xmlAddEntityReference(ent, firstChild, nw);
7622#endif /* LIBXML_LEGACY_ENABLED */
7623 } else {
7624 const xmlChar *nbktext;
7625
7626 /*
7627 * the name change is to avoid coalescing of the
7628 * node with a possible previous text one which
7629 * would make ent->children a dangling pointer
7630 */
7631 nbktext = xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
7632 -1);
7633 if (ent->children->type == XML_TEXT_NODE)
7634 ent->children->name = nbktext;
7635 if ((ent->last != ent->children) &&
7636 (ent->last->type == XML_TEXT_NODE))
7637 ent->last->name = nbktext;
7638 xmlAddChildList(ctxt->node, ent->children);
7639 }
7640
7641 /*
7642 * This is to avoid a nasty side effect, see
7643 * characters() in SAX.c
7644 */
7645 ctxt->nodemem = 0;
7646 ctxt->nodelen = 0;
7647 return;
7648 }
7649 }
7650}
Definition: list.h:37
struct list * next
Definition: list.h:38
if(dx< 0)
Definition: linetemp.h:194
#define XML_ENT_CHECKED
Definition: entities.h:15
static unsigned __int64 next
Definition: rand_nt.c:6
#define list
Definition: rosglue.h:35
@ XML_PARSE_READER
Definition: parser.h:173
static int xmlParserEntityCheck(xmlParserCtxtPtr ctxt, unsigned long extra)
Definition: parser.c:580
static xmlParserErrors xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt, xmlSAXHandlerPtr sax, void *user_data, int depth, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *list)
Definition: parser.c:12658
static xmlParserErrors xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt, const xmlChar *string, void *user_data, xmlNodePtr *lst)
Definition: parser.c:12935
xmlEntityPtr xmlParseEntityRef(xmlParserCtxtPtr ctxt)
Definition: parser.c:7683
int xmlParseCharRef(xmlParserCtxtPtr ctxt)
Definition: parser.c:2493

Referenced by xmlParseContentInternal().

◆ xmlParserHandlePEReference()

XML_DEPRECATED XMLPUBFUN void xmlParserHandlePEReference ( xmlParserCtxtPtr  ctxt)

xmlParserHandlePEReference: @ctxt: the parser context

DEPRECATED: Internal function, do not use.

[69] PEReference ::= '' Name ';'

[ WFC: No Recursion ] A parsed entity must not contain a recursive reference to itself, either directly or indirectly.

[ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", ... ... The declaration of a parameter entity must precede any reference to it...

[ VC: Entity Declared ] In a document with an external subset or external parameter entities with "standalone='no'", ... ... The declaration of a parameter entity must precede any reference to it...

[ WFC: In DTD ] Parameter-entity references may only appear in the DTD. NOTE: misleading but this is handled.

A PEReference may have been detected in the current input stream the handling is done accordingly to http://www.w3.org/TR/REC-xml#entproc i.e.

  • Included in literal in entity values
  • Included as Parameter Entity reference within DTDs

Definition at line 2715 of file parser.c.

2715 {
2716 switch(ctxt->instate) {
2718 return;
2719 case XML_PARSER_COMMENT:
2720 return;
2722 return;
2723 case XML_PARSER_END_TAG:
2724 return;
2725 case XML_PARSER_EOF:
2727 return;
2728 case XML_PARSER_PROLOG:
2729 case XML_PARSER_START:
2731 case XML_PARSER_MISC:
2733 return;
2735 case XML_PARSER_CONTENT:
2737 case XML_PARSER_PI:
2740 /* we just ignore it there */
2741 return;
2742 case XML_PARSER_EPILOG:
2744 return;
2746 /*
2747 * NOTE: in the case of entity values, we don't do the
2748 * substitution here since we need the literal
2749 * entity value to be able to save the internal
2750 * subset of the document.
2751 * This will be handled by xmlStringDecodeEntities
2752 */
2753 return;
2754 case XML_PARSER_DTD:
2755 /*
2756 * [WFC: Well-Formedness Constraint: PEs in Internal Subset]
2757 * In the internal DTD subset, parameter-entity references
2758 * can occur only where markup declarations can occur, not
2759 * within markup declarations.
2760 * In that case this is handled in xmlParseMarkupDecl
2761 */
2762 if ((ctxt->external == 0) && (ctxt->inputNr == 1))
2763 return;
2764 if (IS_BLANK_CH(NXT(1)) || NXT(1) == 0)
2765 return;
2766 break;
2767 case XML_PARSER_IGNORE:
2768 return;
2769 }
2770
2771 xmlParsePEReference(ctxt);
2772}
@ XML_PARSER_END_TAG
Definition: parser.h:126
@ XML_PARSER_PROLOG
Definition: parser.h:121
@ XML_PARSER_IGNORE
Definition: parser.h:132
@ XML_PARSER_SYSTEM_LITERAL
Definition: parser.h:130
@ XML_PARSER_START_TAG
Definition: parser.h:123
@ XML_PARSER_EPILOG
Definition: parser.h:131
@ XML_PARSER_XML_DECL
Definition: parser.h:134
void xmlParsePEReference(xmlParserCtxtPtr ctxt)
Definition: parser.c:8063
@ XML_ERR_PEREF_IN_PROLOG
Definition: xmlerror.h:119
@ XML_ERR_PEREF_IN_EPILOG
Definition: xmlerror.h:120
@ XML_ERR_PEREF_AT_EOF
Definition: xmlerror.h:118

◆ xmlParserInputShrink()

XML_DEPRECATED XMLPUBFUN void xmlParserInputShrink ( xmlParserInputPtr  in)

xmlParserInputShrink: @in: an XML parser input

DEPRECATED: Don't use.

This function removes used input for the parser.

Definition at line 650 of file parserInternals.c.

650 {
651 size_t used;
652 size_t ret;
653
654 if (in == NULL) return;
655 if (in->buf == NULL) return;
656 if (in->base == NULL) return;
657 if (in->cur == NULL) return;
658 if (in->buf->buffer == NULL) return;
659
660 used = in->cur - in->base;
661 /*
662 * Do not shrink on large buffers whose only a tiny fraction
663 * was consumed
664 */
665 if (used > INPUT_CHUNK) {
666 ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
667 if (ret > 0) {
668 used -= ret;
669 if ((ret > ULONG_MAX) ||
670 (in->consumed > ULONG_MAX - (unsigned long)ret))
671 in->consumed = ULONG_MAX;
672 else
673 in->consumed += ret;
674 }
675 }
676
677 if (xmlBufUse(in->buf->buffer) <= INPUT_CHUNK) {
679 }
680
681 in->base = xmlBufContent(in->buf->buffer);
682 if (in->base == NULL) {
683 /* TODO: raise error */
684 in->base = BAD_CAST "";
685 in->cur = in->base;
686 in->end = in->base;
687 return;
688 }
689 in->cur = in->base + used;
690 in->end = xmlBufEnd(in->buf->buffer);
691}
static int used
Definition: adh-main.c:39
xmlChar * xmlBufEnd(xmlBufPtr buf)
Definition: buf.c:508
xmlChar * xmlBufContent(const xmlBuf *buf)
Definition: buf.c:490
size_t xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:570
size_t xmlBufShrink(xmlBufPtr buf, size_t len)
Definition: buf.c:328
#define ULONG_MAX
Definition: limits.h:31
#define LINE_LEN
XMLPUBFUN int xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len)

◆ xmlParseSDDecl()

XML_DEPRECATED XMLPUBFUN int xmlParseSDDecl ( xmlParserCtxtPtr  ctxt)

xmlParseSDDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the XML standalone declaration

[32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"'))

[ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value "no" if any external markup declarations contain declarations of:

  • attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or
  • entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or
  • attributes with values subject to normalization, where the attribute appears in the document with a value which will change as a result of normalization, or
  • element types with element content, if white space occurs directly within any instance of those types.

Returns: 1 if standalone="yes" 0 if standalone="no" -2 if standalone attribute is missing or invalid (A standalone value of -2 means that the XML declaration was found, but no value was specified for the standalone attribute).

Definition at line 10792 of file parser.c.

10792 {
10793 int standalone = -2;
10794
10796 if (CMP10(CUR_PTR, 's', 't', 'a', 'n', 'd', 'a', 'l', 'o', 'n', 'e')) {
10797 SKIP(10);
10799 if (RAW != '=') {
10801 return(standalone);
10802 }
10803 NEXT;
10805 if (RAW == '\''){
10806 NEXT;
10807 if ((RAW == 'n') && (NXT(1) == 'o')) {
10808 standalone = 0;
10809 SKIP(2);
10810 } else if ((RAW == 'y') && (NXT(1) == 'e') &&
10811 (NXT(2) == 's')) {
10812 standalone = 1;
10813 SKIP(3);
10814 } else {
10816 }
10817 if (RAW != '\'') {
10819 } else
10820 NEXT;
10821 } else if (RAW == '"'){
10822 NEXT;
10823 if ((RAW == 'n') && (NXT(1) == 'o')) {
10824 standalone = 0;
10825 SKIP(2);
10826 } else if ((RAW == 'y') && (NXT(1) == 'e') &&
10827 (NXT(2) == 's')) {
10828 standalone = 1;
10829 SKIP(3);
10830 } else {
10832 }
10833 if (RAW != '"') {
10835 } else
10836 NEXT;
10837 } else {
10839 }
10840 }
10841 return(standalone);
10842}
#define CMP10(s, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
Definition: parser.c:2246
@ XML_ERR_STANDALONE_VALUE
Definition: xmlerror.h:178

Referenced by xmlParseXMLDecl().

◆ xmlParseSystemLiteral()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseSystemLiteral ( xmlParserCtxtPtr  ctxt)

xmlParseSystemLiteral: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML Literal

[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")

Returns the SystemLiteral parsed or NULL

Definition at line 4361 of file parser.c.

4361 {
4362 xmlChar *buf = NULL;
4363 int len = 0;
4365 int cur, l;
4366 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4369 xmlChar stop;
4370 int state = ctxt->instate;
4371
4372 if (RAW == '"') {
4373 NEXT;
4374 stop = '"';
4375 } else if (RAW == '\'') {
4376 NEXT;
4377 stop = '\'';
4378 } else {
4380 return(NULL);
4381 }
4382
4384 if (buf == NULL) {
4385 xmlErrMemory(ctxt, NULL);
4386 return(NULL);
4387 }
4388 ctxt->instate = XML_PARSER_SYSTEM_LITERAL;
4389 cur = CUR_CHAR(l);
4390 while ((IS_CHAR(cur)) && (cur != stop)) { /* checked */
4391 if (len + 5 >= size) {
4392 xmlChar *tmp;
4393
4394 size *= 2;
4395 tmp = (xmlChar *) xmlRealloc(buf, size);
4396 if (tmp == NULL) {
4397 xmlFree(buf);
4398 xmlErrMemory(ctxt, NULL);
4399 ctxt->instate = (xmlParserInputState) state;
4400 return(NULL);
4401 }
4402 buf = tmp;
4403 }
4404 COPY_BUF(buf, len, cur);
4405 if (len > maxLength) {
4406 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral");
4407 xmlFree(buf);
4408 ctxt->instate = (xmlParserInputState) state;
4409 return(NULL);
4410 }
4411 NEXTL(l);
4412 cur = CUR_CHAR(l);
4413 }
4414 buf[len] = 0;
4415 if (ctxt->instate == XML_PARSER_EOF) {
4416 xmlFree(buf);
4417 return(NULL);
4418 }
4419 ctxt->instate = (xmlParserInputState) state;
4420 if (!IS_CHAR(cur)) {
4422 } else {
4423 NEXT;
4424 }
4425 return(buf);
4426}

Referenced by xmlParseExternalID().

◆ xmlParseTextDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseTextDecl ( xmlParserCtxtPtr  ctxt)

xmlParseTextDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML declaration header for external entities

[77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'

Definition at line 7074 of file parser.c.

7074 {
7076 int oldstate;
7077
7078 /*
7079 * We know that '<?xml' is here.
7080 */
7081 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
7082 SKIP(5);
7083 } else {
7085 return;
7086 }
7087
7088 /* Avoid expansion of parameter entities when skipping blanks. */
7089 oldstate = ctxt->instate;
7090 ctxt->instate = XML_PARSER_START;
7091
7092 if (SKIP_BLANKS == 0) {
7093 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
7094 "Space needed after '<?xml'\n");
7095 }
7096
7097 /*
7098 * We may have the VersionInfo here.
7099 */
7101 if (version == NULL)
7103 else {
7104 if (SKIP_BLANKS == 0) {
7105 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
7106 "Space needed here\n");
7107 }
7108 }
7109 ctxt->input->version = version;
7110
7111 /*
7112 * We must have the encoding declaration
7113 */
7115 if (ctxt->instate == XML_PARSER_EOF)
7116 return;
7117 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
7118 /*
7119 * The XML REC instructs us to stop parsing right here
7120 */
7121 ctxt->instate = oldstate;
7122 return;
7123 }
7124
7126 if ((RAW == '?') && (NXT(1) == '>')) {
7127 SKIP(2);
7128 } else if (RAW == '>') {
7129 /* Deprecated old WD ... */
7131 NEXT;
7132 } else {
7133 int c;
7134
7136 while ((c = CUR) != 0) {
7137 NEXT;
7138 if (c == '>')
7139 break;
7140 }
7141 }
7142
7143 if (ctxt->instate != XML_PARSER_EOF)
7144 ctxt->instate = oldstate;
7145}
static const WCHAR version[]
Definition: asmname.c:66
#define XML_DEFAULT_VERSION
Definition: parser.h:39
xmlChar * xmlParseVersionInfo(xmlParserCtxtPtr ctxt)
Definition: parser.c:10597
const xmlChar * xmlParseEncodingDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10713
@ XML_ERR_XMLDECL_NOT_FINISHED
Definition: xmlerror.h:157
@ XML_ERR_XMLDECL_NOT_STARTED
Definition: xmlerror.h:156
XMLPUBFUN xmlChar * xmlCharStrdup(const char *cur)
Definition: xmlstring.c:116

Referenced by xmlLoadEntityContent(), xmlParseExternalEntityPrivate(), xmlParseExternalSubset(), and xmlParsePEReference().

◆ xmlParseVersionInfo()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseVersionInfo ( xmlParserCtxtPtr  ctxt)

xmlParseVersionInfo: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the XML version.

[24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")

[25] Eq ::= S? '=' S?

Returns the version string, e.g. "1.0"

Definition at line 10597 of file parser.c.

10597 {
10598 xmlChar *version = NULL;
10599
10600 if (CMP7(CUR_PTR, 'v', 'e', 'r', 's', 'i', 'o', 'n')) {
10601 SKIP(7);
10603 if (RAW != '=') {
10605 return(NULL);
10606 }
10607 NEXT;
10609 if (RAW == '"') {
10610 NEXT;
10612 if (RAW != '"') {
10614 } else
10615 NEXT;
10616 } else if (RAW == '\''){
10617 NEXT;
10619 if (RAW != '\'') {
10621 } else
10622 NEXT;
10623 } else {
10625 }
10626 }
10627 return(version);
10628}
xmlChar * xmlParseVersionNum(xmlParserCtxtPtr ctxt)
Definition: parser.c:10534

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseVersionNum()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlParseVersionNum ( xmlParserCtxtPtr  ctxt)

xmlParseVersionNum: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse the XML version value.

[26] VersionNum ::= '1.' [0-9]+

In practice allow [0-9].[0-9]+ at that level

Returns the string giving the XML version number, or NULL

Definition at line 10534 of file parser.c.

10534 {
10535 xmlChar *buf = NULL;
10536 int len = 0;
10537 int size = 10;
10538 xmlChar cur;
10539
10541 if (buf == NULL) {
10542 xmlErrMemory(ctxt, NULL);
10543 return(NULL);
10544 }
10545 cur = CUR;
10546 if (!((cur >= '0') && (cur <= '9'))) {
10547 xmlFree(buf);
10548 return(NULL);
10549 }
10550 buf[len++] = cur;
10551 NEXT;
10552 cur=CUR;
10553 if (cur != '.') {
10554 xmlFree(buf);
10555 return(NULL);
10556 }
10557 buf[len++] = cur;
10558 NEXT;
10559 cur=CUR;
10560 while ((cur >= '0') && (cur <= '9')) {
10561 if (len + 1 >= size) {
10562 xmlChar *tmp;
10563
10564 size *= 2;
10565 tmp = (xmlChar *) xmlRealloc(buf, size);
10566 if (tmp == NULL) {
10567 xmlFree(buf);
10568 xmlErrMemory(ctxt, NULL);
10569 return(NULL);
10570 }
10571 buf = tmp;
10572 }
10573 buf[len++] = cur;
10574 NEXT;
10575 cur=CUR;
10576 }
10577 buf[len] = 0;
10578 return(buf);
10579}

Referenced by xmlParseVersionInfo().

◆ xmlParseXMLDecl()

XML_DEPRECATED XMLPUBFUN void xmlParseXMLDecl ( xmlParserCtxtPtr  ctxt)

xmlParseXMLDecl: @ctxt: an XML parser context

DEPRECATED: Internal function, don't use.

parse an XML declaration header

[23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'

Definition at line 10856 of file parser.c.

10856 {
10858
10859 /*
10860 * This value for standalone indicates that the document has an
10861 * XML declaration but it does not have a standalone attribute.
10862 * It will be overwritten later if a standalone attribute is found.
10863 */
10864
10865 ctxt->standalone = -2;
10866
10867 /*
10868 * We know that '<?xml' is here.
10869 */
10870 SKIP(5);
10871
10872 if (!IS_BLANK_CH(RAW)) {
10873 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
10874 "Blank needed after '<?xml'\n");
10875 }
10877
10878 /*
10879 * We must have the VersionInfo here.
10880 */
10882 if (version == NULL) {
10884 } else {
10886 /*
10887 * Changed here for XML-1.0 5th edition
10888 */
10889 if (ctxt->options & XML_PARSE_OLD10) {
10890 xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
10891 "Unsupported version '%s'\n",
10892 version);
10893 } else {
10894 if ((version[0] == '1') && ((version[1] == '.'))) {
10895 xmlWarningMsg(ctxt, XML_WAR_UNKNOWN_VERSION,
10896 "Unsupported version '%s'\n",
10897 version, NULL);
10898 } else {
10899 xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
10900 "Unsupported version '%s'\n",
10901 version);
10902 }
10903 }
10904 }
10905 if (ctxt->version != NULL)
10906 xmlFree((void *) ctxt->version);
10907 ctxt->version = version;
10908 }
10909
10910 /*
10911 * We may have the encoding declaration
10912 */
10913 if (!IS_BLANK_CH(RAW)) {
10914 if ((RAW == '?') && (NXT(1) == '>')) {
10915 SKIP(2);
10916 return;
10917 }
10918 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
10919 }
10921 if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
10922 (ctxt->instate == XML_PARSER_EOF)) {
10923 /*
10924 * The XML REC instructs us to stop parsing right here
10925 */
10926 return;
10927 }
10928
10929 /*
10930 * We may have the standalone status.
10931 */
10932 if ((ctxt->encoding != NULL) && (!IS_BLANK_CH(RAW))) {
10933 if ((RAW == '?') && (NXT(1) == '>')) {
10934 SKIP(2);
10935 return;
10936 }
10937 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
10938 }
10939
10940 /*
10941 * We can grow the input buffer freely at that point
10942 */
10943 GROW;
10944
10946 ctxt->standalone = xmlParseSDDecl(ctxt);
10947
10949 if ((RAW == '?') && (NXT(1) == '>')) {
10950 SKIP(2);
10951 } else if (RAW == '>') {
10952 /* Deprecated old WD ... */
10954 NEXT;
10955 } else {
10956 int c;
10957
10959 while ((c = CUR) != 0) {
10960 NEXT;
10961 if (c == '>')
10962 break;
10963 }
10964 }
10965}
@ XML_PARSE_OLD10
Definition: parser.h:1249
int xmlParseSDDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10792
@ XML_WAR_UNKNOWN_VERSION
Definition: xmlerror.h:197
@ XML_ERR_UNKNOWN_VERSION
Definition: xmlerror.h:208
@ XML_ERR_VERSION_MISSING
Definition: xmlerror.h:196

Referenced by xmlParseDocument(), and xmlParseExtParsedEnt().

◆ xmlPopInput()

XMLPUBFUN xmlChar xmlPopInput ( xmlParserCtxtPtr  ctxt)

xmlPopInput: @ctxt: an XML parser context

xmlPopInput: the current input pointed by ctxt->input came to an end pop it and return the next char.

Returns the current xmlChar in the parser context

Definition at line 2419 of file parser.c.

2419 {
2420 xmlParserInputPtr input;
2421
2422 if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
2425 "Popping input %d\n", ctxt->inputNr);
2426 if ((ctxt->inputNr > 1) && (ctxt->inSubset == 0) &&
2427 (ctxt->instate != XML_PARSER_EOF))
2429 "Unfinished entity outside the DTD");
2430 input = inputPop(ctxt);
2431 if (input->entity != NULL)
2432 input->entity->flags &= ~XML_ENT_EXPANDING;
2434 if (*ctxt->input->cur == 0)
2435 xmlParserGrow(ctxt);
2436 return(CUR);
2437}
XML_HIDDEN int xmlParserGrow(xmlParserCtxtPtr ctxt)
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1927

Referenced by xmlSAX2ExternalSubset(), and xmlSkipBlankChars().

◆ xmlPushInput()

XMLPUBFUN int xmlPushInput ( xmlParserCtxtPtr  ctxt,
xmlParserInputPtr  input 
)

xmlPushInput: @ctxt: an XML parser context @input: an XML parser input fragment (entity, XML fragment ...).

xmlPushInput: switch to a new input stream which is stacked on top of the previous one(s). Returns -1 in case of error or the index in the input stack

Definition at line 2449 of file parser.c.

2449 {
2450 int ret;
2451 if (input == NULL) return(-1);
2452
2454 if ((ctxt->input != NULL) && (ctxt->input->filename))
2456 "%s(%d): ", ctxt->input->filename,
2457 ctxt->input->line);
2459 "Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
2460 }
2461 if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
2462 (ctxt->inputNr > 100)) {
2464 while (ctxt->inputNr > 1)
2466 return(-1);
2467 }
2468 ret = inputPush(ctxt, input);
2469 if (ctxt->instate == XML_PARSER_EOF)
2470 return(-1);
2471 GROW;
2472 return(ret);
2473}

Referenced by xmlParsePEReference(), and xmlSAX2ExternalSubset().

◆ xmlSkipBlankChars()

XML_DEPRECATED XMLPUBFUN int xmlSkipBlankChars ( xmlParserCtxtPtr  ctxt)

xmlSkipBlankChars: @ctxt: the XML parser context

DEPRECATED: Internal function, do not use.

skip all blanks character found at that point in the input streams. It pops up finished entities in the process if allowable at that point.

Returns the number of space chars skipped

Definition at line 2316 of file parser.c.

2316 {
2317 int res = 0;
2318
2319 /*
2320 * It's Okay to use CUR/NEXT here since all the blanks are on
2321 * the ASCII range.
2322 */
2323 if (((ctxt->inputNr == 1) && (ctxt->instate != XML_PARSER_DTD)) ||
2324 (ctxt->instate == XML_PARSER_START)) {
2325 const xmlChar *cur;
2326 /*
2327 * if we are in the document content, go really fast
2328 */
2329 cur = ctxt->input->cur;
2330 while (IS_BLANK_CH(*cur)) {
2331 if (*cur == '\n') {
2332 ctxt->input->line++; ctxt->input->col = 1;
2333 } else {
2334 ctxt->input->col++;
2335 }
2336 cur++;
2337 if (res < INT_MAX)
2338 res++;
2339 if (*cur == 0) {
2340 ctxt->input->cur = cur;
2341 xmlParserGrow(ctxt);
2342 cur = ctxt->input->cur;
2343 }
2344 }
2345 ctxt->input->cur = cur;
2346 } else {
2347 int expandPE = ((ctxt->external != 0) || (ctxt->inputNr != 1));
2348
2349 while (ctxt->instate != XML_PARSER_EOF) {
2350 if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */
2351 NEXT;
2352 } else if (CUR == '%') {
2353 /*
2354 * Need to handle support of entities branching here
2355 */
2356 if ((expandPE == 0) || (IS_BLANK_CH(NXT(1))) || (NXT(1) == 0))
2357 break;
2358 xmlParsePEReference(ctxt);
2359 } else if (CUR == 0) {
2360 unsigned long consumed;
2361 xmlEntityPtr ent;
2362
2363 if (ctxt->inputNr <= 1)
2364 break;
2365
2366 consumed = ctxt->input->consumed;
2368 ctxt->input->cur - ctxt->input->base);
2369
2370 /*
2371 * Add to sizeentities when parsing an external entity
2372 * for the first time.
2373 */
2374 ent = ctxt->input->entity;
2375 if ((ent->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
2376 ((ent->flags & XML_ENT_PARSED) == 0)) {
2377 ent->flags |= XML_ENT_PARSED;
2378
2379 xmlSaturatedAdd(&ctxt->sizeentities, consumed);
2380 }
2381
2383
2384 xmlPopInput(ctxt);
2385 } else {
2386 break;
2387 }
2388
2389 /*
2390 * Also increase the counter when entering or exiting a PERef.
2391 * The spec says: "When a parameter-entity reference is recognized
2392 * in the DTD and included, its replacement text MUST be enlarged
2393 * by the attachment of one leading and one following space (#x20)
2394 * character."
2395 */
2396 if (res < INT_MAX)
2397 res++;
2398 }
2399 }
2400 return(res);
2401}
int consumed
Definition: scanf.h:200
xmlChar xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2419

◆ xmlSplitQName()

XMLPUBFUN xmlChar * xmlSplitQName ( xmlParserCtxtPtr  ctxt,
const xmlChar name,
xmlChar **  prefix 
)

Namespaces.

Definition at line 3157 of file parser.c.

3157 {
3159 xmlChar *buffer = NULL;
3160 int len = 0;
3161 int max = XML_MAX_NAMELEN;
3162 xmlChar *ret = NULL;
3163 const xmlChar *cur = name;
3164 int c;
3165
3166 if (prefix == NULL) return(NULL);
3167 *prefix = NULL;
3168
3169 if (cur == NULL) return(NULL);
3170
3171#ifndef XML_XML_NAMESPACE
3172 /* xml: prefix is not really a namespace */
3173 if ((cur[0] == 'x') && (cur[1] == 'm') &&
3174 (cur[2] == 'l') && (cur[3] == ':'))
3175 return(xmlStrdup(name));
3176#endif
3177
3178 /* nasty but well=formed */
3179 if (cur[0] == ':')
3180 return(xmlStrdup(name));
3181
3182 c = *cur++;
3183 while ((c != 0) && (c != ':') && (len < max)) { /* tested bigname.xml */
3184 buf[len++] = c;
3185 c = *cur++;
3186 }
3187 if (len >= max) {
3188 /*
3189 * Okay someone managed to make a huge name, so he's ready to pay
3190 * for the processing speed.
3191 */
3192 max = len * 2;
3193
3195 if (buffer == NULL) {
3196 xmlErrMemory(ctxt, NULL);
3197 return(NULL);
3198 }
3199 memcpy(buffer, buf, len);
3200 while ((c != 0) && (c != ':')) { /* tested bigname.xml */
3201 if (len + 10 > max) {
3202 xmlChar *tmp;
3203
3204 max *= 2;
3205 tmp = (xmlChar *) xmlRealloc(buffer, max);
3206 if (tmp == NULL) {
3207 xmlFree(buffer);
3208 xmlErrMemory(ctxt, NULL);
3209 return(NULL);
3210 }
3211 buffer = tmp;
3212 }
3213 buffer[len++] = c;
3214 c = *cur++;
3215 }
3216 buffer[len] = 0;
3217 }
3218
3219 if ((c == ':') && (*cur == 0)) {
3220 if (buffer != NULL)
3221 xmlFree(buffer);
3222 *prefix = NULL;
3223 return(xmlStrdup(name));
3224 }
3225
3226 if (buffer == NULL)
3227 ret = xmlStrndup(buf, len);
3228 else {
3229 ret = buffer;
3230 buffer = NULL;
3232 }
3233
3234
3235 if (c == ':') {
3236 c = *cur;
3237 *prefix = ret;
3238 if (c == 0) {
3239 return(xmlStrndup(BAD_CAST "", 0));
3240 }
3241 len = 0;
3242
3243 /*
3244 * Check that the first character is proper to start
3245 * a new name
3246 */
3247 if (!(((c >= 0x61) && (c <= 0x7A)) ||
3248 ((c >= 0x41) && (c <= 0x5A)) ||
3249 (c == '_') || (c == ':'))) {
3250 int l;
3251 int first = CUR_SCHAR(cur, l);
3252
3253 if (!IS_LETTER(first) && (first != '_')) {
3254 xmlFatalErrMsgStr(ctxt, XML_NS_ERR_QNAME,
3255 "Name %s is not XML Namespace compliant\n",
3256 name);
3257 }
3258 }
3259 cur++;
3260
3261 while ((c != 0) && (len < max)) { /* tested bigname2.xml */
3262 buf[len++] = c;
3263 c = *cur++;
3264 }
3265 if (len >= max) {
3266 /*
3267 * Okay someone managed to make a huge name, so he's ready to pay
3268 * for the processing speed.
3269 */
3270 max = len * 2;
3271
3273 if (buffer == NULL) {
3274 xmlErrMemory(ctxt, NULL);
3275 return(NULL);
3276 }
3277 memcpy(buffer, buf, len);
3278 while (c != 0) { /* tested bigname2.xml */
3279 if (len + 10 > max) {
3280 xmlChar *tmp;
3281
3282 max *= 2;
3283 tmp = (xmlChar *) xmlRealloc(buffer, max);
3284 if (tmp == NULL) {
3285 xmlErrMemory(ctxt, NULL);
3286 xmlFree(buffer);
3287 return(NULL);
3288 }
3289 buffer = tmp;
3290 }
3291 buffer[len++] = c;
3292 c = *cur++;
3293 }
3294 buffer[len] = 0;
3295 }
3296
3297 if (buffer == NULL)
3298 ret = xmlStrndup(buf, len);
3299 else {
3300 ret = buffer;
3301 }
3302 }
3303
3304 return(ret);
3305}
const GLint * first
Definition: glext.h:5794
#define IS_LETTER(c)
#define CUR_SCHAR(s, l)
Definition: parser.c:2297
Character const *const prefix
Definition: tempnam.cpp:195
@ XML_NS_ERR_QNAME
Definition: xmlerror.h:216

Referenced by xmlSAX2AttributeDecl().

◆ xmlStringCurrentChar()

XML_DEPRECATED XMLPUBFUN int xmlStringCurrentChar ( xmlParserCtxtPtr ctxt  ATTRIBUTE_UNUSED,
const xmlChar cur,
int len 
)

xmlStringCurrentChar: @ctxt: the XML parser context @cur: pointer to the beginning of the char @len: pointer to the length of the char read

DEPRECATED: Internal function, do not use.

The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer.

Returns the current char value and its length

Definition at line 990 of file parserInternals.c.

991 {
992 int c;
993
994 if ((cur == NULL) || (len == NULL))
995 return(0);
996
997 /* cur is zero-terminated, so we can lie about its length. */
998 *len = 4;
1000
1001 return((c < 0) ? 0 : c);
1002}
XMLPUBFUN int XMLPUBFUN int XMLPUBFUN int xmlGetUTF8Char(const unsigned char *utf, int *len)
Definition: xmlstring.c:708

◆ xmlStringDecodeEntities()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlStringDecodeEntities ( xmlParserCtxtPtr  ctxt,
const xmlChar str,
int  what,
xmlChar  end,
xmlChar  end2,
xmlChar  end3 
)

xmlStringDecodeEntities: @ctxt: the parser context @str: the input string @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF @end: an end marker xmlChar, 0 if none @end2: an end marker xmlChar, 0 if none @end3: an end marker xmlChar, 0 if none

DEPRECATED: Internal function, don't use.

Takes a entity string content and process to do the adequate substitutions.

[67] Reference ::= EntityRef | CharRef

[69] PEReference ::= '' Name ';'

Returns A newly allocated string with the substitution done. The caller must deallocate it !

Definition at line 3050 of file parser.c.

3051 {
3052 if ((ctxt == NULL) || (str == NULL)) return(NULL);
3053 return(xmlStringDecodeEntitiesInt(ctxt, str, xmlStrlen(str), what,
3054 end, end2, end3, 0));
3055}
GLuint GLuint end
Definition: gl.h:1545
const WCHAR * str

◆ xmlStringLenDecodeEntities()

XML_DEPRECATED XMLPUBFUN xmlChar * xmlStringLenDecodeEntities ( xmlParserCtxtPtr  ctxt,
const xmlChar str,
int  len,
int  what,
xmlChar  end,
xmlChar  end2,
xmlChar  end3 
)

xmlStringLenDecodeEntities: @ctxt: the parser context @str: the input string @len: the string length @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF @end: an end marker xmlChar, 0 if none @end2: an end marker xmlChar, 0 if none @end3: an end marker xmlChar, 0 if none

DEPRECATED: Internal function, don't use.

Takes a entity string content and process to do the adequate substitutions.

[67] Reference ::= EntityRef | CharRef

[69] PEReference ::= '' Name ';'

Returns A newly allocated string with the substitution done. The caller must deallocate it !

Definition at line 3020 of file parser.c.

3022 {
3023 if ((ctxt == NULL) || (str == NULL) || (len < 0))
3024 return(NULL);
3025 return(xmlStringDecodeEntitiesInt(ctxt, str, len, what,
3026 end, end2, end3, 0));
3027}

◆ xmlSwitchEncoding()

XMLPUBFUN int xmlSwitchEncoding ( xmlParserCtxtPtr  ctxt,
xmlCharEncoding  enc 
)

xmlSwitchEncoding: @ctxt: the parser context @enc: the encoding value (number)

Use encoding specified by enum to decode input data.

This function can be used to enforce the encoding of chunks passed to xmlParseChunk.

Returns 0 in case of success, -1 otherwise

Definition at line 1146 of file parserInternals.c.

1147{
1149 int check = 1;
1150 int ret;
1151
1152 if ((ctxt == NULL) || (ctxt->input == NULL))
1153 return(-1);
1154
1155 switch (enc) {
1159 check = 0;
1160 break;
1162 handler = xmlDetectEBCDIC(ctxt->input);
1163 break;
1164 default:
1166 break;
1167 }
1168
1169 if ((check) && (handler == NULL)) {
1170 const char *name = xmlGetCharEncodingName(enc);
1171
1173 "encoding not supported: %s\n",
1174 BAD_CAST (name ? name : "<null>"), NULL);
1175 /*
1176 * TODO: We could recover from errors in external entities
1177 * if we didn't stop the parser. But most callers of this
1178 * function don't check the return value.
1179 */
1180 xmlStopParser(ctxt);
1181 return(-1);
1182 }
1183
1184 ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
1185
1186 if ((ret >= 0) && (enc == XML_CHAR_ENCODING_NONE)) {
1187 ctxt->input->flags &= ~XML_INPUT_HAS_ENCODING;
1188 }
1189
1190 return(ret);
1191}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#define check(expected, result)
Definition: dplayx.c:32
const char * xmlGetCharEncodingName(xmlCharEncoding enc)
Definition: encoding.c:1229
xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler(xmlCharEncoding enc)
Definition: encoding.c:1547
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:68
@ XML_CHAR_ENCODING_EBCDIC
Definition: encoding.h:73
@ XML_CHAR_ENCODING_ASCII
Definition: encoding.h:89
int xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
static xmlCharEncodingHandlerPtr xmlDetectEBCDIC(xmlParserInputPtr input)
XMLPUBFUN void xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12311

Referenced by doparse(), internal_parseBuffer(), xmlDetectEncoding(), and xmlNewIOInputStream().

◆ xmlSwitchInputEncoding()

XML_DEPRECATED XMLPUBFUN int xmlSwitchInputEncoding ( xmlParserCtxtPtr  ctxt,
xmlParserInputPtr  input,
xmlCharEncodingHandlerPtr  handler 
)

xmlSwitchInputEncoding: @ctxt: the parser context @input: the input stream @handler: the encoding handler

DEPRECATED: Internal function, don't use.

Use encoding handler to decode input data.

Returns 0 in case of success, -1 otherwise

Definition at line 1206 of file parserInternals.c.

1208{
1209 int nbchars;
1210 xmlParserInputBufferPtr in;
1211
1212 if ((input == NULL) || (input->buf == NULL)) {
1214 return (-1);
1215 }
1216 in = input->buf;
1217
1218 input->flags |= XML_INPUT_HAS_ENCODING;
1219
1220 /*
1221 * UTF-8 requires no encoding handler.
1222 */
1223 if ((handler != NULL) &&
1224 (xmlStrcasecmp(BAD_CAST handler->name, BAD_CAST "UTF-8") == 0)) {
1226 handler = NULL;
1227 }
1228
1229 if (in->encoder == handler)
1230 return (0);
1231
1232 if (in->encoder != NULL) {
1233 /*
1234 * Switching encodings during parsing is a really bad idea,
1235 * but Chromium can switch between ISO-8859-1 and UTF-16 before
1236 * separate calls to xmlParseChunk.
1237 *
1238 * TODO: We should check whether the "raw" input buffer is empty and
1239 * convert the old content using the old encoder.
1240 */
1241
1242 xmlCharEncCloseFunc(in->encoder);
1243 in->encoder = handler;
1244 return (0);
1245 }
1246
1247 in->encoder = handler;
1248
1249 /*
1250 * Is there already some content down the pipe to convert ?
1251 */
1252 if (xmlBufIsEmpty(in->buffer) == 0) {
1253 size_t processed;
1254
1255 /*
1256 * Shrink the current input buffer.
1257 * Move it as the raw buffer and create a new input buffer
1258 */
1259 processed = input->cur - input->base;
1260 xmlBufShrink(in->buffer, processed);
1261 input->consumed += processed;
1262 in->raw = in->buffer;
1263 in->buffer = xmlBufCreate();
1264 in->rawconsumed = processed;
1265
1266 nbchars = xmlCharEncInput(in);
1267 xmlBufResetInput(in->buffer, input);
1268 if (nbchars < 0) {
1269 /* TODO: This could be an out of memory or an encoding error. */
1270 xmlErrInternal(ctxt,
1271 "switching encoding: encoder error\n",
1272 NULL);
1273 xmlHaltParser(ctxt);
1274 return (-1);
1275 }
1276 }
1277 return (0);
1278}
int xmlBufIsEmpty(const xmlBufPtr buf)
Definition: buf.c:610
xmlBufPtr xmlBufCreate(void)
Definition: buf.c:122
XML_HIDDEN int xmlCharEncInput(xmlParserInputBufferPtr input)
XMLPUBFUN int xmlCharEncCloseFunc(xmlCharEncodingHandler *handler)
void xmlHaltParser(xmlParserCtxtPtr ctxt)
#define XML_INPUT_HAS_ENCODING
Definition: parser.h:20
static int processed(const type_t *type)
Definition: typegen.c:2524
XMLPUBFUN int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:277

Referenced by xmlSwitchEncoding(), and xmlSwitchToEncoding().

◆ xmlSwitchToEncoding()

XMLPUBFUN int xmlSwitchToEncoding ( xmlParserCtxtPtr  ctxt,
xmlCharEncodingHandlerPtr  handler 
)

xmlSwitchToEncoding: @ctxt: the parser context @handler: the encoding handler

Use encoding handler to decode input data.

This function can be used to enforce the encoding of chunks passed to xmlParseChunk.

Returns 0 in case of success, -1 otherwise

Definition at line 1293 of file parserInternals.c.

1294{
1295 if (ctxt == NULL)
1296 return(-1);
1297 return(xmlSwitchInputEncoding(ctxt, ctxt->input, handler));
1298}

Referenced by xmlCtxtResetPush(), xmlDoRead(), xmlParseInNodeContext(), and xmlSetDeclaredEncoding().

Variable Documentation

◆ xmlParserMaxDepth

XMLPUBVAR unsigned int xmlParserMaxDepth

xmlParserMaxDepth:

arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it.

Definition at line 32 of file parserInternals.h.

◆ xmlStringComment

XMLPUBVAR const xmlChar xmlStringComment[]

Definition at line 294 of file parserInternals.h.

◆ xmlStringText

XMLPUBVAR const xmlChar xmlStringText[]

Global variables used for predefined strings.

Definition at line 292 of file parserInternals.h.

Referenced by xmlSAX2Text(), xmlSAX2TextNode(), and xsltCopyTextString().

◆ xmlStringTextNoenc