ReactOS 0.4.15-dev-7934-g1dc8d80
parserInternals.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#include <libxml/chvalid.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_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 SKIP_EOL(p)
 
#define MOVETO_ENDTAG(p)    while ((*p) && (*(p) != '>')) (p)++
 
#define MOVETO_STARTTAG(p)    while ((*p) && (*(p) != '<')) (p)++
 
#define XML_SUBSTITUTE_NONE   0
 
#define XML_SUBSTITUTE_REF   1
 
#define XML_SUBSTITUTE_PEREF   2
 
#define XML_SUBSTITUTE_BOTH   3
 

Functions

XMLPUBFUN int XMLCALL xmlIsLetter (int c)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt (const char *filename)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateURLParserCtxt (const char *filename, int options)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateMemoryParserCtxt (const char *buffer, int size)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateEntityParserCtxt (const xmlChar *URL, const xmlChar *ID, const xmlChar *base)
 
XMLPUBFUN int XMLCALL xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
 
XMLPUBFUN int XMLCALL xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream (xmlParserCtxtPtr ctxt, const xmlChar *buffer)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
 
XMLPUBFUN int XMLCALL xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
 
XMLPUBFUN xmlChar XMLCALL xmlPopInput (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlFreeInputStream (xmlParserInputPtr input)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile (xmlParserCtxtPtr ctxt, const char *filename)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseNmtoken (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseAttValue (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseSystemLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParsePubidLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
 
XMLPUBFUN void XMLCALL xmlParseComment (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParsePITarget (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePI (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseNotationDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseEntityDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseNotationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN int XMLCALL xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN void XMLCALL xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN int XMLCALL xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
 
XMLPUBFUN int XMLCALL xmlParseElementDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMarkupDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseCharRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseContent (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseElement (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionNum (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionInfo (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEncName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseEncodingDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseSDDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseXMLDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseTextDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMisc (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value)
 
XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
 
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL namePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, const xmlChar *value)
 
XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len)
 
XMLPUBFUN void XMLCALL xmlParserHandlePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang)
 
XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, int *len)
 
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, int val)
 
XMLPUBFUN int XMLCALL xmlCopyChar (int len, xmlChar *out, int val)
 
XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL 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 89 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 260 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 250 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 153 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 135 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 143 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 105 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 117 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 125 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 181 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 189 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 163 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 171 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 202 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 210 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 221 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 232 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 241 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 271 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 279 of file parserInternals.h.

◆ MOVETO_ENDTAG

#define MOVETO_ENDTAG (   p)     while ((*p) && (*(p) != '>')) (p)++

MOVETO_ENDTAG: : and UTF8 string pointer

Skips to the next '>' char.

Definition at line 297 of file parserInternals.h.

◆ MOVETO_STARTTAG

#define MOVETO_STARTTAG (   p)     while ((*p) && (*(p) != '<')) (p)++

MOVETO_STARTTAG: : and UTF8 string pointer

Skips to the next '<' char.

Definition at line 306 of file parserInternals.h.

◆ SKIP_EOL

#define SKIP_EOL (   p)
Value:
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
GLfloat GLfloat p
Definition: glext.h:8902

SKIP_EOL: : and UTF8 string pointer

Skips the end of line chars.

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 63 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 73 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 53 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 81 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 41 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 520 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 502 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 514 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 508 of file parserInternals.h.

Function Documentation

◆ inputPop()

inputPop: @ctxt: an XML parser context

Pops the top parser input from the input stack

Returns the input just removed

Definition at line 1774 of file parser.c.

1775{
1777
1778 if (ctxt == NULL)
1779 return(NULL);
1780 if (ctxt->inputNr <= 0)
1781 return (NULL);
1782 ctxt->inputNr--;
1783 if (ctxt->inputNr > 0)
1784 ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1785 else
1786 ctxt->input = NULL;
1787 ret = ctxt->inputTab[ctxt->inputNr];
1788 ctxt->inputTab[ctxt->inputNr] = NULL;
1789 return (ret);
1790}
#define NULL
Definition: types.h:112
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
int ret

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

◆ inputPush()

XMLPUBFUN int XMLCALL 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 1745 of file parser.c.

1746{
1747 if ((ctxt == NULL) || (value == NULL))
1748 return(-1);
1749 if (ctxt->inputNr >= ctxt->inputMax) {
1750 ctxt->inputMax *= 2;
1751 ctxt->inputTab =
1753 ctxt->inputMax *
1754 sizeof(ctxt->inputTab[0]));
1755 if (ctxt->inputTab == NULL) {
1756 xmlErrMemory(ctxt, NULL);
1757 ctxt->inputMax /= 2;
1758 return (-1);
1759 }
1760 }
1761 ctxt->inputTab[ctxt->inputNr] = value;
1762 ctxt->input = value;
1763 return (ctxt->inputNr++);
1764}
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
int inputMax
Definition: parser.h:201
Definition: pdh_main.c:94

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

◆ namePop()

namePop: @ctxt: an XML parser context

Pops the top element name from the name stack

Returns the name just removed

Definition at line 1981 of file parser.c.

1982{
1983 const xmlChar *ret;
1984
1985 if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1986 return (NULL);
1987 ctxt->nameNr--;
1988 if (ctxt->nameNr > 0)
1989 ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1990 else
1991 ctxt->name = NULL;
1992 ret = ctxt->nameTab[ctxt->nameNr];
1993 ctxt->nameTab[ctxt->nameNr] = NULL;
1994 return (ret);
1995}
const xmlChar * name
Definition: parser.h:229
const xmlChar ** nameTab
Definition: parser.h:232
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlParseElementEnd(), and xmlParseElementStart().

◆ namePush()

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

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

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 1950 of file parser.c.

1951{
1952 if (ctxt == NULL) return (-1);
1953
1954 if (ctxt->nameNr >= ctxt->nameMax) {
1955 const xmlChar * *tmp;
1956 tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1957 ctxt->nameMax * 2 *
1958 sizeof(ctxt->nameTab[0]));
1959 if (tmp == NULL) {
1960 goto mem_error;
1961 }
1962 ctxt->nameTab = tmp;
1963 ctxt->nameMax *= 2;
1964 }
1965 ctxt->nameTab[ctxt->nameNr] = value;
1966 ctxt->name = value;
1967 return (ctxt->nameNr++);
1968mem_error:
1969 xmlErrMemory(ctxt, NULL);
1970 return (-1);
1971}

◆ nodePop()

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1839 of file parser.c.

1840{
1842
1843 if (ctxt == NULL) return(NULL);
1844 if (ctxt->nodeNr <= 0)
1845 return (NULL);
1846 ctxt->nodeNr--;
1847 if (ctxt->nodeNr > 0)
1848 ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1849 else
1850 ctxt->node = NULL;
1851 ret = ctxt->nodeTab[ctxt->nodeNr];
1852 ctxt->nodeTab[ctxt->nodeNr] = NULL;
1853 return (ret);
1854}
Definition: tree.h:489
xmlNodePtr * nodeTab
Definition: parser.h:208
xmlNodePtr node
Definition: parser.h:205

Referenced by xmlParseElementStart(), and xmlSAX2EndElementNs().

◆ nodePush()

XMLPUBFUN int XMLCALL nodePush ( xmlParserCtxtPtr  ctxt,
xmlNodePtr  value 
)

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

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 1801 of file parser.c.

1802{
1803 if (ctxt == NULL) return(0);
1804 if (ctxt->nodeNr >= ctxt->nodeMax) {
1805 xmlNodePtr *tmp;
1806
1807 tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1808 ctxt->nodeMax * 2 *
1809 sizeof(ctxt->nodeTab[0]));
1810 if (tmp == NULL) {
1811 xmlErrMemory(ctxt, NULL);
1812 return (-1);
1813 }
1814 ctxt->nodeTab = tmp;
1815 ctxt->nodeMax *= 2;
1816 }
1817 if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1818 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1819 xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1820 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1822 xmlHaltParser(ctxt);
1823 return(-1);
1824 }
1825 ctxt->nodeTab[ctxt->nodeNr] = value;
1826 ctxt->node = value;
1827 return (ctxt->nodeNr++);
1828}
@ XML_PARSE_HUGE
Definition: parser.h:1114
unsigned int xmlParserMaxDepth
Definition: parser.c:270
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101

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

◆ xmlCheckLanguageID()

XMLPUBFUN int XMLCALL xmlCheckLanguageID ( const xmlChar lang)

xmlCheckLanguageID: @lang: pointer to the string value

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 1474 of file parser.c.

1475{
1476 const xmlChar *cur = lang, *nxt;
1477
1478 if (cur == NULL)
1479 return (0);
1480 if (((cur[0] == 'i') && (cur[1] == '-')) ||
1481 ((cur[0] == 'I') && (cur[1] == '-')) ||
1482 ((cur[0] == 'x') && (cur[1] == '-')) ||
1483 ((cur[0] == 'X') && (cur[1] == '-'))) {
1484 /*
1485 * Still allow IANA code and user code which were coming
1486 * from the previous version of the XML-1.0 specification
1487 * it's deprecated but we should not fail
1488 */
1489 cur += 2;
1490 while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1491 ((cur[0] >= 'a') && (cur[0] <= 'z')))
1492 cur++;
1493 return(cur[0] == 0);
1494 }
1495 nxt = cur;
1496 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1497 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1498 nxt++;
1499 if (nxt - cur >= 4) {
1500 /*
1501 * Reserved
1502 */
1503 if ((nxt - cur > 8) || (nxt[0] != 0))
1504 return(0);
1505 return(1);
1506 }
1507 if (nxt - cur < 2)
1508 return(0);
1509 /* we got an ISO 639 code */
1510 if (nxt[0] == 0)
1511 return(1);
1512 if (nxt[0] != '-')
1513 return(0);
1514
1515 nxt++;
1516 cur = nxt;
1517 /* now we can have extlang or script or region or variant */
1518 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1519 goto region_m49;
1520
1521 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1522 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1523 nxt++;
1524 if (nxt - cur == 4)
1525 goto script;
1526 if (nxt - cur == 2)
1527 goto region;
1528 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1529 goto variant;
1530 if (nxt - cur != 3)
1531 return(0);
1532 /* we parsed an extlang */
1533 if (nxt[0] == 0)
1534 return(1);
1535 if (nxt[0] != '-')
1536 return(0);
1537
1538 nxt++;
1539 cur = nxt;
1540 /* now we can have script or region or variant */
1541 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1542 goto region_m49;
1543
1544 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1545 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1546 nxt++;
1547 if (nxt - cur == 2)
1548 goto region;
1549 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1550 goto variant;
1551 if (nxt - cur != 4)
1552 return(0);
1553 /* we parsed a script */
1554script:
1555 if (nxt[0] == 0)
1556 return(1);
1557 if (nxt[0] != '-')
1558 return(0);
1559
1560 nxt++;
1561 cur = nxt;
1562 /* now we can have region or variant */
1563 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1564 goto region_m49;
1565
1566 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1567 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1568 nxt++;
1569
1570 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1571 goto variant;
1572 if (nxt - cur != 2)
1573 return(0);
1574 /* we parsed a region */
1575region:
1576 if (nxt[0] == 0)
1577 return(1);
1578 if (nxt[0] != '-')
1579 return(0);
1580
1581 nxt++;
1582 cur = nxt;
1583 /* now we can just have a variant */
1584 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1585 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1586 nxt++;
1587
1588 if ((nxt - cur < 5) || (nxt - cur > 8))
1589 return(0);
1590
1591 /* we parsed a variant */
1592variant:
1593 if (nxt[0] == 0)
1594 return(1);
1595 if (nxt[0] != '-')
1596 return(0);
1597 /* extensions and private use subtags not checked */
1598 return (1);
1599
1600region_m49:
1601 if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1602 ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1603 nxt += 3;
1604 goto region;
1605 }
1606 return(0);
1607}
FxCollectionEntry * cur
script
Definition: msipriv.h:383
static const WCHAR lang[]
Definition: wbemdisp.c:287

Referenced by xmlParseAttribute2().

◆ xmlCopyChar()

XMLPUBFUN int XMLCALL 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 852 of file parserInternals.c.

852 {
853 if (out == NULL) return(0);
854 /* the len parameter is ignored */
855 if (val >= 0x80) {
856 return(xmlCopyCharMultiByte (out, val));
857 }
858 *out = (xmlChar) val;
859 return 1;
860}
GLuint GLfloat * val
Definition: glext.h:7180
int xmlCopyCharMultiByte(xmlChar *out, int val)
static FILE * out
Definition: regtests2xml.c:44

Referenced by xmlParseAttValueComplex().

◆ xmlCopyCharMultiByte()

XMLPUBFUN int XMLCALL 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 809 of file parserInternals.c.

809 {
810 if (out == NULL) return(0);
811 /*
812 * We are supposed to handle UTF8, check it's valid
813 * From rfc2044: encoding of the Unicode values on UTF-8:
814 *
815 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
816 * 0000 0000-0000 007F 0xxxxxxx
817 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
818 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
819 */
820 if (val >= 0x80) {
821 xmlChar *savedout = out;
822 int bits;
823 if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
824 else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
825 else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
826 else {
827 xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
828 "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
829 val);
830 return(0);
831 }
832 for ( ; bits >= 0; bits-= 6)
833 *out++= ((val >> bits) & 0x3F) | 0x80 ;
834 return (out - savedout);
835 }
836 *out = (xmlChar) val;
837 return 1;
838}
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 XMLCALL 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 14027 of file parser.c.

14028 {
14030
14031}
#define ID
Definition: ruserpass.c:36
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13954

◆ xmlCreateFileParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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 14093 of file parser.c.

14094{
14095 return(xmlCreateURLParserCtxt(filename, 0));
14096}
const char * filename
Definition: ioapi.h:137
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14051

◆ xmlCreateMemoryParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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 14339 of file parser.c.

14339 {
14340 xmlParserCtxtPtr ctxt;
14343
14344 if (buffer == NULL)
14345 return(NULL);
14346 if (size <= 0)
14347 return(NULL);
14348
14349 ctxt = xmlNewParserCtxt();
14350 if (ctxt == NULL)
14351 return(NULL);
14352
14353 /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14355 if (buf == NULL) {
14356 xmlFreeParserCtxt(ctxt);
14357 return(NULL);
14358 }
14359
14360 input = xmlNewInputStream(ctxt);
14361 if (input == NULL) {
14363 xmlFreeParserCtxt(ctxt);
14364 return(NULL);
14365 }
14366
14367 input->filename = NULL;
14368 input->buf = buf;
14369 xmlBufResetInput(input->buf->buffer, input);
14370
14371 inputPush(ctxt, input);
14372 return(ctxt);
14373}
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:58
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)

Referenced by xmlCreateDocParserCtxt(), xmlParseBalancedChunkMemoryInternal(), xmlParseInNodeContext(), and xmlReadMemory().

◆ xmlCreateURLParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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 14051 of file parser.c.

14052{
14053 xmlParserCtxtPtr ctxt;
14054 xmlParserInputPtr inputStream;
14055 char *directory = NULL;
14056
14057 ctxt = xmlNewParserCtxt();
14058 if (ctxt == NULL) {
14059 xmlErrMemory(NULL, "cannot allocate parser context");
14060 return(NULL);
14061 }
14062
14063 if (options)
14065 ctxt->linenumbers = 1;
14066
14067 inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14068 if (inputStream == NULL) {
14069 xmlFreeParserCtxt(ctxt);
14070 return(NULL);
14071 }
14072
14073 inputPush(ctxt, inputStream);
14074 if ((ctxt->directory == NULL) && (directory == NULL))
14076 if ((ctxt->directory == NULL) && (directory != NULL))
14077 ctxt->directory = directory;
14078
14079 return(ctxt);
14080}
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
char * directory
Definition: parser.h:226
int linenumbers
Definition: parser.h:259
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCurrentChar()

XMLPUBFUN int XMLCALL xmlCurrentChar ( xmlParserCtxtPtr  ctxt,
int len 
)

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

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 542 of file parserInternals.c.

542 {
543 if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
544 if (ctxt->instate == XML_PARSER_EOF)
545 return(0);
546
547 if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
548 *len = 1;
549 return((int) *ctxt->input->cur);
550 }
551 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
552 /*
553 * We are supposed to handle UTF8, check it's valid
554 * From rfc2044: encoding of the Unicode values on UTF-8:
555 *
556 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
557 * 0000 0000-0000 007F 0xxxxxxx
558 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
559 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
560 *
561 * Check for the 0x110000 limit too
562 */
563 const unsigned char *cur = ctxt->input->cur;
564 unsigned char c;
565 unsigned int val;
566
567 c = *cur;
568 if (c & 0x80) {
569 if (((c & 0x40) == 0) || (c == 0xC0))
570 goto encoding_error;
571 if (cur[1] == 0) {
573 cur = ctxt->input->cur;
574 }
575 if ((cur[1] & 0xc0) != 0x80)
576 goto encoding_error;
577 if ((c & 0xe0) == 0xe0) {
578 if (cur[2] == 0) {
580 cur = ctxt->input->cur;
581 }
582 if ((cur[2] & 0xc0) != 0x80)
583 goto encoding_error;
584 if ((c & 0xf0) == 0xf0) {
585 if (cur[3] == 0) {
587 cur = ctxt->input->cur;
588 }
589 if (((c & 0xf8) != 0xf0) ||
590 ((cur[3] & 0xc0) != 0x80))
591 goto encoding_error;
592 /* 4-byte code */
593 *len = 4;
594 val = (cur[0] & 0x7) << 18;
595 val |= (cur[1] & 0x3f) << 12;
596 val |= (cur[2] & 0x3f) << 6;
597 val |= cur[3] & 0x3f;
598 if (val < 0x10000)
599 goto encoding_error;
600 } else {
601 /* 3-byte code */
602 *len = 3;
603 val = (cur[0] & 0xf) << 12;
604 val |= (cur[1] & 0x3f) << 6;
605 val |= cur[2] & 0x3f;
606 if (val < 0x800)
607 goto encoding_error;
608 }
609 } else {
610 /* 2-byte code */
611 *len = 2;
612 val = (cur[0] & 0x1f) << 6;
613 val |= cur[1] & 0x3f;
614 if (val < 0x80)
615 goto encoding_error;
616 }
617 if (!IS_CHAR(val)) {
618 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
619 "Char 0x%X out of allowed range\n", val);
620 }
621 return(val);
622 } else {
623 /* 1-byte code */
624 *len = 1;
625 if (*ctxt->input->cur == 0)
627 if ((*ctxt->input->cur == 0) &&
628 (ctxt->input->end > ctxt->input->cur)) {
629 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
630 "Char 0x0 out of allowed range\n", 0);
631 }
632 if (*ctxt->input->cur == 0xD) {
633 if (ctxt->input->cur[1] == 0xA) {
634 ctxt->input->cur++;
635 }
636 return(0xA);
637 }
638 return((int) *ctxt->input->cur);
639 }
640 }
641 /*
642 * Assume it's a fixed length encoding (1) with
643 * a compatible encoding for the ASCII set, since
644 * XML constructs only use < 128 chars
645 */
646 *len = 1;
647 if (*ctxt->input->cur == 0xD) {
648 if (ctxt->input->cur[1] == 0xA) {
649 ctxt->input->cur++;
650 }
651 return(0xA);
652 }
653 return((int) *ctxt->input->cur);
654encoding_error:
655 /*
656 * An encoding problem may arise from a truncated input buffer
657 * splitting a character in the middle. In that case do not raise
658 * an error but return 0 to indicate an end of stream problem
659 */
660 if (ctxt->input->end - ctxt->input->cur < 4) {
661 *len = 0;
662 return(0);
663 }
664
665 /*
666 * If we detect an UTF8 error that probably mean that the
667 * input encoding didn't get properly advertised in the
668 * declaration header. Report the error and switch the encoding
669 * to ISO-Latin-1 (if you don't like this policy, just declare the
670 * encoding !)
671 */
672 {
673 char buffer[150];
674
675 snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
676 ctxt->input->cur[0], ctxt->input->cur[1],
677 ctxt->input->cur[2], ctxt->input->cur[3]);
679 "Input is not proper UTF-8, indicate encoding !\n%s",
681 }
683 *len = 1;
684 return((int) *ctxt->input->cur);
685}
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:59
@ XML_CHAR_ENCODING_8859_1
Definition: encoding.h:68
GLenum GLsizei len
Definition: glext.h:6722
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define IS_CHAR(c)
#define INPUT_CHUNK
@ XML_PARSER_EOF
Definition: parser.h:111
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * end
Definition: parser.h:60
const xmlChar * cur
Definition: parser.h:59
#define snprintf
Definition: wintirpc.h:48
#define BAD_CAST
Definition: xmlstring.h:35

◆ xmlFreeInputStream()

XMLPUBFUN void XMLCALL xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1192 of file parserInternals.c.

1192 {
1193 if (input == NULL) return;
1194
1195 if (input->filename != NULL) xmlFree((char *) input->filename);
1196 if (input->directory != NULL) xmlFree((char *) input->directory);
1197 if (input->encoding != NULL) xmlFree((char *) input->encoding);
1198 if (input->version != NULL) xmlFree((char *) input->version);
1199 if ((input->free != NULL) && (input->base != NULL))
1200 input->free((xmlChar *) input->base);
1201 if (input->buf != NULL)
1203 xmlFree(input);
1204}
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251

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

◆ xmlIsLetter()

XMLPUBFUN int XMLCALL 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 213 of file parserInternals.c.

213 {
214 return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
215}
#define IS_IDEOGRAPHIC(c)
#define IS_BASECHAR(c)

◆ xmlNewEntityInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream ( xmlParserCtxtPtr  ctxt,
xmlEntityPtr  entity 
)

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

Create a new input stream based on an xmlEntityPtr

Returns the new input stream or NULL

Definition at line 1283 of file parserInternals.c.

1283 {
1285
1286 if (entity == NULL) {
1287 xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1288 NULL);
1289 return(NULL);
1290 }
1293 "new input from entity: %s\n", entity->name);
1294 if (entity->content == NULL) {
1295 switch (entity->etype) {
1297 xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1298 entity->name);
1299 break;
1302 return(xmlLoadExternalEntity((char *) entity->URI,
1303 (char *) entity->ExternalID, ctxt));
1305 xmlErrInternal(ctxt,
1306 "Internal entity %s without content !\n",
1307 entity->name);
1308 break;
1310 xmlErrInternal(ctxt,
1311 "Internal parameter entity %s without content !\n",
1312 entity->name);
1313 break;
1315 xmlErrInternal(ctxt,
1316 "Predefined entity %s without content !\n",
1317 entity->name);
1318 break;
1319 }
1320 return(NULL);
1321 }
1322 input = xmlNewInputStream(ctxt);
1323 if (input == NULL) {
1324 return(NULL);
1325 }
1326 if (entity->URI != NULL)
1327 input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1328 input->base = entity->content;
1329 if (entity->length == 0)
1330 entity->length = xmlStrlen(entity->content);
1331 input->cur = entity->content;
1332 input->length = entity->length;
1333 input->end = &entity->content[input->length];
1334 return(input);
1335}
@ XML_EXTERNAL_GENERAL_PARSED_ENTITY
Definition: entities.h:26
@ XML_INTERNAL_PREDEFINED_ENTITY
Definition: entities.h:30
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
Definition: entities.h:27
@ XML_INTERNAL_GENERAL_ENTITY
Definition: entities.h:25
@ XML_INTERNAL_PARAMETER_ENTITY
Definition: entities.h:28
@ XML_EXTERNAL_PARAMETER_ENTITY
Definition: entities.h:29
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
Definition: actctx.c:388
WCHAR * name
Definition: actctx.c:405
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426

Referenced by xmlLoadEntityContent(), and xmlParsePEReference().

◆ xmlNewInputFromFile()

XMLPUBFUN xmlParserInputPtr XMLCALL 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 1379 of file parserInternals.c.

1379 {
1381 xmlParserInputPtr inputStream;
1382 char *directory = NULL;
1383 xmlChar *URI = NULL;
1384
1387 "new input from file: %s\n", filename);
1388 if (ctxt == NULL) return(NULL);
1390 if (buf == NULL) {
1391 if (filename == NULL)
1392 __xmlLoaderErr(ctxt,
1393 "failed to load external entity: NULL filename \n",
1394 NULL);
1395 else
1396 __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1397 (const char *) filename);
1398 return(NULL);
1399 }
1400
1401 inputStream = xmlNewInputStream(ctxt);
1402 if (inputStream == NULL) {
1404 return(NULL);
1405 }
1406
1407 inputStream->buf = buf;
1408 inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1409 if (inputStream == NULL)
1410 return(NULL);
1411
1412 if (inputStream->filename == NULL)
1413 URI = xmlStrdup((xmlChar *) filename);
1414 else
1415 URI = xmlStrdup((xmlChar *) inputStream->filename);
1416 directory = xmlParserGetDirectory((const char *) URI);
1417 if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1418 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1419 if (URI != NULL) xmlFree((char *) URI);
1420 inputStream->directory = directory;
1421
1422 xmlBufResetInput(inputStream->buf->buffer, inputStream);
1423 if ((ctxt->directory == NULL) && (directory != NULL))
1424 ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1425 return(inputStream);
1426}
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
xmlBufPtr buffer
Definition: xmlIO.h:132
const char * filename
Definition: parser.h:56
xmlParserInputBufferPtr buf
Definition: parser.h:54
const char * directory
Definition: parser.h:57
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2380
XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)

◆ xmlNewInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL 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 1215 of file parserInternals.c.

1215 {
1217
1219 if (input == NULL) {
1220 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1221 return(NULL);
1222 }
1223 memset(input, 0, sizeof(xmlParserInput));
1224 input->line = 1;
1225 input->col = 1;
1226 input->standalone = -1;
1227
1228 /*
1229 * If the context is NULL the id cannot be initialized, but that
1230 * should not happen while parsing which is the situation where
1231 * the id is actually needed.
1232 */
1233 if (ctxt != NULL)
1234 input->id = ctxt->input_id++;
1235
1236 return(input);
1237}
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
xmlParserInput * xmlParserInputPtr
Definition: tree.h:36
#define memset(x, y, z)
Definition: compat.h:39
int input_id
Definition: parser.h:312

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

◆ xmlNewStringInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL 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 1346 of file parserInternals.c.

1346 {
1348
1349 if (buffer == NULL) {
1350 xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1351 NULL);
1352 return(NULL);
1353 }
1356 "new fixed input: %.30s\n", buffer);
1357 input = xmlNewInputStream(ctxt);
1358 if (input == NULL) {
1359 xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1360 return(NULL);
1361 }
1362 input->base = buffer;
1363 input->cur = buffer;
1364 input->length = xmlStrlen(buffer);
1365 input->end = &buffer[input->length];
1366 return(input);
1367}

◆ xmlNextChar()

XMLPUBFUN void XMLCALL xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

Skip to the next char input char.

Definition at line 380 of file parserInternals.c.

381{
382 if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
383 (ctxt->input == NULL))
384 return;
385
386 if (!(VALID_CTXT(ctxt))) {
387 xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
389 xmlStopParser(ctxt);
390 return;
391 }
392
393 if ((*ctxt->input->cur == 0) &&
394 (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
395 return;
396 }
397
398 if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
399 const unsigned char *cur;
400 unsigned char c;
401
402 /*
403 * 2.11 End-of-Line Handling
404 * the literal two-character sequence "#xD#xA" or a standalone
405 * literal #xD, an XML processor must pass to the application
406 * the single character #xA.
407 */
408 if (*(ctxt->input->cur) == '\n') {
409 ctxt->input->line++; ctxt->input->col = 1;
410 } else
411 ctxt->input->col++;
412
413 /*
414 * We are supposed to handle UTF8, check it's valid
415 * From rfc2044: encoding of the Unicode values on UTF-8:
416 *
417 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
418 * 0000 0000-0000 007F 0xxxxxxx
419 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
420 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
421 *
422 * Check for the 0x110000 limit too
423 */
424 cur = ctxt->input->cur;
425
426 c = *cur;
427 if (c & 0x80) {
428 if (c == 0xC0)
429 goto encoding_error;
430 if (cur[1] == 0) {
432 cur = ctxt->input->cur;
433 }
434 if ((cur[1] & 0xc0) != 0x80)
435 goto encoding_error;
436 if ((c & 0xe0) == 0xe0) {
437 unsigned int val;
438
439 if (cur[2] == 0) {
441 cur = ctxt->input->cur;
442 }
443 if ((cur[2] & 0xc0) != 0x80)
444 goto encoding_error;
445 if ((c & 0xf0) == 0xf0) {
446 if (cur[3] == 0) {
448 cur = ctxt->input->cur;
449 }
450 if (((c & 0xf8) != 0xf0) ||
451 ((cur[3] & 0xc0) != 0x80))
452 goto encoding_error;
453 /* 4-byte code */
454 ctxt->input->cur += 4;
455 val = (cur[0] & 0x7) << 18;
456 val |= (cur[1] & 0x3f) << 12;
457 val |= (cur[2] & 0x3f) << 6;
458 val |= cur[3] & 0x3f;
459 } else {
460 /* 3-byte code */
461 ctxt->input->cur += 3;
462 val = (cur[0] & 0xf) << 12;
463 val |= (cur[1] & 0x3f) << 6;
464 val |= cur[2] & 0x3f;
465 }
466 if (((val > 0xd7ff) && (val < 0xe000)) ||
467 ((val > 0xfffd) && (val < 0x10000)) ||
468 (val >= 0x110000)) {
469 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
470 "Char 0x%X out of allowed range\n",
471 val);
472 }
473 } else
474 /* 2-byte code */
475 ctxt->input->cur += 2;
476 } else
477 /* 1-byte code */
478 ctxt->input->cur++;
479 } else {
480 /*
481 * Assume it's a fixed length encoding (1) with
482 * a compatible encoding for the ASCII set, since
483 * XML constructs only use < 128 chars
484 */
485
486 if (*(ctxt->input->cur) == '\n') {
487 ctxt->input->line++; ctxt->input->col = 1;
488 } else
489 ctxt->input->col++;
490 ctxt->input->cur++;
491 }
492 if (*ctxt->input->cur == 0)
494 return;
495encoding_error:
496 /*
497 * If we detect an UTF8 error that probably mean that the
498 * input encoding didn't get properly advertised in the
499 * declaration header. Report the error and switch the encoding
500 * to ISO-Latin-1 (if you don't like this policy, just declare the
501 * encoding !)
502 */
503 if ((ctxt == NULL) || (ctxt->input == NULL) ||
504 (ctxt->input->end - ctxt->input->cur < 4)) {
506 "Input is not proper UTF-8, indicate encoding !\n",
507 NULL, NULL);
508 } else {
509 char buffer[150];
510
511 snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
512 ctxt->input->cur[0], ctxt->input->cur[1],
513 ctxt->input->cur[2], ctxt->input->cur[3]);
515 "Input is not proper UTF-8, indicate encoding !\n%s",
517 }
519 ctxt->input->cur++;
520 return;
521}
#define VALID_CTXT(ctxt)
XMLPUBFUN void XMLCALL xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12583

◆ xmlParseAttributeListDecl()

XMLPUBFUN void XMLCALL xmlParseAttributeListDecl ( xmlParserCtxtPtr  ctxt)

xmlParseAttributeListDecl: @ctxt: an XML parser context

: parse the Attribute list def for an element

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

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

Definition at line 5976 of file parser.c.

5976 {
5977 const xmlChar *elemName;
5978 const xmlChar *attrName;
5980
5981 if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5982 int inputid = ctxt->input->id;
5983
5984 SKIP(9);
5985 if (SKIP_BLANKS == 0) {
5986 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5987 "Space required after '<!ATTLIST'\n");
5988 }
5989 elemName = xmlParseName(ctxt);
5990 if (elemName == NULL) {
5991 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5992 "ATTLIST: no name for Element\n");
5993 return;
5994 }
5996 GROW;
5997 while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5998 int type;
5999 int def;
6000 xmlChar *defaultValue = NULL;
6001
6002 GROW;
6003 tree = NULL;
6004 attrName = xmlParseName(ctxt);
6005 if (attrName == NULL) {
6006 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6007 "ATTLIST: no name for Attribute\n");
6008 break;
6009 }
6010 GROW;
6011 if (SKIP_BLANKS == 0) {
6012 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6013 "Space required after the attribute name\n");
6014 break;
6015 }
6016
6018 if (type <= 0) {
6019 break;
6020 }
6021
6022 GROW;
6023 if (SKIP_BLANKS == 0) {
6024 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6025 "Space required after the attribute type\n");
6026 if (tree != NULL)
6028 break;
6029 }
6030
6031 def = xmlParseDefaultDecl(ctxt, &defaultValue);
6032 if (def <= 0) {
6033 if (defaultValue != NULL)
6034 xmlFree(defaultValue);
6035 if (tree != NULL)
6037 break;
6038 }
6039 if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
6040 xmlAttrNormalizeSpace(defaultValue, defaultValue);
6041
6042 GROW;
6043 if (RAW != '>') {
6044 if (SKIP_BLANKS == 0) {
6045 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6046 "Space required after the attribute default value\n");
6047 if (defaultValue != NULL)
6048 xmlFree(defaultValue);
6049 if (tree != NULL)
6051 break;
6052 }
6053 }
6054 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6055 (ctxt->sax->attributeDecl != NULL))
6056 ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6057 type, def, defaultValue, tree);
6058 else if (tree != NULL)
6060
6061 if ((ctxt->sax2) && (defaultValue != NULL) &&
6062 (def != XML_ATTRIBUTE_IMPLIED) &&
6063 (def != XML_ATTRIBUTE_REQUIRED)) {
6064 xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6065 }
6066 if (ctxt->sax2) {
6067 xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6068 }
6069 if (defaultValue != NULL)
6070 xmlFree(defaultValue);
6071 GROW;
6072 }
6073 if (RAW == '>') {
6074 if (inputid != ctxt->input->id) {
6075 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6076 "Attribute list declaration doesn't start and"
6077 " stop in the same entity\n");
6078 }
6079 NEXT;
6080 }
6081 }
6082}
struct _tree tree
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ XML_ATTRIBUTE_CDATA
Definition: tree.h:207
@ XML_ATTRIBUTE_REQUIRED
Definition: tree.h:227
@ XML_ATTRIBUTE_IMPLIED
Definition: tree.h:228
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5682
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1242
#define NEXT
Definition: parser.c:2147
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1152
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
#define SKIP_BLANKS
Definition: parser.c:2145
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5934
#define RAW
Definition: parser.c:2064
#define GROW
Definition: parser.c:2117
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1353
#define SKIP(val)
Definition: parser.c:2088
#define CUR_PTR
Definition: parser.c:2067
int disableSAX
Definition: parser.h:237
struct _xmlSAXHandler * sax
Definition: parser.h:185
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817
@ 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()

XMLPUBFUN int XMLCALL xmlParseAttributeType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr tree 
)

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

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 5934 of file parser.c.

5934 {
5935 SHRINK;
5936 if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5937 SKIP(5);
5938 return(XML_ATTRIBUTE_CDATA);
5939 } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5940 SKIP(6);
5941 return(XML_ATTRIBUTE_IDREFS);
5942 } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5943 SKIP(5);
5944 return(XML_ATTRIBUTE_IDREF);
5945 } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5946 SKIP(2);
5947 return(XML_ATTRIBUTE_ID);
5948 } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5949 SKIP(6);
5950 return(XML_ATTRIBUTE_ENTITY);
5951 } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5952 SKIP(8);
5953 return(XML_ATTRIBUTE_ENTITIES);
5954 } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5955 SKIP(8);
5956 return(XML_ATTRIBUTE_NMTOKENS);
5957 } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5958 SKIP(7);
5959 return(XML_ATTRIBUTE_NMTOKEN);
5960 }
5961 return(xmlParseEnumeratedType(ctxt, tree));
5962}
@ XML_ATTRIBUTE_NMTOKENS
Definition: tree.h:214
@ XML_ATTRIBUTE_IDREF
Definition: tree.h:209
@ XML_ATTRIBUTE_ENTITIES
Definition: tree.h:212
@ XML_ATTRIBUTE_IDREFS
Definition: tree.h:210
@ XML_ATTRIBUTE_ID
Definition: tree.h:208
@ XML_ATTRIBUTE_NMTOKEN
Definition: tree.h:213
@ XML_ATTRIBUTE_ENTITY
Definition: tree.h:211
#define SHRINK
Definition: parser.c:2106
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2077
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5871
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2073
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2075
#define NXT(val)
Definition: parser.c:2066

Referenced by xmlParseAttributeListDecl().

◆ xmlParseAttValue()

XMLPUBFUN xmlChar *XMLCALL xmlParseAttValue ( xmlParserCtxtPtr  ctxt)

xmlParseAttValue: @ctxt: an XML parser context

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 4182 of file parser.c.

4182 {
4183 if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4184 return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4185}
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8960

Referenced by xmlParseDefaultDecl().

◆ xmlParseCDSect()

XMLPUBFUN void XMLCALL xmlParseCDSect ( xmlParserCtxtPtr  ctxt)

xmlParseCDSect: @ctxt: an XML parser context

Parse escaped pure raw content.

[18] CDSect ::= CDStart CData CDEnd

[19] CDStart ::= ''

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

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

Definition at line 9765 of file parser.c.

9765 {
9766 xmlChar *buf = NULL;
9767 int len = 0;
9769 int r, rl;
9770 int s, sl;
9771 int cur, l;
9772 int count = 0;
9773 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
9776
9777 /* Check 2.6.0 was NXT(0) not RAW */
9778 if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9779 SKIP(9);
9780 } else
9781 return;
9782
9784 r = CUR_CHAR(rl);
9785 if (!IS_CHAR(r)) {
9788 return;
9789 }
9790 NEXTL(rl);
9791 s = CUR_CHAR(sl);
9792 if (!IS_CHAR(s)) {
9795 return;
9796 }
9797 NEXTL(sl);
9798 cur = CUR_CHAR(l);
9799 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9800 if (buf == NULL) {
9801 xmlErrMemory(ctxt, NULL);
9802 return;
9803 }
9804 while (IS_CHAR(cur) &&
9805 ((r != ']') || (s != ']') || (cur != '>'))) {
9806 if (len + 5 >= size) {
9807 xmlChar *tmp;
9808
9809 tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9810 if (tmp == NULL) {
9811 xmlFree(buf);
9812 xmlErrMemory(ctxt, NULL);
9813 return;
9814 }
9815 buf = tmp;
9816 size *= 2;
9817 }
9818 COPY_BUF(rl,buf,len,r);
9819 r = s;
9820 rl = sl;
9821 s = cur;
9822 sl = l;
9823 count++;
9824 if (count > 50) {
9825 SHRINK;
9826 GROW;
9827 if (ctxt->instate == XML_PARSER_EOF) {
9828 xmlFree(buf);
9829 return;
9830 }
9831 count = 0;
9832 }
9833 NEXTL(l);
9834 cur = CUR_CHAR(l);
9835 if (len > maxLength) {
9836 xmlFatalErrMsg(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9837 "CData section too big found\n");
9838 xmlFree(buf);
9839 return;
9840 }
9841 }
9842 buf[len] = 0;
9844 if (cur != '>') {
9845 xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9846 "CData section not finished\n%.50s\n", buf);
9847 xmlFree(buf);
9848 return;
9849 }
9850 NEXTL(l);
9851
9852 /*
9853 * OK the buffer is to be consumed as cdata.
9854 */
9855 if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9856 if (ctxt->sax->cdataBlock != NULL)
9857 ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9858 else if (ctxt->sax->characters != NULL)
9859 ctxt->sax->characters(ctxt->userData, buf, len);
9860 }
9861 xmlFree(buf);
9862}
r l[0]
Definition: byte_order.h:168
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei maxLength
Definition: glext.h:6877
#define XML_MAX_TEXT_LENGTH
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
@ XML_PARSER_CONTENT
Definition: parser.h:119
@ XML_PARSER_CDATA_SECTION
Definition: parser.h:120
#define NEXTL(l)
Definition: parser.c:2156
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:276
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2166
#define CUR_CHAR(l)
Definition: parser.c:2163
#define XML_MAX_HUGE_LENGTH
Definition: parser.c:105
@ XML_ERR_CDATA_NOT_FINISHED
Definition: xmlerror.h:163

Referenced by xmlParseContentInternal().

◆ xmlParseCharData()

XMLPUBFUN void XMLCALL xmlParseCharData ( xmlParserCtxtPtr  ctxt,
int  cdata 
)

xmlParseCharData: @ctxt: an XML parser context @cdata: int indicating whether we are within a CDATA section

parse a CharData section. if we are within a CDATA section ']]>' marks an end of section.

The right angle bracket (>) may be represented using the string "&gt;", and must, for compatibility, be escaped using "&gt;" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section.

[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

Definition at line 4425 of file parser.c.

4425 {
4426 const xmlChar *in;
4427 int nbchar = 0;
4428 int line = ctxt->input->line;
4429 int col = ctxt->input->col;
4430 int ccol;
4431
4432 SHRINK;
4433 GROW;
4434 /*
4435 * Accelerated common case where input don't need to be
4436 * modified before passing it to the handler.
4437 */
4438 if (!cdata) {
4439 in = ctxt->input->cur;
4440 do {
4441get_more_space:
4442 while (*in == 0x20) { in++; ctxt->input->col++; }
4443 if (*in == 0xA) {
4444 do {
4445 ctxt->input->line++; ctxt->input->col = 1;
4446 in++;
4447 } while (*in == 0xA);
4448 goto get_more_space;
4449 }
4450 if (*in == '<') {
4451 nbchar = in - ctxt->input->cur;
4452 if (nbchar > 0) {
4453 const xmlChar *tmp = ctxt->input->cur;
4454 ctxt->input->cur = in;
4455
4456 if ((ctxt->sax != NULL) &&
4457 (ctxt->sax->ignorableWhitespace !=
4458 ctxt->sax->characters)) {
4459 if (areBlanks(ctxt, tmp, nbchar, 1)) {
4460 if (ctxt->sax->ignorableWhitespace != NULL)
4461 ctxt->sax->ignorableWhitespace(ctxt->userData,
4462 tmp, nbchar);
4463 } else {
4464 if (ctxt->sax->characters != NULL)
4465 ctxt->sax->characters(ctxt->userData,
4466 tmp, nbchar);
4467 if (*ctxt->space == -1)
4468 *ctxt->space = -2;
4469 }
4470 } else if ((ctxt->sax != NULL) &&
4471 (ctxt->sax->characters != NULL)) {
4472 ctxt->sax->characters(ctxt->userData,
4473 tmp, nbchar);
4474 }
4475 }
4476 return;
4477 }
4478
4479get_more:
4480 ccol = ctxt->input->col;
4481 while (test_char_data[*in]) {
4482 in++;
4483 ccol++;
4484 }
4485 ctxt->input->col = ccol;
4486 if (*in == 0xA) {
4487 do {
4488 ctxt->input->line++; ctxt->input->col = 1;
4489 in++;
4490 } while (*in == 0xA);
4491 goto get_more;
4492 }
4493 if (*in == ']') {
4494 if ((in[1] == ']') && (in[2] == '>')) {
4496 ctxt->input->cur = in + 1;
4497 return;
4498 }
4499 in++;
4500 ctxt->input->col++;
4501 goto get_more;
4502 }
4503 nbchar = in - ctxt->input->cur;
4504 if (nbchar > 0) {
4505 if ((ctxt->sax != NULL) &&
4506 (ctxt->sax->ignorableWhitespace !=
4507 ctxt->sax->characters) &&
4508 (IS_BLANK_CH(*ctxt->input->cur))) {
4509 const xmlChar *tmp = ctxt->input->cur;
4510 ctxt->input->cur = in;
4511
4512 if (areBlanks(ctxt, tmp, nbchar, 0)) {
4513 if (ctxt->sax->ignorableWhitespace != NULL)
4514 ctxt->sax->ignorableWhitespace(ctxt->userData,
4515 tmp, nbchar);
4516 } else {
4517 if (ctxt->sax->characters != NULL)
4518 ctxt->sax->characters(ctxt->userData,
4519 tmp, nbchar);
4520 if (*ctxt->space == -1)
4521 *ctxt->space = -2;
4522 }
4523 line = ctxt->input->line;
4524 col = ctxt->input->col;
4525 } else if (ctxt->sax != NULL) {
4526 if (ctxt->sax->characters != NULL)
4527 ctxt->sax->characters(ctxt->userData,
4528 ctxt->input->cur, nbchar);
4529 line = ctxt->input->line;
4530 col = ctxt->input->col;
4531 }
4532 /* something really bad happened in the SAX callback */
4533 if (ctxt->instate != XML_PARSER_CONTENT)
4534 return;
4535 }
4536 ctxt->input->cur = in;
4537 if (*in == 0xD) {
4538 in++;
4539 if (*in == 0xA) {
4540 ctxt->input->cur = in;
4541 in++;
4542 ctxt->input->line++; ctxt->input->col = 1;
4543 continue; /* while */
4544 }
4545 in--;
4546 }
4547 if (*in == '<') {
4548 return;
4549 }
4550 if (*in == '&') {
4551 return;
4552 }
4553 SHRINK;
4554 GROW;
4555 if (ctxt->instate == XML_PARSER_EOF)
4556 return;
4557 in = ctxt->input->cur;
4558 } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
4559 nbchar = 0;
4560 }
4561 ctxt->input->line = line;
4562 ctxt->input->col = col;
4563 xmlParseCharDataComplex(ctxt, cdata);
4564}
GLuint in
Definition: glext.h:9616
#define IS_BLANK_CH(c)
static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
Definition: parser.c:2864
static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4576
static const unsigned char test_char_data[256]
Definition: parser.c:4373
int * space
Definition: parser.h:244
Definition: parser.c:49
@ XML_ERR_MISPLACED_CDATA_END
Definition: xmlerror.h:162

Referenced by xmlParseContentInternal().

◆ xmlParseCharRef()

XMLPUBFUN int XMLCALL xmlParseCharRef ( xmlParserCtxtPtr  ctxt)

xmlParseCharRef: @ctxt: an XML parser context

parse Reference declarations

[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 2332 of file parser.c.

2332 {
2333 int val = 0;
2334 int count = 0;
2335
2336 /*
2337 * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2338 */
2339 if ((RAW == '&') && (NXT(1) == '#') &&
2340 (NXT(2) == 'x')) {
2341 SKIP(3);
2342 GROW;
2343 while (RAW != ';') { /* loop blocked by count */
2344 if (count++ > 20) {
2345 count = 0;
2346 GROW;
2347 if (ctxt->instate == XML_PARSER_EOF)
2348 return(0);
2349 }
2350 if ((RAW >= '0') && (RAW <= '9'))
2351 val = val * 16 + (CUR - '0');
2352 else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2353 val = val * 16 + (CUR - 'a') + 10;
2354 else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2355 val = val * 16 + (CUR - 'A') + 10;
2356 else {
2358 val = 0;
2359 break;
2360 }
2361 if (val > 0x110000)
2362 val = 0x110000;
2363
2364 NEXT;
2365 count++;
2366 }
2367 if (RAW == ';') {
2368 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2369 ctxt->input->col++;
2370 ctxt->input->cur++;
2371 }
2372 } else if ((RAW == '&') && (NXT(1) == '#')) {
2373 SKIP(2);
2374 GROW;
2375 while (RAW != ';') { /* loop blocked by count */
2376 if (count++ > 20) {
2377 count = 0;
2378 GROW;
2379 if (ctxt->instate == XML_PARSER_EOF)
2380 return(0);
2381 }
2382 if ((RAW >= '0') && (RAW <= '9'))
2383 val = val * 10 + (CUR - '0');
2384 else {
2386 val = 0;
2387 break;
2388 }
2389 if (val > 0x110000)
2390 val = 0x110000;
2391
2392 NEXT;
2393 count++;
2394 }
2395 if (RAW == ';') {
2396 /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2397 ctxt->input->col++;
2398 ctxt->input->cur++;
2399 }
2400 } else {
2402 }
2403
2404 /*
2405 * [ WFC: Legal Character ]
2406 * Characters referred to using character references must match the
2407 * production for Char.
2408 */
2409 if (val >= 0x110000) {
2410 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2411 "xmlParseCharRef: character reference out of bounds\n",
2412 val);
2413 } else if (IS_CHAR(val)) {
2414 return(val);
2415 } else {
2416 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2417 "xmlParseCharRef: invalid xmlChar value %d\n",
2418 val);
2419 }
2420 return(0);
2421}
#define CUR
Definition: parser.c:2065
@ 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()

XMLPUBFUN void XMLCALL xmlParseComment ( xmlParserCtxtPtr  ctxt)

xmlParseComment: @ctxt: an XML parser context

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

[15] Comment ::= ''

Definition at line 4888 of file parser.c.

4888 {
4889 xmlChar *buf = NULL;
4891 size_t len = 0;
4892 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4896 const xmlChar *in;
4897 size_t nbchar = 0;
4898 int ccol;
4899 int inputid;
4900
4901 /*
4902 * Check that there is a comment right here.
4903 */
4904 if ((RAW != '<') || (NXT(1) != '!') ||
4905 (NXT(2) != '-') || (NXT(3) != '-')) return;
4906 state = ctxt->instate;
4908 inputid = ctxt->input->id;
4909 SKIP(4);
4910 SHRINK;
4911 GROW;
4912
4913 /*
4914 * Accelerated common case where input don't need to be
4915 * modified before passing it to the handler.
4916 */
4917 in = ctxt->input->cur;
4918 do {
4919 if (*in == 0xA) {
4920 do {
4921 ctxt->input->line++; ctxt->input->col = 1;
4922 in++;
4923 } while (*in == 0xA);
4924 }
4925get_more:
4926 ccol = ctxt->input->col;
4927 while (((*in > '-') && (*in <= 0x7F)) ||
4928 ((*in >= 0x20) && (*in < '-')) ||
4929 (*in == 0x09)) {
4930 in++;
4931 ccol++;
4932 }
4933 ctxt->input->col = ccol;
4934 if (*in == 0xA) {
4935 do {
4936 ctxt->input->line++; ctxt->input->col = 1;
4937 in++;
4938 } while (*in == 0xA);
4939 goto get_more;
4940 }
4941 nbchar = in - ctxt->input->cur;
4942 /*
4943 * save current set of data
4944 */
4945 if (nbchar > 0) {
4946 if ((ctxt->sax != NULL) &&
4947 (ctxt->sax->comment != NULL)) {
4948 if (buf == NULL) {
4949 if ((*in == '-') && (in[1] == '-'))
4950 size = nbchar + 1;
4951 else
4952 size = XML_PARSER_BUFFER_SIZE + nbchar;
4953 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4954 if (buf == NULL) {
4955 xmlErrMemory(ctxt, NULL);
4956 ctxt->instate = state;
4957 return;
4958 }
4959 len = 0;
4960 } else if (len + nbchar + 1 >= size) {
4961 xmlChar *new_buf;
4962 size += len + nbchar + XML_PARSER_BUFFER_SIZE;
4963 new_buf = (xmlChar *) xmlRealloc(buf,
4964 size * sizeof(xmlChar));
4965 if (new_buf == NULL) {
4966 xmlFree (buf);
4967 xmlErrMemory(ctxt, NULL);
4968 ctxt->instate = state;
4969 return;
4970 }
4971 buf = new_buf;
4972 }
4973 memcpy(&buf[len], ctxt->input->cur, nbchar);
4974 len += nbchar;
4975 buf[len] = 0;
4976 }
4977 }
4978 if (len > maxLength) {
4979 xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
4980 "Comment too big found", NULL);
4981 xmlFree (buf);
4982 return;
4983 }
4984 ctxt->input->cur = in;
4985 if (*in == 0xA) {
4986 in++;
4987 ctxt->input->line++; ctxt->input->col = 1;
4988 }
4989 if (*in == 0xD) {
4990 in++;
4991 if (*in == 0xA) {
4992 ctxt->input->cur = in;
4993 in++;
4994 ctxt->input->line++; ctxt->input->col = 1;
4995 goto get_more;
4996 }
4997 in--;
4998 }
4999 SHRINK;
5000 GROW;
5001 if (ctxt->instate == XML_PARSER_EOF) {
5002 xmlFree(buf);
5003 return;
5004 }
5005 in = ctxt->input->cur;
5006 if (*in == '-') {
5007 if (in[1] == '-') {
5008 if (in[2] == '>') {
5009 if (ctxt->input->id != inputid) {
5010 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5011 "comment doesn't start and stop in the"
5012 " same entity\n");
5013 }
5014 SKIP(3);
5015 if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
5016 (!ctxt->disableSAX)) {
5017 if (buf != NULL)
5018 ctxt->sax->comment(ctxt->userData, buf);
5019 else
5020 ctxt->sax->comment(ctxt->userData, BAD_CAST "");
5021 }
5022 if (buf != NULL)
5023 xmlFree(buf);
5024 if (ctxt->instate != XML_PARSER_EOF)
5025 ctxt->instate = state;
5026 return;
5027 }
5028 if (buf != NULL) {
5029 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5030 "Double hyphen within comment: "
5031 "<!--%.50s\n",
5032 buf);
5033 } else
5034 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5035 "Double hyphen within comment\n", NULL);
5036 if (ctxt->instate == XML_PARSER_EOF) {
5037 xmlFree(buf);
5038 return;
5039 }
5040 in++;
5041 ctxt->input->col++;
5042 }
5043 in++;
5044 ctxt->input->col++;
5045 goto get_more;
5046 }
5047 } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
5049 ctxt->instate = state;
5050 return;
5051}
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
xmlParserInputState
Definition: parser.h:110
@ XML_PARSER_COMMENT
Definition: parser.h:117
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4750
@ 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 XMLCALL 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 9958 of file parser.c.

9958 {
9959 int nameNr = ctxt->nameNr;
9960
9962
9963 if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->nameNr > nameNr)) {
9964 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9965 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9966 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9967 "Premature end of data in tag %s line %d\n",
9968 name, line, NULL);
9969 }
9970}
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9873
xmlStartTag * pushTab
Definition: parser.h:283
int line
Definition: parser.c:80
Definition: name.c:39
@ XML_ERR_TAG_NOT_FINISHED
Definition: xmlerror.h:177

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

◆ xmlParseDefaultDecl()

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

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

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 5682 of file parser.c.

5682 {
5683 int val;
5684 xmlChar *ret;
5685
5686 *value = NULL;
5687 if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5688 SKIP(9);
5689 return(XML_ATTRIBUTE_REQUIRED);
5690 }
5691 if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5692 SKIP(8);
5693 return(XML_ATTRIBUTE_IMPLIED);
5694 }
5696 if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5697 SKIP(6);
5699 if (SKIP_BLANKS == 0) {
5700 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5701 "Space required after '#FIXED'\n");
5702 }
5703 }
5704 ret = xmlParseAttValue(ctxt);
5705 ctxt->instate = XML_PARSER_DTD;
5706 if (ret == NULL) {
5707 xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5708 "Attribute default value declaration error\n");
5709 } else
5710 *value = ret;
5711 return(val);
5712}
@ XML_PARSER_DTD
Definition: parser.h:115
@ XML_ATTRIBUTE_NONE
Definition: tree.h:226
@ XML_ATTRIBUTE_FIXED
Definition: tree.h:229
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4182
xmlParserErrors
Definition: xmlerror.h:99

Referenced by xmlParseAttributeListDecl().

◆ xmlParseDocTypeDecl()

XMLPUBFUN void XMLCALL xmlParseDocTypeDecl ( xmlParserCtxtPtr  ctxt)

xmlParseDocTypeDecl: @ctxt: an XML parser context

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 8282 of file parser.c.

8282 {
8283 const xmlChar *name = NULL;
8284 xmlChar *ExternalID = NULL;
8285 xmlChar *URI = NULL;
8286
8287 /*
8288 * We know that '<!DOCTYPE' has been detected.
8289 */
8290 SKIP(9);
8291
8293
8294 /*
8295 * Parse the DOCTYPE name.
8296 */
8297 name = xmlParseName(ctxt);
8298 if (name == NULL) {
8299 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8300 "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8301 }
8302 ctxt->intSubName = name;
8303
8305
8306 /*
8307 * Check for SystemID and ExternalID
8308 */
8309 URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8310
8311 if ((URI != NULL) || (ExternalID != NULL)) {
8312 ctxt->hasExternalSubset = 1;
8313 }
8314 ctxt->extSubURI = URI;
8315 ctxt->extSubSystem = ExternalID;
8316
8318
8319 /*
8320 * Create and update the internal subset.
8321 */
8322 if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8323 (!ctxt->disableSAX))
8324 ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8325 if (ctxt->instate == XML_PARSER_EOF)
8326 return;
8327
8328 /*
8329 * Is there any internal subset declarations ?
8330 * they are handled separately in xmlParseInternalSubset()
8331 */
8332 if (RAW == '[')
8333 return;
8334
8335 /*
8336 * We should be at the end of the DOCTYPE declaration.
8337 */
8338 if (RAW != '>') {
8340 }
8341 NEXT;
8342}
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4683
const xmlChar * intSubName
Definition: parser.h:239
xmlChar * extSubSystem
Definition: parser.h:241
int hasExternalSubset
Definition: parser.h:215
xmlChar * extSubURI
Definition: parser.h:240
@ XML_ERR_DOCTYPE_NOT_FINISHED
Definition: xmlerror.h:161

Referenced by xmlParseDocument().

◆ xmlParseElement()

XMLPUBFUN void XMLCALL xmlParseElement ( xmlParserCtxtPtr  ctxt)

xmlParseElement: @ctxt: an XML parser context

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 9987 of file parser.c.

9987 {
9988 if (xmlParseElementStart(ctxt) != 0)
9989 return;
9990
9992 if (ctxt->instate == XML_PARSER_EOF)
9993 return;
9994
9995 if (CUR == 0) {
9996 const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9997 int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9998 xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9999 "Premature end of data in tag %s line %d\n",
10000 name, line, NULL);
10001 return;
10002 }
10003
10004 xmlParseElementEnd(ctxt);
10005}
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:10015
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10144

Referenced by xmlParseDocument().

◆ xmlParseElementChildrenContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

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

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 6533 of file parser.c.

6533 {
6534 /* stub left for API/ABI compat */
6535 return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6536}
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6230

◆ xmlParseElementContentDecl()

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

Definition at line 6553 of file parser.c.

6554 {
6555
6557 int inputid = ctxt->input->id;
6558 int res;
6559
6560 *result = NULL;
6561
6562 if (RAW != '(') {
6563 xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6564 "xmlParseElementContentDecl : %s '(' expected\n", name);
6565 return(-1);
6566 }
6567 NEXT;
6568 GROW;
6569 if (ctxt->instate == XML_PARSER_EOF)
6570 return(-1);
6572 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6573 tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6575 } else {
6576 tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6578 }
6580 *result = tree;
6581 return(res);
6582}
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
@ XML_ELEMENT_TYPE_MIXED
Definition: tree.h:326
@ XML_ELEMENT_TYPE_ELEMENT
Definition: tree.h:327
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6104
@ XML_ERR_ELEMCONTENT_NOT_STARTED
Definition: xmlerror.h:154

Referenced by xmlParseElementDecl().

◆ xmlParseElementDecl()

XMLPUBFUN int XMLCALL xmlParseElementDecl ( xmlParserCtxtPtr  ctxt)

xmlParseElementDecl: @ctxt: an XML parser context

parse an Element declaration.

[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 6598 of file parser.c.

6598 {
6599 const xmlChar *name;
6600 int ret = -1;
6602
6603 /* GROW; done in the caller */
6604 if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6605 int inputid = ctxt->input->id;
6606
6607 SKIP(9);
6608 if (SKIP_BLANKS == 0) {
6609 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6610 "Space required after 'ELEMENT'\n");
6611 return(-1);
6612 }
6613 name = xmlParseName(ctxt);
6614 if (name == NULL) {
6615 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6616 "xmlParseElementDecl: no name for Element\n");
6617 return(-1);
6618 }
6619 if (SKIP_BLANKS == 0) {
6620 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6621 "Space required after the element name\n");
6622 }
6623 if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6624 SKIP(5);
6625 /*
6626 * Element must always be empty.
6627 */
6629 } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6630 (NXT(2) == 'Y')) {
6631 SKIP(3);
6632 /*
6633 * Element is a generic container.
6634 */
6636 } else if (RAW == '(') {
6638 } else {
6639 /*
6640 * [ WFC: PEs in Internal Subset ] error handling.
6641 */
6642 if ((RAW == '%') && (ctxt->external == 0) &&
6643 (ctxt->inputNr == 1)) {
6644 xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6645 "PEReference: forbidden within markup decl in internal subset\n");
6646 } else {
6647 xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6648 "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6649 }
6650 return(-1);
6651 }
6652
6654
6655 if (RAW != '>') {
6657 if (content != NULL) {
6659 }
6660 } else {
6661 if (inputid != ctxt->input->id) {
6662 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6663 "Element declaration doesn't start and stop in"
6664 " the same entity\n");
6665 }
6666
6667 NEXT;
6668 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6669 (ctxt->sax->elementDecl != NULL)) {
6670 if (content != NULL)
6671 content->parent = NULL;
6672 ctxt->sax->elementDecl(ctxt->userData, name, ret,
6673 content);
6674 if ((content != NULL) && (content->parent == NULL)) {
6675 /*
6676 * this is a trick: if xmlAddElementDecl is called,
6677 * instead of copying the full tree it is plugged directly
6678 * if called from the parser. Avoid duplicating the
6679 * interfaces or change the API/ABI
6680 */
6682 }
6683 } else if (content != NULL) {
6685 }
6686 }
6687 }
6688 return(ret);
6689}
content
Definition: atl_ax.c:994
@ XML_ELEMENT_TYPE_EMPTY
Definition: tree.h:324
@ XML_ELEMENT_TYPE_ANY
Definition: tree.h:325
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6553
int external
Definition: parser.h:217
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1089
@ XML_ERR_PEREF_IN_INT_SUBSET
Definition: xmlerror.h:121
@ XML_ERR_GT_REQUIRED
Definition: xmlerror.h:173

Referenced by xmlParseMarkupDecl().

◆ xmlParseElementMixedContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

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

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 6104 of file parser.c.

6104 {
6106 const xmlChar *elem = NULL;
6107
6108 GROW;
6109 if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6110 SKIP(7);
6112 SHRINK;
6113 if (RAW == ')') {
6114 if (ctxt->input->id != inputchk) {
6115 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6116 "Element content declaration doesn't start and"
6117 " stop in the same entity\n");
6118 }
6119 NEXT;
6121 if (ret == NULL)
6122 return(NULL);
6123 if (RAW == '*') {
6125 NEXT;
6126 }
6127 return(ret);
6128 }
6129 if ((RAW == '(') || (RAW == '|')) {
6131 if (ret == NULL) return(NULL);
6132 }
6133 while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6134 NEXT;
6135 if (elem == NULL) {
6137 if (ret == NULL) {
6139 return(NULL);
6140 }
6141 ret->c1 = cur;
6142 if (cur != NULL)
6143 cur->parent = ret;
6144 cur = ret;
6145 } else {
6147 if (n == NULL) {
6149 return(NULL);
6150 }
6152 if (n->c1 != NULL)
6153 n->c1->parent = n;
6154 cur->c2 = n;
6155 if (n != NULL)
6156 n->parent = cur;
6157 cur = n;
6158 }
6160 elem = xmlParseName(ctxt);
6161 if (elem == NULL) {
6162 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6163 "xmlParseElementMixedContentDecl : Name expected\n");
6165 return(NULL);
6166 }
6168 GROW;
6169 }
6170 if ((RAW == ')') && (NXT(1) == '*')) {
6171 if (elem != NULL) {
6174 if (cur->c2 != NULL)
6175 cur->c2->parent = cur;
6176 }
6177 if (ret != NULL)
6179 if (ctxt->input->id != inputchk) {
6180 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6181 "Element content declaration doesn't start and"
6182 " stop in the same entity\n");
6183 }
6184 SKIP(2);
6185 } else {
6188 return(NULL);
6189 }
6190
6191 } else {
6193 }
6194 return(ret);
6195}
GLdouble n
Definition: glext.h:7729
static size_t elem
Definition: string.c:68
@ XML_ELEMENT_CONTENT_MULT
Definition: tree.h:293
@ XML_ELEMENT_CONTENT_PCDATA
Definition: tree.h:279
@ XML_ELEMENT_CONTENT_ELEMENT
Definition: tree.h:280
@ XML_ELEMENT_CONTENT_OR
Definition: tree.h:282
XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:908
@ XML_ERR_MIXED_NOT_STARTED
Definition: xmlerror.h:152
@ XML_ERR_PCDATA_REQUIRED
Definition: xmlerror.h:169

Referenced by xmlParseElementContentDecl().

◆ xmlParseEncName()

XMLPUBFUN xmlChar *XMLCALL xmlParseEncName ( xmlParserCtxtPtr  ctxt)

xmlParseEncName: @ctxt: an XML parser context

parse the XML encoding name

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

Returns the encoding name value or NULL

Definition at line 10293 of file parser.c.

10293 {
10294 xmlChar *buf = NULL;
10295 int len = 0;
10296 int size = 10;
10297 xmlChar cur;
10298
10299 cur = CUR;
10300 if (((cur >= 'a') && (cur <= 'z')) ||
10301 ((cur >= 'A') && (cur <= 'Z'))) {
10302 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10303 if (buf == NULL) {
10304 xmlErrMemory(ctxt, NULL);
10305 return(NULL);
10306 }
10307
10308 buf[len++] = cur;
10309 NEXT;
10310 cur = CUR;
10311 while (((cur >= 'a') && (cur <= 'z')) ||
10312 ((cur >= 'A') && (cur <= 'Z')) ||
10313 ((cur >= '0') && (cur <= '9')) ||
10314 (cur == '.') || (cur == '_') ||
10315 (cur == '-')) {
10316 if (len + 1 >= size) {
10317 xmlChar *tmp;
10318
10319 size *= 2;
10320 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10321 if (tmp == NULL) {
10322 xmlErrMemory(ctxt, NULL);
10323 xmlFree(buf);
10324 return(NULL);
10325 }
10326 buf = tmp;
10327 }
10328 buf[len++] = cur;
10329 NEXT;
10330 cur = CUR;
10331 if (cur == 0) {
10332 SHRINK;
10333 GROW;
10334 cur = CUR;
10335 }
10336 }
10337 buf[len] = 0;
10338 } else {
10340 }
10341 return(buf);
10342}
@ XML_ERR_ENCODING_NAME
Definition: xmlerror.h:179

Referenced by xmlParseEncodingDecl().

◆ xmlParseEncodingDecl()

XMLPUBFUN const xmlChar *XMLCALL xmlParseEncodingDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEncodingDecl: @ctxt: an XML parser context

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 10358 of file parser.c.

10358 {
10360
10362 if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10363 SKIP(8);
10365 if (RAW != '=') {
10367 return(NULL);
10368 }
10369 NEXT;
10371 if (RAW == '"') {
10372 NEXT;
10373 encoding = xmlParseEncName(ctxt);
10374 if (RAW != '"') {
10377 return(NULL);
10378 } else
10379 NEXT;
10380 } else if (RAW == '\''){
10381 NEXT;
10382 encoding = xmlParseEncName(ctxt);
10383 if (RAW != '\'') {
10386 return(NULL);
10387 } else
10388 NEXT;
10389 } else {
10391 }
10392
10393 /*
10394 * Non standard parsing, allowing the user to ignore encoding
10395 */
10396 if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10398 return(NULL);
10399 }
10400
10401 /*
10402 * UTF-16 encoding switch has already taken place at this stage,
10403 * more over the little-endian/big-endian selection is already done
10404 */
10405 if ((encoding != NULL) &&
10406 ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10407 (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10408 /*
10409 * If no encoding was passed to the parser, that we are
10410 * using UTF-16 and no decoder is present i.e. the
10411 * document is apparently UTF-8 compatible, then raise an
10412 * encoding mismatch fatal error
10413 */
10414 if ((ctxt->encoding == NULL) &&
10415 (ctxt->input->buf != NULL) &&
10416 (ctxt->input->buf->encoder == NULL)) {
10417 xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10418 "Document labelled UTF-16 but has UTF-8 content\n");
10419 }
10420 if (ctxt->encoding != NULL)
10421 xmlFree((xmlChar *) ctxt->encoding);
10422 ctxt->encoding = encoding;
10423 }
10424 /*
10425 * UTF-8 encoding is handled natively
10426 */
10427 else if ((encoding != NULL) &&
10428 ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10429 (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10430 if (ctxt->encoding != NULL)
10431 xmlFree((xmlChar *) ctxt->encoding);
10432 ctxt->encoding = encoding;
10433 }
10434 else if (encoding != NULL) {
10436
10437 if (ctxt->input->encoding != NULL)
10438 xmlFree((xmlChar *) ctxt->input->encoding);
10439 ctxt->input->encoding = encoding;
10440
10442 if (handler != NULL) {
10443 if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10444 /* failed to convert */
10446 return(NULL);
10447 }
10448 } else {
10449 xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10450 "Unsupported encoding %s\n", encoding);
10451 return(NULL);
10452 }
10453 }
10454 }
10455 return(encoding);
10456}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1678
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
@ XML_PARSE_IGNORE_ENC
Definition: parser.h:1116
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10293
const xmlChar * encoding
Definition: parser.h:191
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
const xmlChar * encoding
Definition: parser.h:71
@ XML_ERR_INVALID_ENCODING
Definition: xmlerror.h:181
@ 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
@ XML_ERR_UNSUPPORTED_ENCODING
Definition: xmlerror.h:132
static char * encoding
Definition: xmllint.c:155
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:275

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseEntityDecl()

XMLPUBFUN void XMLCALL xmlParseEntityDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEntityDecl: @ctxt: an XML parser context

parse <!ENTITY declarations

[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 5409 of file parser.c.

5409 {
5410 const xmlChar *name = NULL;
5411 xmlChar *value = NULL;
5412 xmlChar *URI = NULL, *literal = NULL;
5413 const xmlChar *ndata = NULL;
5414 int isParameter = 0;
5415 xmlChar *orig = NULL;
5416
5417 /* GROW; done in the caller */
5418 if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
5419 int inputid = ctxt->input->id;
5420 SHRINK;
5421 SKIP(8);
5422 if (SKIP_BLANKS == 0) {
5423 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5424 "Space required after '<!ENTITY'\n");
5425 }
5426
5427 if (RAW == '%') {
5428 NEXT;
5429 if (SKIP_BLANKS == 0) {
5430 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5431 "Space required after '%%'\n");
5432 }
5433 isParameter = 1;
5434 }
5435
5436 name = xmlParseName(ctxt);
5437 if (name == NULL) {
5438 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5439 "xmlParseEntityDecl: no name\n");
5440 return;
5441 }
5442 if (xmlStrchr(name, ':') != NULL) {
5443 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5444 "colons are forbidden from entities names '%s'\n",
5445 name, NULL, NULL);
5446 }
5447 if (SKIP_BLANKS == 0) {
5448 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5449 "Space required after the entity name\n");
5450 }
5451
5453 /*
5454 * handle the various case of definitions...
5455 */
5456 if (isParameter) {
5457 if ((RAW == '"') || (RAW == '\'')) {
5458 value = xmlParseEntityValue(ctxt, &orig);
5459 if (value) {
5460 if ((ctxt->sax != NULL) &&
5461 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5462 ctxt->sax->entityDecl(ctxt->userData, name,
5464 NULL, NULL, value);
5465 }
5466 } else {
5467 URI = xmlParseExternalID(ctxt, &literal, 1);
5468 if ((URI == NULL) && (literal == NULL)) {
5470 }
5471 if (URI) {
5472 xmlURIPtr uri;
5473
5474 uri = xmlParseURI((const char *) URI);
5475 if (uri == NULL) {
5476 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5477 "Invalid URI: %s\n", URI);
5478 /*
5479 * This really ought to be a well formedness error
5480 * but the XML Core WG decided otherwise c.f. issue
5481 * E26 of the XML erratas.
5482 */
5483 } else {
5484 if (uri->fragment != NULL) {
5485 /*
5486 * Okay this is foolish to block those but not
5487 * invalid URIs.
5488 */
5490 } else {
5491 if ((ctxt->sax != NULL) &&
5492 (!ctxt->disableSAX) &&
5493 (ctxt->sax->entityDecl != NULL))
5494 ctxt->sax->entityDecl(ctxt->userData, name,
5496 literal, URI, NULL);
5497 }
5498 xmlFreeURI(uri);
5499 }
5500 }
5501 }
5502 } else {
5503 if ((RAW == '"') || (RAW == '\'')) {
5504 value = xmlParseEntityValue(ctxt, &orig);
5505 if ((ctxt->sax != NULL) &&
5506 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5507 ctxt->sax->entityDecl(ctxt->userData, name,
5509 NULL, NULL, value);
5510 /*
5511 * For expat compatibility in SAX mode.
5512 */
5513 if ((ctxt->myDoc == NULL) ||
5515 if (ctxt->myDoc == NULL) {
5517 if (ctxt->myDoc == NULL) {
5518 xmlErrMemory(ctxt, "New Doc failed");
5519 return;
5520 }
5522 }
5523 if (ctxt->myDoc->intSubset == NULL)
5524 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5525 BAD_CAST "fake", NULL, NULL);
5526
5528 NULL, NULL, value);
5529 }
5530 } else {
5531 URI = xmlParseExternalID(ctxt, &literal, 1);
5532 if ((URI == NULL) && (literal == NULL)) {
5534 }
5535 if (URI) {
5536 xmlURIPtr uri;
5537
5538 uri = xmlParseURI((const char *)URI);
5539 if (uri == NULL) {
5540 xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5541 "Invalid URI: %s\n", URI);
5542 /*
5543 * This really ought to be a well formedness error
5544 * but the XML Core WG decided otherwise c.f. issue
5545 * E26 of the XML erratas.
5546 */
5547 } else {
5548 if (uri->fragment != NULL) {
5549 /*
5550 * Okay this is foolish to block those but not
5551 * invalid URIs.
5552 */
5554 }
5555 xmlFreeURI(uri);
5556 }
5557 }
5558 if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5559 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5560 "Space required before 'NDATA'\n");
5561 }
5562 if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5563 SKIP(5);
5564 if (SKIP_BLANKS == 0) {
5565 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5566 "Space required after 'NDATA'\n");
5567 }
5568 ndata = xmlParseName(ctxt);
5569 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5570 (ctxt->sax->unparsedEntityDecl != NULL))
5571 ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5572 literal, URI, ndata);
5573 } else {
5574 if ((ctxt->sax != NULL) &&
5575 (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5576 ctxt->sax->entityDecl(ctxt->userData, name,
5578 literal, URI, NULL);
5579 /*
5580 * For expat compatibility in SAX mode.
5581 * assuming the entity replacement was asked for
5582 */
5583 if ((ctxt->replaceEntities != 0) &&
5584 ((ctxt->myDoc == NULL) ||
5586 if (ctxt->myDoc == NULL) {
5588 if (ctxt->myDoc == NULL) {
5589 xmlErrMemory(ctxt, "New Doc failed");
5590 return;
5591 }
5593 }
5594
5595 if (ctxt->myDoc->intSubset == NULL)
5596 ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5597 BAD_CAST "fake", NULL, NULL);
5598 xmlSAX2EntityDecl(ctxt, name,
5600 literal, URI, NULL);
5601 }
5602 }
5603 }
5604 }
5605 if (ctxt->instate == XML_PARSER_EOF)
5606 goto done;
5608 if (RAW != '>') {
5609 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
5610 "xmlParseEntityDecl: entity %s not terminated\n", name);
5611 xmlHaltParser(ctxt);
5612 } else {
5613 if (inputid != ctxt->input->id) {
5614 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5615 "Entity declaration doesn't start and stop in"
5616 " the same entity\n");
5617 }
5618 NEXT;
5619 }
5620 if (orig != NULL) {
5621 /*
5622 * Ugly mechanism to save the raw entity value.
5623 */
5625
5626 if (isParameter) {
5627 if ((ctxt->sax != NULL) &&
5628 (ctxt->sax->getParameterEntity != NULL))
5629 cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
5630 } else {
5631 if ((ctxt->sax != NULL) &&
5632 (ctxt->sax->getEntity != NULL))
5633 cur = ctxt->sax->getEntity(ctxt->userData, name);
5634 if ((cur == NULL) && (ctxt->userData==ctxt)) {
5635 cur = xmlSAX2GetEntity(ctxt, name);
5636 }
5637 }
5638 if ((cur != NULL) && (cur->orig == NULL)) {
5639 cur->orig = orig;
5640 orig = NULL;
5641 }
5642 }
5643
5644done:
5645 if (value != NULL) xmlFree(value);
5646 if (URI != NULL) xmlFree(URI);
5647 if (literal != NULL) xmlFree(literal);
5648 if (orig != NULL) xmlFree(orig);
5649 }
5650}
XMLPUBFUN void XMLCALL xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:604
XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:526
const char * uri
Definition: sec_mgr.c:1588
@ XML_PARSER_ENTITY_DECL
Definition: parser.h:122
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
@ XML_DOC_INTERNAL
Definition: tree.h:540
xmlChar * xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig)
Definition: parser.c:3767
#define SAX_COMPAT_MODE
Definition: parser.c:277
struct _xmlDtd * intSubset
Definition: tree.h:570
const xmlChar * version
Definition: tree.h:573
int properties
Definition: tree.h:584
int replaceEntities
Definition: parser.h:189
Definition: uri.h:33
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:940
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1387
@ 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:218
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:325
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

Referenced by xmlParseMarkupDecl().

◆ xmlParseEntityRef()

XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef ( xmlParserCtxtPtr  ctxt)

xmlParseEntityRef: @ctxt: an XML parser context

parse ENTITY references declarations

[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 7531 of file parser.c.

7531 {
7532 const xmlChar *name;
7533 xmlEntityPtr ent = NULL;
7534
7535 GROW;
7536 if (ctxt->instate == XML_PARSER_EOF)
7537 return(NULL);
7538
7539 if (RAW != '&')
7540 return(NULL);
7541 NEXT;
7542 name = xmlParseName(ctxt);
7543 if (name == NULL) {
7544 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
7545 "xmlParseEntityRef: no name\n");
7546 return(NULL);
7547 }
7548 if (RAW != ';') {
7550 return(NULL);
7551 }
7552 NEXT;
7553
7554 /*
7555 * Predefined entities override any extra definition
7556 */
7557 if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
7559 if (ent != NULL)
7560 return(ent);
7561 }
7562
7563 /*
7564 * Increase the number of entity references parsed
7565 */
7566 ctxt->nbentities++;
7567
7568 /*
7569 * Ask first SAX for entity resolution, otherwise try the
7570 * entities which may have stored in the parser context.
7571 */
7572 if (ctxt->sax != NULL) {
7573 if (ctxt->sax->getEntity != NULL)
7574 ent = ctxt->sax->getEntity(ctxt->userData, name);
7575 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7576 (ctxt->options & XML_PARSE_OLDSAX))
7578 if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
7579 (ctxt->userData==ctxt)) {
7580 ent = xmlSAX2GetEntity(ctxt, name);
7581 }
7582 }
7583 if (ctxt->instate == XML_PARSER_EOF)
7584 return(NULL);
7585 /*
7586 * [ WFC: Entity Declared ]
7587 * In a document without any DTD, a document with only an
7588 * internal DTD subset which contains no parameter entity
7589 * references, or a document with "standalone='yes'", the
7590 * Name given in the entity reference must match that in an
7591 * entity declaration, except that well-formed documents
7592 * need not declare any of the following entities: amp, lt,
7593 * gt, apos, quot.
7594 * The declaration of a parameter entity must precede any
7595 * reference to it.
7596 * Similarly, the declaration of a general entity must
7597 * precede any reference to it which appears in a default
7598 * value in an attribute-list declaration. Note that if
7599 * entities are declared in the external subset or in
7600 * external parameter entities, a non-validating processor
7601 * is not obligated to read and process their declarations;
7602 * for such documents, the rule that an entity must be
7603 * declared is a well-formedness constraint only if
7604 * standalone='yes'.
7605 */
7606 if (ent == NULL) {
7607 if ((ctxt->standalone == 1) ||
7608 ((ctxt->hasExternalSubset == 0) &&
7609 (ctxt->hasPErefs == 0))) {
7610 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7611 "Entity '%s' not defined\n", name);
7612 } else {
7613 xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
7614 "Entity '%s' not defined\n", name);
7615 if ((ctxt->inSubset == 0) &&
7616 (ctxt->sax != NULL) &&
7617 (ctxt->sax->reference != NULL)) {
7618 ctxt->sax->reference(ctxt->userData, name);
7619 }
7620 }
7621 xmlParserEntityCheck(ctxt, 0, ent, 0);
7622 ctxt->valid = 0;
7623 }
7624
7625 /*
7626 * [ WFC: Parsed Entity ]
7627 * An entity reference must not contain the name of an
7628 * unparsed entity
7629 */
7631 xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
7632 "Entity reference to unparsed entity %s\n", name);
7633 }
7634
7635 /*
7636 * [ WFC: No External Entity References ]
7637 * Attribute values cannot contain direct or indirect
7638 * entity references to external entities.
7639 */
7640 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7642 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
7643 "Attribute references external entity '%s'\n", name);
7644 }
7645 /*
7646 * [ WFC: No < in Attribute Values ]
7647 * The replacement text of any entity referred to directly or
7648 * indirectly in an attribute value (other than "&lt;") must
7649 * not contain a <.
7650 */
7651 else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
7652 (ent != NULL) &&
7654 if (((ent->checked & 1) || (ent->checked == 0)) &&
7655 (ent->content != NULL) && (xmlStrchr(ent->content, '<'))) {
7656 xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
7657 "'<' in entity '%s' is not allowed in attributes values\n", name);
7658 }
7659 }
7660
7661 /*
7662 * Internal check, no parameter entities here ...
7663 */
7664 else {
7665 switch (ent->etype) {
7668 xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
7669 "Attempt to reference the parameter entity '%s'\n",
7670 name);
7671 break;
7672 default:
7673 break;
7674 }
7675 }
7676
7677 /*
7678 * [ WFC: No Recursion ]
7679 * A parsed entity must not contain a recursive reference
7680 * to itself, either directly or indirectly.
7681 * Done somewhere else
7682 */
7683 return(ent);
7684}
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetPredefinedEntity(const xmlChar *name)
@ XML_PARSER_ATTRIBUTE_VALUE
Definition: parser.h:124
@ XML_PARSE_OLDSAX
Definition: parser.h:1115
static int xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size, xmlEntityPtr ent, size_t replacement)
Definition: parser.c:128
xmlChar * content
Definition: entities.h:50
xmlEntityType etype
Definition: entities.h:52
int checked
Definition: entities.h:59
int hasPErefs
Definition: parser.h:216
int wellFormed
Definition: parser.h:188
int inSubset
Definition: parser.h:238
int standalone
Definition: parser.h:192
unsigned long nbentities
Definition: parser.h:303
@ 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()

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

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

parse a value for ENTITY declarations

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

Returns the EntityValue parsed with reference substituted or NULL

Definition at line 3767 of file parser.c.

3767 {
3768 xmlChar *buf = NULL;
3769 int len = 0;
3771 int c, l;
3772 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3775 xmlChar stop;
3776 xmlChar *ret = NULL;
3777 const xmlChar *cur = NULL;
3779
3780 if (RAW == '"') stop = '"';
3781 else if (RAW == '\'') stop = '\'';
3782 else {
3784 return(NULL);
3785 }
3786 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
3787 if (buf == NULL) {
3788 xmlErrMemory(ctxt, NULL);
3789 return(NULL);
3790 }
3791
3792 /*
3793 * The content of the entity definition is copied in a buffer.
3794 */
3795
3797 input = ctxt->input;
3798 GROW;
3799 if (ctxt->instate == XML_PARSER_EOF)
3800 goto error;
3801 NEXT;
3802 c = CUR_CHAR(l);
3803 /*
3804 * NOTE: 4.4.5 Included in Literal
3805 * When a parameter entity reference appears in a literal entity
3806 * value, ... a single or double quote character in the replacement
3807 * text is always treated as a normal data character and will not
3808 * terminate the literal.
3809 * In practice it means we stop the loop only when back at parsing
3810 * the initial entity and the quote is found
3811 */
3812 while (((IS_CHAR(c)) && ((c != stop) || /* checked */
3813 (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) {
3814 if (len + 5 >= size) {
3815 xmlChar *tmp;
3816
3817 size *= 2;
3818 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
3819 if (tmp == NULL) {
3820 xmlErrMemory(ctxt, NULL);
3821 goto error;
3822 }
3823 buf = tmp;
3824 }
3825 COPY_BUF(l,buf,len,c);
3826 NEXTL(l);
3827
3828 GROW;
3829 c = CUR_CHAR(l);
3830 if (c == 0) {
3831 GROW;
3832 c = CUR_CHAR(l);
3833 }
3834
3835 if (len > maxLength) {
3836 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
3837 "entity value too long\n");
3838 goto error;
3839 }
3840 }
3841 buf[len] = 0;
3842 if (ctxt->instate == XML_PARSER_EOF)
3843 goto error;
3844 if (c != stop) {
3846 goto error;
3847 }
3848 NEXT;
3849
3850 /*
3851 * Raise problem w.r.t. '&' and '%' being used in non-entities
3852 * reference constructs. Note Charref will be handled in
3853 * xmlStringDecodeEntities()
3854 */
3855 cur = buf;
3856 while (*cur != 0) { /* non input consuming */
3857 if ((*cur == '%') || ((*cur == '&') && (cur[1] != '#'))) {
3858 xmlChar *name;
3859 xmlChar tmp = *cur;
3860 int nameOk = 0;
3861
3862 cur++;
3863 name = xmlParseStringName(ctxt, &cur);
3864 if (name != NULL) {
3865 nameOk = 1;
3866 xmlFree(name);
3867 }
3868 if ((nameOk == 0) || (*cur != ';')) {
3869 xmlFatalErrMsgInt(ctxt, XML_ERR_ENTITY_CHAR_ERROR,
3870 "EntityValue: '%c' forbidden except for entities references\n",
3871 tmp);
3872 goto error;
3873 }
3874 if ((tmp == '%') && (ctxt->inSubset == 1) &&
3875 (ctxt->inputNr == 1)) {
3877 goto error;
3878 }
3879 if (*cur == 0)
3880 break;
3881 }
3882 cur++;
3883 }
3884
3885 /*
3886 * Then PEReference entities are substituted.
3887 *
3888 * NOTE: 4.4.7 Bypassed
3889 * When a general entity reference appears in the EntityValue in
3890 * an entity declaration, it is bypassed and left as is.
3891 * so XML_SUBSTITUTE_REF is not set here.
3892 */
3893 ++ctxt->depth;
3895 0, 0, 0);
3896 --ctxt->depth;
3897 if (orig != NULL) {
3898 *orig = buf;
3899 buf = NULL;
3900 }
3901
3902error:
3903 if (buf != NULL)
3904 xmlFree(buf);
3905 return(ret);
3906}
#define error(str)
Definition: mkdosfs.c:1605
#define XML_SUBSTITUTE_PEREF
@ XML_PARSER_ENTITY_VALUE
Definition: parser.h:123
static xmlChar * xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:3573
xmlChar * xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
Definition: parser.c:2839
@ 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()

XMLPUBFUN int XMLCALL xmlParseEnumeratedType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr tree 
)

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

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 5871 of file parser.c.

5871 {
5872 if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
5873 SKIP(8);
5874 if (SKIP_BLANKS == 0) {
5875 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5876 "Space required after 'NOTATION'\n");
5877 return(0);
5878 }
5879 *tree = xmlParseNotationType(ctxt);
5880 if (*tree == NULL) return(0);
5881 return(XML_ATTRIBUTE_NOTATION);
5882 }
5884 if (*tree == NULL) return(0);
5886}
@ XML_ATTRIBUTE_NOTATION
Definition: tree.h:216
@ XML_ATTRIBUTE_ENUMERATION
Definition: tree.h:215
xmlEnumerationPtr xmlParseNotationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5732
xmlEnumerationPtr xmlParseEnumerationType(xmlParserCtxtPtr ctxt)
Definition: parser.c:5802

Referenced by xmlParseAttributeType().

◆ xmlParseEnumerationType()

XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType ( xmlParserCtxtPtr  ctxt)

xmlParseEnumerationType: @ctxt: an XML parser context

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 5802 of file parser.c.

5802 {
5803 xmlChar *name;
5805
5806 if (RAW != '(') {
5808 return(NULL);
5809 }
5810 SHRINK;
5811 do {
5812 NEXT;
5814 name = xmlParseNmtoken(ctxt);
5815 if (name == NULL) {
5817 return(ret);
5818 }
5819 tmp = ret;
5820 while (tmp != NULL) {
5821 if (xmlStrEqual(name, tmp->name)) {
5822 xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
5823 "standalone: attribute enumeration value token %s duplicated\n",
5824 name, NULL);
5825 if (!xmlDictOwns(ctxt->dict, name))
5826 xmlFree(name);
5827 break;
5828 }
5829 tmp = tmp->next;
5830 }
5831 if (tmp == NULL) {
5833 if (!xmlDictOwns(ctxt->dict, name))
5834 xmlFree(name);
5835 if (cur == NULL) {
5837 return(NULL);
5838 }
5839 if (last == NULL) ret = last = cur;
5840 else {
5841 last->next = cur;
5842 last = cur;
5843 }
5844 }
5846 } while (RAW == '|');
5847 if (RAW != ')') {
5849 return(ret);
5850 }
5851 NEXT;
5852 return(ret);
5853}
static UINT UINT last
Definition: font.c:45
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1220
xmlChar * xmlParseNmtoken(xmlParserCtxtPtr ctxt)
Definition: parser.c:3662
xmlDictPtr dict
Definition: parser.h:263
WCHAR * name
Definition: name.c:42
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlCreateEnumeration(const xmlChar *name)
Definition: valid.c:1795
@ XML_ERR_ATTLIST_NOT_STARTED
Definition: xmlerror.h:150
@ XML_DTD_DUP_TOKEN
Definition: xmlerror.h:260
@ XML_ERR_NMTOKEN_REQUIRED
Definition: xmlerror.h:167
@ XML_ERR_ATTLIST_NOT_FINISHED
Definition: xmlerror.h:151

Referenced by xmlParseEnumeratedType().

◆ xmlParseExternalID()

XMLPUBFUN xmlChar *XMLCALL 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

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 4683 of file parser.c.

4683 {
4684 xmlChar *URI = NULL;
4685
4686 SHRINK;
4687
4688 *publicID = NULL;
4689 if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
4690 SKIP(6);
4691 if (SKIP_BLANKS == 0) {
4692 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4693 "Space required after 'SYSTEM'\n");
4694 }
4695 URI = xmlParseSystemLiteral(ctxt);
4696 if (URI == NULL) {
4698 }
4699 } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) {
4700 SKIP(6);
4701 if (SKIP_BLANKS == 0) {
4702 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4703 "Space required after 'PUBLIC'\n");
4704 }
4705 *publicID = xmlParsePubidLiteral(ctxt);
4706 if (*publicID == NULL) {
4708 }
4709 if (strict) {
4710 /*
4711 * We don't handle [83] so "S SystemLiteral" is required.
4712 */
4713 if (SKIP_BLANKS == 0) {
4714 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
4715 "Space required after the Public Identifier\n");
4716 }
4717 } else {
4718 /*
4719 * We handle [83] so we return immediately, if
4720 * "S SystemLiteral" is not detected. We skip blanks if no
4721 * system literal was found, but this is harmless since we must
4722 * be at the end of a NotationDecl.
4723 */
4724 if (SKIP_BLANKS == 0) return(NULL);
4725 if ((CUR != '\'') && (CUR != '"')) return(NULL);
4726 }
4727 URI = xmlParseSystemLiteral(ctxt);
4728 if (URI == NULL) {
4730 }
4731 }
4732 return(URI);
4733}
static int strict
Definition: error.c:51
xmlChar * xmlParsePubidLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4291
xmlChar * xmlParseSystemLiteral(xmlParserCtxtPtr ctxt)
Definition: parser.c:4199
@ 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 XMLCALL 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 6998 of file parser.c.

6999 {
7000 xmlDetectSAX2(ctxt);
7001 GROW;
7002
7003 if ((ctxt->encoding == NULL) &&
7004 (ctxt->input->end - ctxt->input->cur >= 4)) {
7005 xmlChar start[4];
7006 xmlCharEncoding enc;
7007
7008 start[0] = RAW;
7009 start[1] = NXT(1);
7010 start[2] = NXT(2);
7011 start[3] = NXT(3);
7012 enc = xmlDetectCharEncoding(start, 4);
7013 if (enc != XML_CHAR_ENCODING_NONE)
7014 xmlSwitchEncoding(ctxt, enc);
7015 }
7016
7017 if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
7018 xmlParseTextDecl(ctxt);
7019 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
7020 /*
7021 * The XML REC instructs us to stop parsing right here
7022 */
7023 xmlHaltParser(ctxt);
7024 return;
7025 }
7026 }
7027 if (ctxt->myDoc == NULL) {
7028 ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
7029 if (ctxt->myDoc == NULL) {
7030 xmlErrMemory(ctxt, "New Doc failed");
7031 return;
7032 }
7034 }
7035 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL))
7036 xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID);
7037
7038 ctxt->instate = XML_PARSER_DTD;
7039 ctxt->external = 1;
7041 while (((RAW == '<') && (NXT(1) == '?')) ||
7042 ((RAW == '<') && (NXT(1) == '!')) ||
7043 (RAW == '%')) {
7044 int id = ctxt->input->id;
7045 unsigned long cons = CUR_CONSUMED;
7046
7047 GROW;
7048 if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
7050 } else
7051 xmlParseMarkupDecl(ctxt);
7053
7054 if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
7056 break;
7057 }
7058 }
7059
7060 if (RAW != 0) {
7062 }
7063
7064}
pair cons(caddr_t car, pair cdr)
Definition: tree.c:57
xmlCharEncoding
Definition: encoding.h:56
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:952
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
static void xmlParseConditionalSections(xmlParserCtxtPtr ctxt)
Definition: parser.c:6703
void xmlParseTextDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6915
#define CUR_CONSUMED
Definition: parser.c:2170
void xmlParseMarkupDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6866
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1094
@ XML_ERR_EXT_SUBSET_NOT_FINISHED
Definition: xmlerror.h:160

Referenced by xmlSAX2ExternalSubset().

◆ xmlParseMarkupDecl()

XMLPUBFUN void XMLCALL xmlParseMarkupDecl ( xmlParserCtxtPtr  ctxt)

xmlParseMarkupDecl: @ctxt: an XML parser context

parse Markup declarations

[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 6866 of file parser.c.

6866 {
6867 GROW;
6868 if (CUR == '<') {
6869 if (NXT(1) == '!') {
6870 switch (NXT(2)) {
6871 case 'E':
6872 if (NXT(3) == 'L')
6873 xmlParseElementDecl(ctxt);
6874 else if (NXT(3) == 'N')
6875 xmlParseEntityDecl(ctxt);
6876 break;
6877 case 'A':
6879 break;
6880 case 'N':
6882 break;
6883 case '-':
6884 xmlParseComment(ctxt);
6885 break;
6886 default:
6887 /* there is an error but it will be detected later */
6888 break;
6889 }
6890 } else if (NXT(1) == '?') {
6891 xmlParsePI(ctxt);
6892 }
6893 }
6894
6895 /*
6896 * detect requirement to exit there and act accordingly
6897 * and avoid having instate overridden later on
6898 */
6899 if (ctxt->instate == XML_PARSER_EOF)
6900 return;
6901
6902 ctxt->instate = XML_PARSER_DTD;
6903}
void xmlParsePI(xmlParserCtxtPtr ctxt)
Definition: parser.c:5174
int xmlParseElementDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6598
void xmlParseEntityDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5409
void xmlParseComment(xmlParserCtxtPtr ctxt)
Definition: parser.c:4888
void xmlParseNotationDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5331
void xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:5976

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

◆ xmlParseMisc()

XMLPUBFUN void XMLCALL xmlParseMisc ( xmlParserCtxtPtr  ctxt)

xmlParseMisc: @ctxt: an XML parser context

parse an XML Misc* optional field.

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

Definition at line 10667 of file parser.c.

10667 {
10668 while (ctxt->instate != XML_PARSER_EOF) {
10670 GROW;
10671 if ((RAW == '<') && (NXT(1) == '?')) {
10672 xmlParsePI(ctxt);
10673 } else if (CMP4(CUR_PTR, '<', '!', '-', '-')) {
10674 xmlParseComment(ctxt);
10675 } else {
10676 break;
10677 }
10678 }
10679}
#define CMP4(s, c1, c2, c3, c4)
Definition: parser.c:2070

Referenced by xmlParseDocument().

◆ xmlParseName()

XMLPUBFUN const xmlChar *XMLCALL xmlParseName ( xmlParserCtxtPtr  ctxt)

Generic production rules.

xmlParseName: @ctxt: an XML parser context

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 3344 of file parser.c.

3344 {
3345 const xmlChar *in;
3346 const xmlChar *ret;
3347 size_t count = 0;
3348 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3351
3352 GROW;
3353
3354#ifdef DEBUG
3355 nbParseName++;
3356#endif
3357
3358 /*
3359 * Accelerator for simple ASCII names
3360 */
3361 in = ctxt->input->cur;
3362 if (((*in >= 0x61) && (*in <= 0x7A)) ||
3363 ((*in >= 0x41) && (*in <= 0x5A)) ||
3364 (*in == '_') || (*in == ':')) {
3365 in++;
3366 while (((*in >= 0x61) && (*in <= 0x7A)) ||
3367 ((*in >= 0x41) && (*in <= 0x5A)) ||
3368 ((*in >= 0x30) && (*in <= 0x39)) ||
3369 (*in == '_') || (*in == '-') ||
3370 (*in == ':') || (*in == '.'))
3371 in++;
3372 if ((*in > 0) && (*in < 0x80)) {
3373 count = in - ctxt->input->cur;
3374 if (count > maxLength) {
3375 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
3376 return(NULL);
3377 }
3378 ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
3379 ctxt->input->cur = in;
3380 ctxt->input->col += count;
3381 if (ret == NULL)
3382 xmlErrMemory(ctxt, NULL);
3383 return(ret);
3384 }
3385 }
3386 /* accelerator for special cases */
3387 return(xmlParseNameComplex(ctxt));
3388}
#define XML_MAX_NAME_LENGTH
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
static const xmlChar * xmlParseNameComplex(xmlParserCtxtPtr ctxt)
Definition: parser.c:3203
@ XML_ERR_NAME_TOO_LONG
Definition: xmlerror.h:210

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

◆ xmlParseNmtoken()

XMLPUBFUN xmlChar *XMLCALL xmlParseNmtoken ( xmlParserCtxtPtr  ctxt)

xmlParseNmtoken: @ctxt: an XML parser context

parse an XML Nmtoken.

[7] Nmtoken ::= (NameChar)+

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

Returns the Nmtoken parsed or NULL

Definition at line 3662 of file parser.c.

3662 {
3664 int len = 0, l;
3665 int c;
3666 int count = 0;
3667 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
3670
3671#ifdef DEBUG
3672 nbParseNmToken++;
3673#endif
3674
3675 GROW;
3676 if (ctxt->instate == XML_PARSER_EOF)
3677 return(NULL);
3678 c = CUR_CHAR(l);
3679
3680 while (xmlIsNameChar(ctxt, c)) {
3681 if (count++ > XML_PARSER_CHUNK_SIZE) {
3682 count = 0;
3683 GROW;
3684 }
3685 COPY_BUF(l,buf,len,c);
3686 NEXTL(l);
3687 c = CUR_CHAR(l);
3688 if (c == 0) {
3689 count = 0;
3690 GROW;
3691 if (ctxt->instate == XML_PARSER_EOF)
3692 return(NULL);
3693 c = CUR_CHAR(l);
3694 }
3695 if (len >= XML_MAX_NAMELEN) {
3696 /*
3697 * Okay someone managed to make a huge token, so he's ready to pay
3698 * for the processing speed.
3699 */
3700 xmlChar *buffer;
3701 int max = len * 2;
3702
3703 buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
3704 if (buffer == NULL) {
3705 xmlErrMemory(ctxt, NULL);
3706 return(NULL);
3707 }
3708 memcpy(buffer, buf, len);
3709 while (xmlIsNameChar(ctxt, c)) {
3710 if (count++ > XML_PARSER_CHUNK_SIZE) {
3711 count = 0;
3712 GROW;
3713 if (ctxt->instate == XML_PARSER_EOF) {
3714 xmlFree(buffer);
3715 return(NULL);
3716 }
3717 }
3718 if (len + 10 > max) {
3719 xmlChar *tmp;
3720
3721 max *= 2;
3722 tmp = (xmlChar *) xmlRealloc(buffer,
3723 max * sizeof(xmlChar));
3724 if (tmp == NULL) {
3725 xmlErrMemory(ctxt, NULL);
3726 xmlFree(buffer);
3727 return(NULL);
3728 }
3729 buffer = tmp;
3730 }
3732 NEXTL(l);
3733 c = CUR_CHAR(l);
3734 if (len > maxLength) {
3735 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
3736 xmlFree(buffer);
3737 return(NULL);
3738 }
3739 }
3740 buffer[len] = 0;
3741 return(buffer);
3742 }
3743 }
3744 if (len == 0)
3745 return(NULL);
3746 if (len > maxLength) {
3747 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
3748 return(NULL);
3749 }
3750 return(xmlStrndup(buf, len));
3751}
#define XML_MAX_NAMELEN
#define XML_PARSER_CHUNK_SIZE
Definition: parser.c:288
static int xmlIsNameChar(xmlParserCtxtPtr ctxt, int c)
Definition: parser.c:3161
#define max(a, b)
Definition: svc.c:63
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42

Referenced by xmlParseEnumerationType(), and xmlParseQName().

◆ xmlParseNotationDecl()

XMLPUBFUN void XMLCALL xmlParseNotationDecl ( xmlParserCtxtPtr  ctxt)

xmlParseNotationDecl: @ctxt: an XML parser context

parse a notation declaration

[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 5331 of file parser.c.

5331 {
5332 const xmlChar *name;
5333 xmlChar *Pubid;
5334 xmlChar *Systemid;
5335
5336 if (CMP10(CUR_PTR, '<', '!', 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
5337 int inputid = ctxt->input->id;
5338 SHRINK;
5339 SKIP(10);
5340 if (SKIP_BLANKS == 0) {
5341 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5342 "Space required after '<!NOTATION'\n");
5343 return;
5344 }
5345
5346 name = xmlParseName(ctxt);
5347 if (name == NULL) {
5349 return;
5350 }
5351 if (xmlStrchr(name, ':') != NULL) {
5352 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5353 "colons are forbidden from notation names '%s'\n",
5354 name, NULL, NULL);
5355 }
5356 if (SKIP_BLANKS == 0) {
5357 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5358 "Space required after the NOTATION name'\n");
5359 return;
5360 }
5361
5362 /*
5363 * Parse the IDs.
5364 */
5365 Systemid = xmlParseExternalID(ctxt, &Pubid, 0);
5367
5368 if (RAW == '>') {
5369 if (inputid != ctxt->input->id) {
5370 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5371 "Notation declaration doesn't start and stop"
5372 " in the same entity\n");
5373 }
5374 NEXT;
5375 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5376 (ctxt->sax->notationDecl != NULL))
5377 ctxt->sax->notationDecl(ctxt->userData, name, Pubid, Systemid);
5378 } else {
5380 }
5381 if (Systemid != NULL) xmlFree(Systemid);
5382 if (Pubid != NULL) xmlFree(Pubid);
5383 }
5384}
#define CMP10(s, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
Definition: parser.c:2084
@ XML_ERR_NOTATION_NOT_STARTED
Definition: xmlerror.h:148
@ XML_ERR_NOTATION_NOT_FINISHED
Definition: xmlerror.h:149

Referenced by xmlParseMarkupDecl().

◆ xmlParseNotationType()

XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseNotationType ( xmlParserCtxtPtr  ctxt)

xmlParseNotationType: @ctxt: an XML parser context

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 5732 of file parser.c.

5732 {
5733 const xmlChar *name;
5735
5736 if (RAW != '(') {
5738 return(NULL);
5739 }
5740 SHRINK;
5741 do {
5742 NEXT;
5744 name = xmlParseName(ctxt);
5745 if (name == NULL) {
5746 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5747 "Name expected in NOTATION declaration\n");
5749 return(NULL);
5750 }
5751 tmp = ret;
5752 while (tmp != NULL) {
5753 if (xmlStrEqual(name, tmp->name)) {
5754 xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
5755 "standalone: attribute notation value token %s duplicated\n",
5756 name, NULL);
5757 if (!xmlDictOwns(ctxt->dict, name))
5758 xmlFree((xmlChar *) name);
5759 break;
5760 }
5761 tmp = tmp->next;
5762 }
5763 if (tmp == NULL) {
5765 if (cur == NULL) {
5767 return(NULL);
5768 }
5769 if (last == NULL) ret = last = cur;
5770 else {
5771 last->next = cur;
5772 last = cur;
5773 }
5774 }
5776 } while (RAW == '|');
5777 if (RAW != ')') {
5780 return(NULL);
5781 }
5782 NEXT;
5783 return(ret);
5784}

Referenced by xmlParseEnumeratedType().

◆ xmlParsePEReference()

XMLPUBFUN void XMLCALL xmlParsePEReference ( xmlParserCtxtPtr  ctxt)

xmlParsePEReference: @ctxt: an XML parser context

parse PEReference declarations 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 7912 of file parser.c.

7913{
7914 const xmlChar *name;
7917
7918 if (RAW != '%')
7919 return;
7920 NEXT;
7921 name = xmlParseName(ctxt);
7922 if (name == NULL) {
7923 xmlFatalErrMsg(ctxt, XML_ERR_PEREF_NO_NAME, "PEReference: no name\n");
7924 return;
7925 }
7928 "PEReference: %s\n", name);
7929 if (RAW != ';') {
7931 return;
7932 }
7933
7934 NEXT;
7935
7936 /*
7937 * Increase the number of entity references parsed
7938 */
7939 ctxt->nbentities++;
7940
7941 /*
7942 * Request the entity from SAX
7943 */
7944 if ((ctxt->sax != NULL) &&
7945 (ctxt->sax->getParameterEntity != NULL))
7946 entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
7947 if (ctxt->instate == XML_PARSER_EOF)
7948 return;
7949 if (entity == NULL) {
7950 /*
7951 * [ WFC: Entity Declared ]
7952 * In a document without any DTD, a document with only an
7953 * internal DTD subset which contains no parameter entity
7954 * references, or a document with "standalone='yes'", ...
7955 * ... The declaration of a parameter entity must precede
7956 * any reference to it...
7957 */
7958 if ((ctxt->standalone == 1) ||
7959 ((ctxt->hasExternalSubset == 0) &&
7960 (ctxt->hasPErefs == 0))) {
7961 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7962 "PEReference: %%%s; not found\n",
7963 name);
7964 } else {
7965 /*
7966 * [ VC: Entity Declared ]
7967 * In a document with an external subset or external
7968 * parameter entities with "standalone='no'", ...
7969 * ... The declaration of a parameter entity must
7970 * precede any reference to it...
7971 */
7972 if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) {
7973 xmlValidityError(ctxt, XML_WAR_UNDECLARED_ENTITY,
7974 "PEReference: %%%s; not found\n",
7975 name, NULL);
7976 } else
7977 xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
7978 "PEReference: %%%s; not found\n",
7979 name, NULL);
7980 ctxt->valid = 0;
7981 }
7982 xmlParserEntityCheck(ctxt, 0, NULL, 0);
7983 } else {
7984 /*
7985 * Internal checking in case the entity quest barfed
7986 */
7987 if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
7989 xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
7990 "Internal: %%%s; is not a parameter entity\n",
7991 name, NULL);
7992 } else {
7993 xmlChar start[4];
7994 xmlCharEncoding enc;
7995
7996 if (xmlParserEntityCheck(ctxt, 0, entity, 0))
7997 return;
7998
7999 if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
8000 ((ctxt->options & XML_PARSE_NOENT) == 0) &&
8001 ((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
8002 ((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
8003 ((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
8004 (ctxt->replaceEntities == 0) &&
8005 (ctxt->validate == 0))
8006 return;
8007
8009 if (xmlPushInput(ctxt, input) < 0) {
8011 return;
8012 }
8013
8014 if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {
8015 /*
8016 * Get the 4 first bytes and decode the charset
8017 * if enc != XML_CHAR_ENCODING_NONE
8018 * plug some encoding conversion routines.
8019 * Note that, since we may have some non-UTF8
8020 * encoding (like UTF16, bug 135229), the 'length'
8021 * is not known, but we can calculate based upon
8022 * the amount of data in the buffer.
8023 */
8024 GROW
8025 if (ctxt->instate == XML_PARSER_EOF)
8026 return;
8027 if ((ctxt->input->end - ctxt->input->cur)>=4) {
8028 start[0] = RAW;
8029 start[1] = NXT(1);
8030 start[2] = NXT(2);
8031 start[3] = NXT(3);
8032 enc = xmlDetectCharEncoding(start, 4);
8033 if (enc != XML_CHAR_ENCODING_NONE) {
8034 xmlSwitchEncoding(ctxt, enc);
8035 }
8036 }
8037
8038 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
8039 (IS_BLANK_CH(NXT(5)))) {
8040 xmlParseTextDecl(ctxt);
8041 }
8042 }
8043 }
8044 }
8045 ctxt->hasPErefs = 1;
8046}
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
@ XML_PARSE_DTDVALID
Definition: parser.h:1097
@ XML_PARSE_DTDLOAD
Definition: parser.h:1095
@ XML_PARSE_DTDATTR
Definition: parser.h:1096
@ XML_PARSE_NOENT
Definition: parser.h:1094
int xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2290
xmlValidCtxt vctxt
Definition: parser.h:221
int validate
Definition: parser.h:220
@ XML_ERR_PEREF_NO_NAME
Definition: xmlerror.h:124
@ XML_ERR_PEREF_SEMICOL_MISSING
Definition: xmlerror.h:125

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

◆ xmlParsePI()

XMLPUBFUN void XMLCALL xmlParsePI ( xmlParserCtxtPtr  ctxt)

xmlParsePI: @ctxt: an XML parser context

parse an XML Processing Instruction.

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

The processing is transferred to SAX once parsed.

Definition at line 5174 of file parser.c.

5174 {
5175 xmlChar *buf = NULL;
5176 size_t len = 0;
5178 size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
5181 int cur, l;
5182 const xmlChar *target;
5184 int count = 0;
5185
5186 if ((RAW == '<') && (NXT(1) == '?')) {
5187 int inputid = ctxt->input->id;
5188 state = ctxt->instate;
5189 ctxt->instate = XML_PARSER_PI;
5190 /*
5191 * this is a Processing Instruction.
5192 */
5193 SKIP(2);
5194 SHRINK;
5195
5196 /*
5197 * Parse the target name and check for special support like
5198 * namespace.
5199 */
5200 target = xmlParsePITarget(ctxt);
5201 if (target != NULL) {
5202 if ((RAW == '?') && (NXT(1) == '>')) {
5203 if (inputid != ctxt->input->id) {
5204 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5205 "PI declaration doesn't start and stop in"
5206 " the same entity\n");
5207 }
5208 SKIP(2);
5209
5210 /*
5211 * SAX: PI detected.
5212 */
5213 if ((ctxt->sax) && (!ctxt->disableSAX) &&
5214 (ctxt->sax->processingInstruction != NULL))
5215 ctxt->sax->processingInstruction(ctxt->userData,
5216 target, NULL);
5217 if (ctxt->instate != XML_PARSER_EOF)
5218 ctxt->instate = state;
5219 return;
5220 }
5221 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
5222 if (buf == NULL) {
5223 xmlErrMemory(ctxt, NULL);
5224 ctxt->instate = state;
5225 return;
5226 }
5227 if (SKIP_BLANKS == 0) {
5228 xmlFatalErrMsgStr(ctxt, XML_ERR_SPACE_REQUIRED,
5229 "ParsePI: PI %s space expected\n", target);
5230 }
5231 cur = CUR_CHAR(l);
5232 while (IS_CHAR(cur) && /* checked */
5233 ((cur != '?') || (NXT(1) != '>'))) {
5234 if (len + 5 >= size) {
5235 xmlChar *tmp;
5236 size_t new_size = size * 2;
5237 tmp = (xmlChar *) xmlRealloc(buf, new_size);
5238 if (tmp == NULL) {
5239 xmlErrMemory(ctxt, NULL);
5240 xmlFree(buf);
5241 ctxt->instate = state;
5242 return;
5243 }
5244 buf = tmp;
5245 size = new_size;
5246 }
5247 count++;
5248 if (count > 50) {
5249 SHRINK;
5250 GROW;
5251 if (ctxt->instate == XML_PARSER_EOF) {
5252 xmlFree(buf);
5253 return;
5254 }
5255 count = 0;
5256 }
5257 COPY_BUF(l,buf,len,cur);
5258 NEXTL(l);
5259 cur = CUR_CHAR(l);
5260 if (cur == 0) {
5261 SHRINK;
5262 GROW;
5263 cur = CUR_CHAR(l);
5264 }
5265 if (len > maxLength) {
5266 xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
5267 "PI %s too big found", target);
5268 xmlFree(buf);
5269 ctxt->instate = state;
5270 return;
5271 }
5272 }
5273 buf[len] = 0;
5274 if (cur != '?') {
5275 xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
5276 "ParsePI: PI %s never end ...\n", target);
5277 } else {
5278 if (inputid != ctxt->input->id) {
5279 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5280 "PI declaration doesn't start and stop in"
5281 " the same entity\n");
5282 }
5283 SKIP(2);
5284
5285#ifdef LIBXML_CATALOG_ENABLED
5286 if (((state == XML_PARSER_MISC) ||
5287 (state == XML_PARSER_START)) &&
5288 (xmlStrEqual(target, XML_CATALOG_PI))) {
5289 xmlCatalogAllow allow = xmlCatalogGetDefaults();
5290 if ((allow == XML_CATA_ALLOW_DOCUMENT) ||
5291 (allow == XML_CATA_ALLOW_ALL))
5292 xmlParseCatalogPI(ctxt, buf);
5293 }
5294#endif
5295
5296
5297 /*
5298 * SAX: PI detected.
5299 */
5300 if ((ctxt->sax) && (!ctxt->disableSAX) &&
5301 (ctxt->sax->processingInstruction != NULL))
5302 ctxt->sax->processingInstruction(ctxt->userData,
5303 target, buf);
5304 }
5305 xmlFree(buf);
5306 } else {
5308 }
5309 if (ctxt->instate != XML_PARSER_EOF)
5310 ctxt->instate = state;
5311 }
5312}
GLenum target
Definition: glext.h:7315
@ XML_PARSER_PI
Definition: parser.h:114
@ XML_PARSER_START
Definition: parser.h:112
@ XML_PARSER_MISC
Definition: parser.h:113
const xmlChar * xmlParsePITarget(xmlParserCtxtPtr ctxt)
Definition: parser.c:5066
@ 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()

XMLPUBFUN const xmlChar *XMLCALL xmlParsePITarget ( xmlParserCtxtPtr  ctxt)

xmlParsePITarget: @ctxt: an XML parser context

parse the name of a PI

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

Returns the PITarget name or NULL

Definition at line 5066 of file parser.c.

5066 {
5067 const xmlChar *name;
5068
5069 name = xmlParseName(ctxt);
5070 if ((name != NULL) &&
5071 ((name[0] == 'x') || (name[0] == 'X')) &&
5072 ((name[1] == 'm') || (name[1] == 'M')) &&
5073 ((name[2] == 'l') || (name[2] == 'L'))) {
5074 int i;
5075 if ((name[0] == 'x') && (name[1] == 'm') &&
5076 (name[2] == 'l') && (name[3] == 0)) {
5077 xmlFatalErrMsg(ctxt, XML_ERR_RESERVED_XML_NAME,
5078 "XML declaration allowed only at the start of the document\n");
5079 return(name);
5080 } else if (name[3] == 0) {
5082 return(name);
5083 }
5084 for (i = 0;;i++) {
5085 if (xmlW3CPIs[i] == NULL) break;
5086 if (xmlStrEqual(name, (const xmlChar *)xmlW3CPIs[i]))
5087 return(name);
5088 }
5089 xmlWarningMsg(ctxt, XML_ERR_RESERVED_XML_NAME,
5090 "xmlParsePITarget: invalid name prefix 'xml'\n",
5091 NULL, NULL);
5092 }
5093 if ((name != NULL) && (xmlStrchr(name, ':') != NULL)) {
5094 xmlNsErr(ctxt, XML_NS_ERR_COLON,
5095 "colons are forbidden from PI names '%s'\n", name, NULL, NULL);
5096 }
5097 return(name);
5098}
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:294
@ XML_ERR_RESERVED_XML_NAME
Definition: xmlerror.h:164

Referenced by xmlParsePI().

◆ xmlParsePubidLiteral()

XMLPUBFUN xmlChar *XMLCALL xmlParsePubidLiteral ( xmlParserCtxtPtr  ctxt)

xmlParsePubidLiteral: @ctxt: an XML parser context

parse an XML public literal

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

Returns the PubidLiteral parsed or NULL.

Definition at line 4291 of file parser.c.

4291 {
4292 xmlChar *buf = NULL;
4293 int len = 0;
4295 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4298 xmlChar cur;
4299 xmlChar stop;
4300 int count = 0;
4301 xmlParserInputState oldstate = ctxt->instate;
4302
4303 SHRINK;
4304 if (RAW == '"') {
4305 NEXT;
4306 stop = '"';
4307 } else if (RAW == '\'') {
4308 NEXT;
4309 stop = '\'';
4310 } else {
4312 return(NULL);
4313 }
4314 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4315 if (buf == NULL) {
4316 xmlErrMemory(ctxt, NULL);
4317 return(NULL);
4318 }
4320 cur = CUR;
4321 while ((IS_PUBIDCHAR_CH(cur)) && (cur != stop)) { /* checked */
4322 if (len + 1 >= size) {
4323 xmlChar *tmp;
4324
4325 size *= 2;
4326 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
4327 if (tmp == NULL) {
4328 xmlErrMemory(ctxt, NULL);
4329 xmlFree(buf);
4330 return(NULL);
4331 }
4332 buf = tmp;
4333 }
4334 buf[len++] = cur;
4335 count++;
4336 if (count > 50) {
4337 SHRINK;
4338 GROW;
4339 count = 0;
4340 if (ctxt->instate == XML_PARSER_EOF) {
4341 xmlFree(buf);
4342 return(NULL);
4343 }
4344 }
4345 NEXT;
4346 cur = CUR;
4347 if (cur == 0) {
4348 GROW;
4349 SHRINK;
4350 cur = CUR;
4351 }
4352 if (len > maxLength) {
4353 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID");
4354 xmlFree(buf);
4355 return(NULL);
4356 }
4357 }
4358 buf[len] = 0;
4359 if (cur != stop) {
4361 } else {
4362 NEXT;
4363 }
4364 ctxt->instate = oldstate;
4365 return(buf);
4366}
#define IS_PUBIDCHAR_CH(c)
@ XML_PARSER_PUBLIC_LITERAL
Definition: parser.h:128
@ XML_ERR_LITERAL_NOT_FINISHED
Definition: xmlerror.h:144
@ XML_ERR_LITERAL_NOT_STARTED
Definition: xmlerror.h:143

Referenced by xmlParseExternalID().

◆ xmlParseReference()

XMLPUBFUN void XMLCALL xmlParseReference ( xmlParserCtxtPtr  ctxt)

xmlParseReference: @ctxt: an XML parser context

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.

[67] Reference ::= EntityRef | CharRef

Definition at line 7078 of file parser.c.

7078 {
7079 xmlEntityPtr ent;
7080 xmlChar *val;
7081 int was_checked;
7084
7085
7086 if (RAW != '&')
7087 return;
7088
7089 /*
7090 * Simple case of a CharRef
7091 */
7092 if (NXT(1) == '#') {
7093 int i = 0;
7094 xmlChar out[16];
7095 int hex = NXT(2);
7096 int value = xmlParseCharRef(ctxt);
7097
7098 if (value == 0)
7099 return;
7100 if (ctxt->charset != XML_CHAR_ENCODING_UTF8) {
7101 /*
7102 * So we are using non-UTF-8 buffers
7103 * Check that the char fit on 8bits, if not
7104 * generate a CharRef.
7105 */
7106 if (value <= 0xFF) {
7107 out[0] = value;
7108 out[1] = 0;
7109 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7110 (!ctxt->disableSAX))
7111 ctxt->sax->characters(ctxt->userData, out, 1);
7112 } else {
7113 if ((hex == 'x') || (hex == 'X'))
7114 snprintf((char *)out, sizeof(out), "#x%X", value);
7115 else
7116 snprintf((char *)out, sizeof(out), "#%d", value);
7117 if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
7118 (!ctxt->disableSAX))
7119 ctxt->sax->reference(ctxt->userData, out);
7120 }
7121 } else {
7122 /*
7123 * Just encode the value in UTF-8
7124 */
7125 COPY_BUF(0 ,out, i, value);
7126 out[i] = 0;
7127 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7128 (!ctxt->disableSAX))
7129 ctxt->sax->characters(ctxt->userData, out, i);
7130 }
7131 return;
7132 }
7133
7134 /*
7135 * We are seeing an entity reference
7136 */
7137 ent = xmlParseEntityRef(ctxt);
7138 if (ent == NULL) return;
7139 if (!ctxt->wellFormed)
7140 return;
7141 was_checked = ent->checked;
7142
7143 /* special case of predefined entities */
7144 if ((ent->name == NULL) ||
7146 val = ent->content;
7147 if (val == NULL) return;
7148 /*
7149 * inline the entity.
7150 */
7151 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
7152 (!ctxt->disableSAX))
7153 ctxt->sax->characters(ctxt->userData, val, xmlStrlen(val));
7154 return;
7155 }
7156
7157 /*
7158 * The first reference to the entity trigger a parsing phase
7159 * where the ent->children is filled with the result from
7160 * the parsing.
7161 * Note: external parsed entities will not be loaded, it is not
7162 * required for a non-validating parser, unless the parsing option
7163 * of validating, or substituting entities were given. Doing so is
7164 * far more secure as the parser will only process data coming from
7165 * the document entity by default.
7166 */
7167 if (((ent->checked == 0) ||
7168 ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
7171 unsigned long oldnbent = ctxt->nbentities, diff;
7172
7173 /*
7174 * This is a bit hackish but this seems the best
7175 * way to make sure both SAX and DOM entity support
7176 * behaves okay.
7177 */
7178 void *user_data;
7179 if (ctxt->userData == ctxt)
7180 user_data = NULL;
7181 else
7182 user_data = ctxt->userData;
7183
7184 /*
7185 * Check that this entity is well formed
7186 * 4.3.2: An internal general parsed entity is well-formed
7187 * if its replacement text matches the production labeled
7188 * content.
7189 */
7190 if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
7191 ctxt->depth++;
7193 user_data, &list);
7194 ctxt->depth--;
7195
7196 } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
7197 ctxt->depth++;
7198 ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax,
7199 user_data, ctxt->depth, ent->URI,
7200 ent->ExternalID, &list);
7201 ctxt->depth--;
7202 } else {
7204 xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
7205 "invalid entity type found\n", NULL);
7206 }
7207
7208 /*
7209 * Store the number of entities needing parsing for this entity
7210 * content and do checkings
7211 */
7212 diff = ctxt->nbentities - oldnbent + 1;
7213 if (diff > INT_MAX / 2)
7214 diff = INT_MAX / 2;
7215 ent->checked = diff * 2;
7216 if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
7217 ent->checked |= 1;
7218 if (ret == XML_ERR_ENTITY_LOOP) {
7220 xmlHaltParser(ctxt);
7222 return;
7223 }
7224 if (xmlParserEntityCheck(ctxt, 0, ent, 0)) {
7226 return;
7227 }
7228
7229 if ((ret == XML_ERR_OK) && (list != NULL)) {
7230 if (((ent->etype == XML_INTERNAL_GENERAL_ENTITY) ||
7232 (ent->children == NULL)) {
7233 ent->children = list;
7234 /*
7235 * Prune it directly in the generated document
7236 * except for single text nodes.
7237 */
7238 if ((ctxt->replaceEntities == 0) ||
7239 (ctxt->parseMode == XML_PARSE_READER) ||
7240 ((list->type == XML_TEXT_NODE) &&
7241 (list->next == NULL))) {
7242 ent->owner = 1;
7243 while (list != NULL) {
7244 list->parent = (xmlNodePtr) ent;
7245 if (list->doc != ent->doc)
7246 xmlSetTreeDoc(list, ent->doc);
7247 if (list->next == NULL)
7248 ent->last = list;
7249 list = list->next;
7250 }
7251 list = NULL;
7252 } else {
7253 ent->owner = 0;
7254 while (list != NULL) {
7255 list->parent = (xmlNodePtr) ctxt->node;
7256 list->doc = ctxt->myDoc;
7257 if (list->next == NULL)
7258 ent->last = list;
7259 list = list->next;
7260 }
7261 list = ent->children;
7262#ifdef LIBXML_LEGACY_ENABLED
7264 xmlAddEntityReference(ent, list, NULL);
7265#endif /* LIBXML_LEGACY_ENABLED */
7266 }
7267 } else {
7269 list = NULL;
7270 }
7271 } else if ((ret != XML_ERR_OK) &&
7273 xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
7274 "Entity '%s' failed to parse\n", ent->name);
7275 if (ent->content != NULL)
7276 ent->content[0] = 0;
7277 xmlParserEntityCheck(ctxt, 0, ent, 0);
7278 } else if (list != NULL) {
7280 list = NULL;
7281 }
7282 if (ent->checked == 0)
7283 ent->checked = 2;
7284
7285 /* Prevent entity from being parsed and expanded twice (Bug 760367). */
7286 was_checked = 0;
7287 } else if (ent->checked != 1) {
7288 ctxt->nbentities += ent->checked / 2;
7289 }
7290
7291 /*
7292 * Now that the entity content has been gathered
7293 * provide it to the application, this can take different forms based
7294 * on the parsing modes.
7295 */
7296 if (ent->children == NULL) {
7297 /*
7298 * Probably running in SAX mode and the callbacks don't
7299 * build the entity content. So unless we already went
7300 * though parsing for first checking go though the entity
7301 * content to generate callbacks associated to the entity
7302 */
7303 if (was_checked != 0) {
7304 void *user_data;
7305 /*
7306 * This is a bit hackish but this seems the best
7307 * way to make sure both SAX and DOM entity support
7308 * behaves okay.
7309 */
7310 if (ctxt->userData == ctxt)
7311 user_data = NULL;
7312 else
7313 user_data = ctxt->userData;
7314
7315 if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
7316 ctxt->depth++;
7318 ent->content, user_data, NULL);
7319 ctxt->depth--;
7320 } else if (ent->etype ==
7322 ctxt->depth++;
7324 ctxt->sax, user_data, ctxt->depth,
7325 ent->URI, ent->ExternalID, NULL);
7326 ctxt->depth--;
7327 } else {
7329 xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
7330 "invalid entity type found\n", NULL);
7331 }
7332 if (ret == XML_ERR_ENTITY_LOOP) {
7334 return;
7335 }
7336 }
7337 if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
7338 (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
7339 /*
7340 * Entity reference callback comes second, it's somewhat
7341 * superfluous but a compatibility to historical behaviour
7342 */
7343 ctxt->sax->reference(ctxt->userData, ent->name);
7344 }
7345 return;
7346 }
7347
7348 /*
7349 * If we didn't get any children for the entity being built
7350 */
7351 if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
7352 (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
7353 /*
7354 * Create a node.
7355 */
7356 ctxt->sax->reference(ctxt->userData, ent->name);
7357 return;
7358 }
7359
7360 if ((ctxt->replaceEntities) || (ent->children == NULL)) {
7361 /*
7362 * There is a problem on the handling of _private for entities
7363 * (bug 155816): Should we copy the content of the field from
7364 * the entity (possibly overwriting some value set by the user
7365 * when a copy is created), should we leave it alone, or should
7366 * we try to take care of different situations? The problem
7367 * is exacerbated by the usage of this field by the xmlReader.
7368 * To fix this bug, we look at _private on the created node
7369 * and, if it's NULL, we copy in whatever was in the entity.
7370 * If it's not NULL we leave it alone. This is somewhat of a
7371 * hack - maybe we should have further tests to determine
7372 * what to do.
7373 */
7374 if ((ctxt->node != NULL) && (ent->children != NULL)) {
7375 /*
7376 * Seems we are generating the DOM content, do
7377 * a simple tree copy for all references except the first
7378 * In the first occurrence list contains the replacement.
7379 */
7380 if (((list == NULL) && (ent->owner == 0)) ||
7381 (ctxt->parseMode == XML_PARSE_READER)) {
7382 xmlNodePtr nw = NULL, cur, firstChild = NULL;
7383
7384 /*
7385 * We are copying here, make sure there is no abuse
7386 */
7387 ctxt->sizeentcopy += ent->length + 5;
7388 if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
7389 return;
7390
7391 /*
7392 * when operating on a reader, the entities definitions
7393 * are always owning the entities subtree.
7394 if (ctxt->parseMode == XML_PARSE_READER)
7395 ent->owner = 1;
7396 */
7397
7398 cur = ent->children;
7399 while (cur != NULL) {
7400 nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
7401 if (nw != NULL) {
7402 if (nw->_private == NULL)
7403 nw->_private = cur->_private;
7404 if (firstChild == NULL){
7405 firstChild = nw;
7406 }
7407 nw = xmlAddChild(ctxt->node, nw);
7408 }
7409 if (cur == ent->last) {
7410 /*
7411 * needed to detect some strange empty
7412 * node cases in the reader tests
7413 */
7414 if ((ctxt->parseMode == XML_PARSE_READER) &&
7415 (nw != NULL) &&
7416 (nw->type == XML_ELEMENT_NODE) &&
7417 (nw->children == NULL))
7418 nw->extra = 1;
7419
7420 break;
7421 }
7422 cur = cur->next;
7423 }
7424#ifdef LIBXML_LEGACY_ENABLED
7426 xmlAddEntityReference(ent, firstChild, nw);
7427#endif /* LIBXML_LEGACY_ENABLED */
7428 } else if ((list == NULL) || (ctxt->inputNr > 0)) {
7429 xmlNodePtr nw = NULL, cur, next, last,
7430 firstChild = NULL;
7431
7432 /*
7433 * We are copying here, make sure there is no abuse
7434 */
7435 ctxt->sizeentcopy += ent->length + 5;
7436 if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
7437 return;
7438
7439 /*
7440 * Copy the entity child list and make it the new
7441 * entity child list. The goal is to make sure any
7442 * ID or REF referenced will be the one from the
7443 * document content and not the entity copy.
7444 */
7445 cur = ent->children;
7446 ent->children = NULL;
7447 last = ent->last;
7448 ent->last = NULL;
7449 while (cur != NULL) {
7450 next = cur->next;
7451 cur->next = NULL;
7452 cur->parent = NULL;
7453 nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
7454 if (nw != NULL) {
7455 if (nw->_private == NULL)
7456 nw->_private = cur->_private;
7457 if (firstChild == NULL){
7458 firstChild = cur;
7459 }
7460 xmlAddChild((xmlNodePtr) ent, nw);
7461 xmlAddChild(ctxt->node, cur);
7462 }
7463 if (cur == last)
7464 break;
7465 cur = next;
7466 }
7467 if (ent->owner == 0)
7468 ent->owner = 1;
7469#ifdef LIBXML_LEGACY_ENABLED
7471 xmlAddEntityReference(ent, firstChild, nw);
7472#endif /* LIBXML_LEGACY_ENABLED */
7473 } else {
7474 const xmlChar *nbktext;
7475
7476 /*
7477 * the name change is to avoid coalescing of the
7478 * node with a possible previous text one which
7479 * would make ent->children a dangling pointer
7480 */
7481 nbktext = xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
7482 -1);
7483 if (ent->children->type == XML_TEXT_NODE)
7484 ent->children->name = nbktext;
7485 if ((ent->last != ent->children) &&
7486 (ent->last->type == XML_TEXT_NODE))
7487 ent->last->name = nbktext;
7488 xmlAddChildList(ctxt->node, ent->children);
7489 }
7490
7491 /*
7492 * This is to avoid a nasty side effect, see
7493 * characters() in SAX.c
7494 */
7495 ctxt->nodemem = 0;
7496 ctxt->nodelen = 0;
7497 return;
7498 }
7499 }
7500}
Definition: list.h:37
struct list * next
Definition: list.h:38
int hex(char ch)
#define INT_MAX
Definition: limits.h:40
if(dx< 0)
Definition: linetemp.h:194
static unsigned __int64 next
Definition: rand_nt.c:6
#define list
Definition: rosglue.h:35
@ XML_PARSE_READER
Definition: parser.h:167
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNode * xmlNodePtr
Definition: tree.h:488
@ XML_TEXT_NODE
Definition: tree.h:162
@ XML_ELEMENT_NODE
Definition: tree.h:160
XMLPUBFUN void XMLCALL xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc)
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int recursive)
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:13005
static xmlParserErrors xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt, const xmlChar *string, void *user_data, xmlNodePtr *lst)
Definition: parser.c:13303
xmlEntityPtr xmlParseEntityRef(xmlParserCtxtPtr ctxt)
Definition: parser.c:7531
int xmlParseCharRef(xmlParserCtxtPtr ctxt)
Definition: parser.c:2332
int length
Definition: entities.h:51
const xmlChar * URI
Definition: entities.h:57
const xmlChar * name
Definition: entities.h:41
const xmlChar * ExternalID
Definition: entities.h:53
struct _xmlNode * last
Definition: entities.h:43
struct _xmlNode * children
Definition: entities.h:42
struct _xmlDoc * doc
Definition: entities.h:47
int owner
Definition: entities.h:58
void * _private
Definition: tree.h:490
struct _xmlNode * children
Definition: tree.h:493
unsigned short extra
Definition: tree.h:507
xmlElementType type
Definition: tree.h:491
xmlParserMode parseMode
Definition: parser.h:302
unsigned long sizeentcopy
Definition: parser.h:313
@ XML_ERR_OK
Definition: xmlerror.h:100
@ XML_ERR_ENTITY_LOOP
Definition: xmlerror.h:189

Referenced by xmlParseContentInternal().

◆ xmlParserHandlePEReference()

XMLPUBFUN void XMLCALL xmlParserHandlePEReference ( xmlParserCtxtPtr  ctxt)

xmlParserHandlePEReference: @ctxt: the parser context

[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 2550 of file parser.c.

2550 {
2551 switch(ctxt->instate) {
2553 return;
2554 case XML_PARSER_COMMENT:
2555 return;
2557 return;
2558 case XML_PARSER_END_TAG:
2559 return;
2560 case XML_PARSER_EOF:
2562 return;
2563 case XML_PARSER_PROLOG:
2564 case XML_PARSER_START:
2565 case XML_PARSER_MISC:
2567 return;
2569 case XML_PARSER_CONTENT:
2571 case XML_PARSER_PI:
2574 /* we just ignore it there */
2575 return;
2576 case XML_PARSER_EPILOG:
2578 return;
2580 /*
2581 * NOTE: in the case of entity values, we don't do the
2582 * substitution here since we need the literal
2583 * entity value to be able to save the internal
2584 * subset of the document.
2585 * This will be handled by xmlStringDecodeEntities
2586 */
2587 return;
2588 case XML_PARSER_DTD:
2589 /*
2590 * [WFC: Well-Formedness Constraint: PEs in Internal Subset]
2591 * In the internal DTD subset, parameter-entity references
2592 * can occur only where markup declarations can occur, not
2593 * within markup declarations.
2594 * In that case this is handled in xmlParseMarkupDecl
2595 */
2596 if ((ctxt->external == 0) && (ctxt->inputNr == 1))
2597 return;
2598 if (IS_BLANK_CH(NXT(1)) || NXT(1) == 0)
2599 return;
2600 break;
2601 case XML_PARSER_IGNORE:
2602 return;
2603 }
2604
2605 xmlParsePEReference(ctxt);
2606}
@ XML_PARSER_END_TAG
Definition: parser.h:121
@ XML_PARSER_PROLOG
Definition: parser.h:116
@ XML_PARSER_IGNORE
Definition: parser.h:127
@ XML_PARSER_SYSTEM_LITERAL
Definition: parser.h:125
@ XML_PARSER_START_TAG
Definition: parser.h:118
@ XML_PARSER_EPILOG
Definition: parser.h:126
void xmlParsePEReference(xmlParserCtxtPtr ctxt)
Definition: parser.c:7912
@ 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()

XMLPUBFUN void XMLCALL xmlParserInputShrink ( xmlParserInputPtr  in)

xmlParserInputShrink: @in: an XML parser input

This function removes used input for the parser.

Definition at line 327 of file parserInternals.c.

327 {
328 size_t used;
329 size_t ret;
330
331#ifdef DEBUG_INPUT
333#endif
334 if (in == NULL) return;
335 if (in->buf == NULL) return;
336 if (in->base == NULL) return;
337 if (in->cur == NULL) return;
338 if (in->buf->buffer == NULL) return;
339
341
342 used = in->cur - in->base;
343 /*
344 * Do not shrink on large buffers whose only a tiny fraction
345 * was consumed
346 */
347 if (used > INPUT_CHUNK) {
348 ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
349 if (ret > 0) {
350 used -= ret;
351 in->consumed += ret;
352 }
353 }
354
355 if (xmlBufUse(in->buf->buffer) <= INPUT_CHUNK) {
357 }
358
359 in->base = xmlBufContent(in->buf->buffer);
360 in->cur = in->base + used;
361 in->end = xmlBufEnd(in->buf->buffer);
362
364}
static int used
Definition: adh-main.c:39
#define CHECK_BUFFER(in)
#define LINE_LEN
XMLPUBFUN xmlChar *XMLCALL xmlBufEnd(xmlBufPtr buf)
Definition: buf.c:571
XMLPUBFUN size_t XMLCALL xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:633
XMLPUBFUN size_t XMLCALL xmlBufShrink(xmlBufPtr buf, size_t len)
Definition: buf.c:381
XMLPUBFUN xmlChar *XMLCALL xmlBufContent(const xmlBuf *buf)
Definition: buf.c:553
XMLPUBFUN int XMLCALL xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len)

Referenced by xmlSHRINK().

◆ xmlParseSDDecl()

XMLPUBFUN int XMLCALL xmlParseSDDecl ( xmlParserCtxtPtr  ctxt)

xmlParseSDDecl: @ctxt: an XML parser context

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 10490 of file parser.c.

10490 {
10491 int standalone = -2;
10492
10494 if (CMP10(CUR_PTR, 's', 't', 'a', 'n', 'd', 'a', 'l', 'o', 'n', 'e')) {
10495 SKIP(10);
10497 if (RAW != '=') {
10499 return(standalone);
10500 }
10501 NEXT;
10503 if (RAW == '\''){
10504 NEXT;
10505 if ((RAW == 'n') && (NXT(1) == 'o')) {
10506 standalone = 0;
10507 SKIP(2);
10508 } else if ((RAW == 'y') && (NXT(1) == 'e') &&
10509 (NXT(2) == 's')) {
10510 standalone = 1;
10511 SKIP(3);
10512 } else {
10514 }
10515 if (RAW != '\'') {
10517 } else
10518 NEXT;
10519 } else if (RAW == '"'){
10520 NEXT;
10521 if ((RAW == 'n') && (NXT(1) == 'o')) {
10522 standalone = 0;
10523 SKIP(2);
10524 } else if ((RAW == 'y') && (NXT(1) == 'e') &&
10525 (NXT(2) == 's')) {
10526 standalone = 1;
10527 SKIP(3);
10528 } else {
10530 }
10531 if (RAW != '"') {
10533 } else
10534 NEXT;
10535 } else {
10537 }
10538 }
10539 return(standalone);
10540}
@ XML_ERR_STANDALONE_VALUE
Definition: xmlerror.h:178

Referenced by xmlParseXMLDecl().

◆ xmlParseSystemLiteral()

XMLPUBFUN xmlChar *XMLCALL xmlParseSystemLiteral ( xmlParserCtxtPtr  ctxt)

xmlParseSystemLiteral: @ctxt: an XML parser context

parse an XML Literal

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

Returns the SystemLiteral parsed or NULL

Definition at line 4199 of file parser.c.

4199 {
4200 xmlChar *buf = NULL;
4201 int len = 0;
4203 int cur, l;
4204 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4207 xmlChar stop;
4208 int state = ctxt->instate;
4209 int count = 0;
4210
4211 SHRINK;
4212 if (RAW == '"') {
4213 NEXT;
4214 stop = '"';
4215 } else if (RAW == '\'') {
4216 NEXT;
4217 stop = '\'';
4218 } else {
4220 return(NULL);
4221 }
4222
4223 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4224 if (buf == NULL) {
4225 xmlErrMemory(ctxt, NULL);
4226 return(NULL);
4227 }
4229 cur = CUR_CHAR(l);
4230 while ((IS_CHAR(cur)) && (cur != stop)) { /* checked */
4231 if (len + 5 >= size) {
4232 xmlChar *tmp;
4233
4234 size *= 2;
4235 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
4236 if (tmp == NULL) {
4237 xmlFree(buf);
4238 xmlErrMemory(ctxt, NULL);
4240 return(NULL);
4241 }
4242 buf = tmp;
4243 }
4244 count++;
4245 if (count > 50) {
4246 SHRINK;
4247 GROW;
4248 count = 0;
4249 if (ctxt->instate == XML_PARSER_EOF) {
4250 xmlFree(buf);
4251 return(NULL);
4252 }
4253 }
4254 COPY_BUF(l,buf,len,cur);
4255 NEXTL(l);
4256 cur = CUR_CHAR(l);
4257 if (cur == 0) {
4258 GROW;
4259 SHRINK;
4260 cur = CUR_CHAR(l);
4261 }
4262 if (len > maxLength) {
4263 xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral");
4264 xmlFree(buf);
4266 return(NULL);
4267 }
4268 }
4269 buf[len] = 0;
4271 if (!IS_CHAR(cur)) {
4273 } else {
4274 NEXT;
4275 }
4276 return(buf);
4277}

Referenced by xmlParseExternalID().

◆ xmlParseTextDecl()

XMLPUBFUN void XMLCALL xmlParseTextDecl ( xmlParserCtxtPtr  ctxt)

xmlParseTextDecl: @ctxt: an XML parser context

parse an XML declaration header for external entities

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

Definition at line 6915 of file parser.c.

6915 {
6917 const xmlChar *encoding;
6918 int oldstate;
6919
6920 /*
6921 * We know that '<?xml' is here.
6922 */
6923 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
6924 SKIP(5);
6925 } else {
6927 return;
6928 }
6929
6930 /* Avoid expansion of parameter entities when skipping blanks. */
6931 oldstate = ctxt->instate;
6932 ctxt->instate = XML_PARSER_START;
6933
6934 if (SKIP_BLANKS == 0) {
6935 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6936 "Space needed after '<?xml'\n");
6937 }
6938
6939 /*
6940 * We may have the VersionInfo here.
6941 */
6943 if (version == NULL)
6945 else {
6946 if (SKIP_BLANKS == 0) {
6947 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6948 "Space needed here\n");
6949 }
6950 }
6951 ctxt->input->version = version;
6952
6953 /*
6954 * We must have the encoding declaration
6955 */
6957 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
6958 /*
6959 * The XML REC instructs us to stop parsing right here
6960 */
6961 ctxt->instate = oldstate;
6962 return;
6963 }
6964 if ((encoding == NULL) && (ctxt->errNo == XML_ERR_OK)) {
6965 xmlFatalErrMsg(ctxt, XML_ERR_MISSING_ENCODING,
6966 "Missing encoding in text declaration\n");
6967 }
6968
6970 if ((RAW == '?') && (NXT(1) == '>')) {
6971 SKIP(2);
6972 } else if (RAW == '>') {
6973 /* Deprecated old WD ... */
6975 NEXT;
6976 } else {
6979 NEXT;
6980 }
6981
6982 ctxt->instate = oldstate;
6983}
static const WCHAR version[]
Definition: asmname.c:66
#define MOVETO_ENDTAG(p)
#define XML_DEFAULT_VERSION
Definition: parser.h:31
xmlChar * xmlParseVersionInfo(xmlParserCtxtPtr ctxt)
Definition: parser.c:10249
const xmlChar * xmlParseEncodingDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10358
const xmlChar * version
Definition: parser.h:72
@ XML_ERR_XMLDECL_NOT_FINISHED
Definition: xmlerror.h:157
@ XML_ERR_XMLDECL_NOT_STARTED
Definition: xmlerror.h:156
@ XML_ERR_MISSING_ENCODING
Definition: xmlerror.h:201
XMLPUBFUN xmlChar *XMLCALL xmlCharStrdup(const char *cur)
Definition: xmlstring.c:114

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

◆ xmlParseVersionInfo()

XMLPUBFUN xmlChar *XMLCALL xmlParseVersionInfo ( xmlParserCtxtPtr  ctxt)

xmlParseVersionInfo: @ctxt: an XML parser context

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 10249 of file parser.c.

10249 {
10250 xmlChar *version = NULL;
10251
10252 if (CMP7(CUR_PTR, 'v', 'e', 'r', 's', 'i', 'o', 'n')) {
10253 SKIP(7);
10255 if (RAW != '=') {
10257 return(NULL);
10258 }
10259 NEXT;
10261 if (RAW == '"') {
10262 NEXT;
10264 if (RAW != '"') {
10266 } else
10267 NEXT;
10268 } else if (RAW == '\''){
10269 NEXT;
10271 if (RAW != '\'') {
10273 } else
10274 NEXT;
10275 } else {
10277 }
10278 }
10279 return(version);
10280}
xmlChar * xmlParseVersionNum(xmlParserCtxtPtr ctxt)
Definition: parser.c:10188

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseVersionNum()

XMLPUBFUN xmlChar *XMLCALL xmlParseVersionNum ( xmlParserCtxtPtr  ctxt)

xmlParseVersionNum: @ctxt: an XML parser context

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 10188 of file parser.c.

10188 {
10189 xmlChar *buf = NULL;
10190 int len = 0;
10191 int size = 10;
10192 xmlChar cur;
10193
10194 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10195 if (buf == NULL) {
10196 xmlErrMemory(ctxt, NULL);
10197 return(NULL);
10198 }
10199 cur = CUR;
10200 if (!((cur >= '0') && (cur <= '9'))) {
10201 xmlFree(buf);
10202 return(NULL);
10203 }
10204 buf[len++] = cur;
10205 NEXT;
10206 cur=CUR;
10207 if (cur != '.') {
10208 xmlFree(buf);
10209 return(NULL);
10210 }
10211 buf[len++] = cur;
10212 NEXT;
10213 cur=CUR;
10214 while ((cur >= '0') && (cur <= '9')) {
10215 if (len + 1 >= size) {
10216 xmlChar *tmp;
10217
10218 size *= 2;
10219 tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10220 if (tmp == NULL) {
10221 xmlFree(buf);
10222 xmlErrMemory(ctxt, NULL);
10223 return(NULL);
10224 }
10225 buf = tmp;
10226 }
10227 buf[len++] = cur;
10228 NEXT;
10229 cur=CUR;
10230 }
10231 buf[len] = 0;
10232 return(buf);
10233}

Referenced by xmlParseVersionInfo().

◆ xmlParseXMLDecl()

XMLPUBFUN void XMLCALL xmlParseXMLDecl ( xmlParserCtxtPtr  ctxt)

xmlParseXMLDecl: @ctxt: an XML parser context

parse an XML declaration header

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

Definition at line 10552 of file parser.c.

10552 {
10554
10555 /*
10556 * This value for standalone indicates that the document has an
10557 * XML declaration but it does not have a standalone attribute.
10558 * It will be overwritten later if a standalone attribute is found.
10559 */
10560 ctxt->input->standalone = -2;
10561
10562 /*
10563 * We know that '<?xml' is here.
10564 */
10565 SKIP(5);
10566
10567 if (!IS_BLANK_CH(RAW)) {
10568 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
10569 "Blank needed after '<?xml'\n");
10570 }
10572
10573 /*
10574 * We must have the VersionInfo here.
10575 */
10577 if (version == NULL) {
10579 } else {
10581 /*
10582 * Changed here for XML-1.0 5th edition
10583 */
10584 if (ctxt->options & XML_PARSE_OLD10) {
10585 xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
10586 "Unsupported version '%s'\n",
10587 version);
10588 } else {
10589 if ((version[0] == '1') && ((version[1] == '.'))) {
10590 xmlWarningMsg(ctxt, XML_WAR_UNKNOWN_VERSION,
10591 "Unsupported version '%s'\n",
10592 version, NULL);
10593 } else {
10594 xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
10595 "Unsupported version '%s'\n",
10596 version);
10597 }
10598 }
10599 }
10600 if (ctxt->version != NULL)
10601 xmlFree((void *) ctxt->version);
10602 ctxt->version = version;
10603 }
10604
10605 /*
10606 * We may have the encoding declaration
10607 */
10608 if (!IS_BLANK_CH(RAW)) {
10609 if ((RAW == '?') && (NXT(1) == '>')) {
10610 SKIP(2);
10611 return;
10612 }
10613 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
10614 }
10616 if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
10617 (ctxt->instate == XML_PARSER_EOF)) {
10618 /*
10619 * The XML REC instructs us to stop parsing right here
10620 */
10621 return;
10622 }
10623
10624 /*
10625 * We may have the standalone status.
10626 */
10627 if ((ctxt->input->encoding != NULL) && (!IS_BLANK_CH(RAW))) {
10628 if ((RAW == '?') && (NXT(1) == '>')) {
10629 SKIP(2);
10630 return;
10631 }
10632 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
10633 }
10634
10635 /*
10636 * We can grow the input buffer freely at that point
10637 */
10638 GROW;
10639
10641 ctxt->input->standalone = xmlParseSDDecl(ctxt);
10642
10644 if ((RAW == '?') && (NXT(1) == '>')) {
10645 SKIP(2);
10646 } else if (RAW == '>') {
10647 /* Deprecated old WD ... */
10649 NEXT;
10650 } else {
10653 NEXT;
10654 }
10655}
@ XML_PARSE_OLD10
Definition: parser.h:1112
int xmlParseSDDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10490
const xmlChar * version
Definition: parser.h:190
int standalone
Definition: parser.h:73
@ 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 XMLCALL 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 2265 of file parser.c.

2265 {
2266 if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
2269 "Popping input %d\n", ctxt->inputNr);
2270 if ((ctxt->inputNr > 1) && (ctxt->inSubset == 0) &&
2271 (ctxt->instate != XML_PARSER_EOF))
2273 "Unfinished entity outside the DTD");
2275 if (*ctxt->input->cur == 0)
2277 return(CUR);
2278}
XMLPUBFUN int XMLCALL xmlParserInputGrow(xmlParserInputPtr in, int len)
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1774

Referenced by xmlLoadEntityContent(), xmlParseInternalSubset(), xmlSAX2ExternalSubset(), and xmlSkipBlankChars().

◆ xmlPushInput()

XMLPUBFUN int XMLCALL 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 2290 of file parser.c.

2290 {
2291 int ret;
2292 if (input == NULL) return(-1);
2293
2295 if ((ctxt->input != NULL) && (ctxt->input->filename))
2297 "%s(%d): ", ctxt->input->filename,
2298 ctxt->input->line);
2300 "Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
2301 }
2302 if (((ctxt->inputNr > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
2303 (ctxt->inputNr > 1024)) {
2305 while (ctxt->inputNr > 1)
2307 return(-1);
2308 }
2309 ret = inputPush(ctxt, input);
2310 if (ctxt->instate == XML_PARSER_EOF)
2311 return(-1);
2312 GROW;
2313 return(ret);
2314}

Referenced by xmlLoadEntityContent(), xmlParsePEReference(), and xmlSAX2ExternalSubset().

◆ xmlSkipBlankChars()

XMLPUBFUN int XMLCALL xmlSkipBlankChars ( xmlParserCtxtPtr  ctxt)

xmlSkipBlankChars: @ctxt: the XML parser context

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 2184 of file parser.c.

2184 {
2185 int res = 0;
2186
2187 /*
2188 * It's Okay to use CUR/NEXT here since all the blanks are on
2189 * the ASCII range.
2190 */
2191 if (((ctxt->inputNr == 1) && (ctxt->instate != XML_PARSER_DTD)) ||
2192 (ctxt->instate == XML_PARSER_START)) {
2193 const xmlChar *cur;
2194 /*
2195 * if we are in the document content, go really fast
2196 */
2197 cur = ctxt->input->cur;
2198 while (IS_BLANK_CH(*cur)) {
2199 if (*cur == '\n') {
2200 ctxt->input->line++; ctxt->input->col = 1;
2201 } else {
2202 ctxt->input->col++;
2203 }
2204 cur++;
2205 if (res < INT_MAX)
2206 res++;
2207 if (*cur == 0) {
2208 ctxt->input->cur = cur;
2210 cur = ctxt->input->cur;
2211 }
2212 }
2213 ctxt->input->cur = cur;
2214 } else {
2215 int expandPE = ((ctxt->external != 0) || (ctxt->inputNr != 1));
2216
2217 while (1) {
2218 if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */
2219 NEXT;
2220 } else if (CUR == '%') {
2221 /*
2222 * Need to handle support of entities branching here
2223 */
2224 if ((expandPE == 0) || (IS_BLANK_CH(NXT(1))) || (NXT(1) == 0))
2225 break;
2226 xmlParsePEReference(ctxt);
2227 } else if (CUR == 0) {
2228 if (ctxt->inputNr <= 1)
2229 break;
2230 xmlPopInput(ctxt);
2231 } else {
2232 break;
2233 }
2234
2235 /*
2236 * Also increase the counter when entering or exiting a PERef.
2237 * The spec says: "When a parameter-entity reference is recognized
2238 * in the DTD and included, its replacement text MUST be enlarged
2239 * by the attachment of one leading and one following space (#x20)
2240 * character."
2241 */
2242 if (res < INT_MAX)
2243 res++;
2244 }
2245 }
2246 return(res);
2247}
xmlChar xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2265

◆ xmlSplitQName()

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

Namespaces.

Definition at line 2946 of file parser.c.

2946 {
2948 xmlChar *buffer = NULL;
2949 int len = 0;
2950 int max = XML_MAX_NAMELEN;
2951 xmlChar *ret = NULL;
2952 const xmlChar *cur = name;
2953 int c;
2954
2955 if (prefix == NULL) return(NULL);
2956 *prefix = NULL;
2957
2958 if (cur == NULL) return(NULL);
2959
2960#ifndef XML_XML_NAMESPACE
2961 /* xml: prefix is not really a namespace */
2962 if ((cur[0] == 'x') && (cur[1] == 'm') &&
2963 (cur[2] == 'l') && (cur[3] == ':'))
2964 return(xmlStrdup(name));
2965#endif
2966
2967 /* nasty but well=formed */
2968 if (cur[0] == ':')
2969 return(xmlStrdup(name));
2970
2971 c = *cur++;
2972 while ((c != 0) && (c != ':') && (len < max)) { /* tested bigname.xml */
2973 buf[len++] = c;
2974 c = *cur++;
2975 }
2976 if (len >= max) {
2977 /*
2978 * Okay someone managed to make a huge name, so he's ready to pay
2979 * for the processing speed.
2980 */
2981 max = len * 2;
2982
2983 buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
2984 if (buffer == NULL) {
2985 xmlErrMemory(ctxt, NULL);
2986 return(NULL);
2987 }
2988 memcpy(buffer, buf, len);
2989 while ((c != 0) && (c != ':')) { /* tested bigname.xml */
2990 if (len + 10 > max) {
2991 xmlChar *tmp;
2992
2993 max *= 2;
2994 tmp = (xmlChar *) xmlRealloc(buffer,
2995 max * sizeof(xmlChar));
2996 if (tmp == NULL) {
2997 xmlFree(buffer);
2998 xmlErrMemory(ctxt, NULL);
2999 return(NULL);
3000 }
3001 buffer = tmp;
3002 }
3003 buffer[len++] = c;
3004 c = *cur++;
3005 }
3006 buffer[len] = 0;
3007 }
3008
3009 if ((c == ':') && (*cur == 0)) {
3010 if (buffer != NULL)
3011 xmlFree(buffer);
3012 *prefix = NULL;
3013 return(xmlStrdup(name));
3014 }
3015
3016 if (buffer == NULL)
3017 ret = xmlStrndup(buf, len);
3018 else {
3019 ret = buffer;
3020 buffer = NULL;
3022 }
3023
3024
3025 if (c == ':') {
3026 c = *cur;
3027 *prefix = ret;
3028 if (c == 0) {
3029 return(xmlStrndup(BAD_CAST "", 0));
3030 }
3031 len = 0;
3032
3033 /*
3034 * Check that the first character is proper to start
3035 * a new name
3036 */
3037 if (!(((c >= 0x61) && (c <= 0x7A)) ||
3038 ((c >= 0x41) && (c <= 0x5A)) ||
3039 (c == '_') || (c == ':'))) {
3040 int l;
3041 int first = CUR_SCHAR(cur, l);
3042
3043 if (!IS_LETTER(first) && (first != '_')) {
3044 xmlFatalErrMsgStr(ctxt, XML_NS_ERR_QNAME,
3045 "Name %s is not XML Namespace compliant\n",
3046 name);
3047 }
3048 }
3049 cur++;
3050
3051 while ((c != 0) && (len < max)) { /* tested bigname2.xml */
3052 buf[len++] = c;
3053 c = *cur++;
3054 }
3055 if (len >= max) {
3056 /*
3057 * Okay someone managed to make a huge name, so he's ready to pay
3058 * for the processing speed.
3059 */
3060 max = len * 2;
3061
3062 buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
3063 if (buffer == NULL) {
3064 xmlErrMemory(ctxt, NULL);
3065 return(NULL);
3066 }
3067 memcpy(buffer, buf, len);
3068 while (c != 0) { /* tested bigname2.xml */
3069 if (len + 10 > max) {
3070 xmlChar *tmp;
3071
3072 max *= 2;
3073 tmp = (xmlChar *) xmlRealloc(buffer,
3074 max * sizeof(xmlChar));
3075 if (tmp == NULL) {
3076 xmlErrMemory(ctxt, NULL);
3077 xmlFree(buffer);
3078 return(NULL);
3079 }
3080 buffer = tmp;
3081 }
3082 buffer[len++] = c;
3083 c = *cur++;
3084 }
3085 buffer[len] = 0;
3086 }
3087
3088 if (buffer == NULL)
3089 ret = xmlStrndup(buf, len);
3090 else {
3091 ret = buffer;
3092 }
3093 }
3094
3095 return(ret);
3096}
const GLint * first
Definition: glext.h:5794
#define IS_LETTER(c)
#define CUR_SCHAR(s, l)
Definition: parser.c:2164
@ XML_NS_ERR_QNAME
Definition: xmlerror.h:215

Referenced by xmlSAX2AttributeDecl().

◆ xmlStringCurrentChar()

XMLPUBFUN int XMLCALL xmlStringCurrentChar ( xmlParserCtxtPtr  ctxt,
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

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 700 of file parserInternals.c.

701{
702 if ((len == NULL) || (cur == NULL)) return(0);
703 if ((ctxt == NULL) || (ctxt->charset == XML_CHAR_ENCODING_UTF8)) {
704 /*
705 * We are supposed to handle UTF8, check it's valid
706 * From rfc2044: encoding of the Unicode values on UTF-8:
707 *
708 * UCS-4 range (hex.) UTF-8 octet sequence (binary)
709 * 0000 0000-0000 007F 0xxxxxxx
710 * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
711 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
712 *
713 * Check for the 0x110000 limit too
714 */
715 unsigned char c;
716 unsigned int val;
717
718 c = *cur;
719 if (c & 0x80) {
720 if ((cur[1] & 0xc0) != 0x80)
721 goto encoding_error;
722 if ((c & 0xe0) == 0xe0) {
723
724 if ((cur[2] & 0xc0) != 0x80)
725 goto encoding_error;
726 if ((c & 0xf0) == 0xf0) {
727 if (((c & 0xf8) != 0xf0) || ((cur[3] & 0xc0) != 0x80))
728 goto encoding_error;
729 /* 4-byte code */
730 *len = 4;
731 val = (cur[0] & 0x7) << 18;
732 val |= (cur[1] & 0x3f) << 12;
733 val |= (cur[2] & 0x3f) << 6;
734 val |= cur[3] & 0x3f;
735 } else {
736 /* 3-byte code */
737 *len = 3;
738 val = (cur[0] & 0xf) << 12;
739 val |= (cur[1] & 0x3f) << 6;
740 val |= cur[2] & 0x3f;
741 }
742 } else {
743 /* 2-byte code */
744 *len = 2;
745 val = (cur[0] & 0x1f) << 6;
746 val |= cur[1] & 0x3f;
747 }
748 if (!IS_CHAR(val)) {
749 xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
750 "Char 0x%X out of allowed range\n", val);
751 }
752 return (val);
753 } else {
754 /* 1-byte code */
755 *len = 1;
756 return ((int) *cur);
757 }
758 }
759 /*
760 * Assume it's a fixed length encoding (1) with
761 * a compatible encoding for the ASCII set, since
762 * XML constructs only use < 128 chars
763 */
764 *len = 1;
765 return ((int) *cur);
766encoding_error:
767
768 /*
769 * An encoding problem may arise from a truncated input buffer
770 * splitting a character in the middle. In that case do not raise
771 * an error but return 0 to indicate an end of stream problem
772 */
773 if ((ctxt == NULL) || (ctxt->input == NULL) ||
774 (ctxt->input->end - ctxt->input->cur < 4)) {
775 *len = 0;
776 return(0);
777 }
778 /*
779 * If we detect an UTF8 error that probably mean that the
780 * input encoding didn't get properly advertised in the
781 * declaration header. Report the error and switch the encoding
782 * to ISO-Latin-1 (if you don't like this policy, just declare the
783 * encoding !)
784 */
785 {
786 char buffer[150];
787
788 snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
789 ctxt->input->cur[0], ctxt->input->cur[1],
790 ctxt->input->cur[2], ctxt->input->cur[3]);
792 "Input is not proper UTF-8, indicate encoding !\n%s",
794 }
795 *len = 1;
796 return ((int) *cur);
797}

Referenced by xsltNumberFormatTokenize(), xsltScanLiteral(), and xsltScanNCName().

◆ xmlStringDecodeEntities()

XMLPUBFUN xmlChar *XMLCALL 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

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 2839 of file parser.c.

2840 {
2841 if ((ctxt == NULL) || (str == NULL)) return(NULL);
2842 return(xmlStringLenDecodeEntities(ctxt, str, xmlStrlen(str), what,
2843 end, end2, end3));
2844}
GLuint GLuint end
Definition: gl.h:1545
const WCHAR * str
xmlChar * xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
Definition: parser.c:2643

Referenced by xmlParseAttValueComplex(), xmlParseEntityValue(), xmlParserEntityCheck(), and xmlStringLenDecodeEntities().

◆ xmlStringLenDecodeEntities()

XMLPUBFUN xmlChar *XMLCALL 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

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 2643 of file parser.c.

2644 {
2645 xmlChar *buffer = NULL;
2646 size_t buffer_size = 0;
2647 size_t nbchars = 0;
2648
2649 xmlChar *current = NULL;
2650 xmlChar *rep = NULL;
2651 const xmlChar *last;
2652 xmlEntityPtr ent;
2653 int c,l;
2654
2655 if ((ctxt == NULL) || (str == NULL) || (len < 0))
2656 return(NULL);
2657 last = str + len;
2658
2659 if (((ctxt->depth > 40) &&
2660 ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
2661 (ctxt->depth > 1024)) {
2663 return(NULL);
2664 }
2665
2666 /*
2667 * allocate a translation buffer.
2668 */
2671 if (buffer == NULL) goto mem_error;
2672
2673 /*
2674 * OK loop until we reach one of the ending char or a size limit.
2675 * we are operating on already parsed values.
2676 */
2677 if (str < last)
2678 c = CUR_SCHAR(str, l);
2679 else
2680 c = 0;
2681 while ((c != 0) && (c != end) && /* non input consuming loop */
2682 (c != end2) && (c != end3) &&
2683 (ctxt->instate != XML_PARSER_EOF)) {
2684
2685 if (c == 0) break;
2686 if ((c == '&') && (str[1] == '#')) {
2687 int val = xmlParseStringCharRef(ctxt, &str);
2688 if (val == 0)
2689 goto int_error;
2690 COPY_BUF(0,buffer,nbchars,val);
2691 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
2693 }
2694 } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
2697 "String decoding Entity Reference: %.30s\n",
2698 str);
2699 ent = xmlParseStringEntityRef(ctxt, &str);
2700 xmlParserEntityCheck(ctxt, 0, ent, 0);
2701 if (ent != NULL)
2702 ctxt->nbentities += ent->checked / 2;
2703 if ((ent != NULL) &&
2705 if (ent->content != NULL) {
2706 COPY_BUF(0,buffer,nbchars,ent->content[0]);
2707 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
2709 }
2710 } else {
2711 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
2712 "predefined entity has no content\n");
2713 goto int_error;
2714 }
2715 } else if ((ent != NULL) && (ent->content != NULL)) {
2716 ctxt->depth++;
2717 rep = xmlStringDecodeEntities(ctxt, ent->content, what,
2718 0, 0, 0);
2719 ctxt->depth--;
2720 if (rep == NULL) {
2721 ent->content[0] = 0;
2722 goto int_error;
2723 }
2724
2725 current = rep;
2726 while (*current != 0) { /* non input consuming loop */
2727 buffer[nbchars++] = *current++;
2728 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
2729 if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
2730 goto int_error;
2732 }
2733 }
2734 xmlFree(rep);
2735 rep = NULL;
2736 } else if (ent != NULL) {
2737 int i = xmlStrlen(ent->name);
2738 const xmlChar *cur = ent->name;
2739
2740 buffer[nbchars++] = '&';
2741 if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) {
2743 }
2744 for (;i > 0;i--)
2745 buffer[nbchars++] = *cur++;
2746 buffer[nbchars++] = ';';
2747 }
2748 } else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) {
2751 "String decoding PE Reference: %.30s\n", str);
2752 ent = xmlParseStringPEReference(ctxt, &str);
2753 xmlParserEntityCheck(ctxt, 0, ent, 0);
2754 if (ent != NULL)
2755 ctxt->nbentities += ent->checked / 2;
2756 if (ent != NULL) {
2757 if (ent->content == NULL) {
2758 /*
2759 * Note: external parsed entities will not be loaded,
2760 * it is not required for a non-validating parser to
2761 * complete external PEReferences coming from the
2762 * internal subset
2763 */
2764 if (((ctxt->options & XML_PARSE_NOENT) != 0) ||
2765 ((ctxt->options & XML_PARSE_DTDVALID) != 0) ||
2766 (ctxt->validate != 0)) {
2767 xmlLoadEntityContent(ctxt, ent);
2768 } else {
2769 xmlWarningMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
2770 "not validating will not read content for PE entity %s\n",
2771 ent->name, NULL);
2772 }
2773 }
2774 ctxt->depth++;
2775 rep = xmlStringDecodeEntities(ctxt, ent->content, what,
2776 0, 0, 0);
2777 ctxt->depth--;
2778 if (rep == NULL) {
2779 if (ent->content != NULL)
2780 ent->content[0] = 0;
2781 goto int_error;
2782 }
2783 current = rep;
2784 while (*current != 0) { /* non input consuming loop */
2785 buffer[nbchars++] = *current++;
2786 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
2787 if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
2788 goto int_error;
2790 }
2791 }
2792 xmlFree(rep);
2793 rep = NULL;
2794 }
2795 } else {
2796 COPY_BUF(l,buffer,nbchars,c);
2797 str += l;
2798 if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
2800 }
2801 }
2802 if (str < last)
2803 c = CUR_SCHAR(str, l);
2804 else
2805 c = 0;
2806 }
2807 buffer[nbchars] = 0;
2808 return(buffer);
2809
2810mem_error:
2811 xmlErrMemory(ctxt, NULL);
2812int_error:
2813 if (rep != NULL)
2814 xmlFree(rep);
2815 if (buffer != NULL)
2816 xmlFree(buffer);
2817 return(NULL);
2818}
struct task_struct * current
Definition: linux.c:32
#define XML_SUBSTITUTE_REF
#define XML_PARSER_BIG_BUFFER_SIZE
Definition: parser.c:275
#define growBuffer(buffer, n)
Definition: parser.c:2613
static int xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:2442
static int xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
Definition: parser.c:8060
static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:7718
static xmlEntityPtr xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str)
Definition: parser.c:8179
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
@ XML_ERR_ENTITY_PROCESSING
Definition: xmlerror.h:204

Referenced by xmlStringDecodeEntities().

◆ xmlSwitchEncoding()

XMLPUBFUN int XMLCALL xmlSwitchEncoding ( xmlParserCtxtPtr  ctxt,
xmlCharEncoding  enc 
)

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

change the input functions when discovering the character encoding of a given entity.

Returns 0 in case of success, -1 otherwise

Definition at line 882 of file parserInternals.c.

883{
885 int len = -1;
886 int ret;
887
888 if (ctxt == NULL) return(-1);
889 switch (enc) {
892 "encoding unknown\n", NULL, NULL);
893 return(-1);
895 /* let's assume it's UTF-8 without the XML decl */
897 return(0);
899 /* default encoding, no conversion should be needed */
901
902 /*
903 * Errata on XML-1.0 June 20 2001
904 * Specific handling of the Byte Order Mark for
905 * UTF-8
906 */
907 if ((ctxt->input != NULL) &&
908 (ctxt->input->cur[0] == 0xEF) &&
909 (ctxt->input->cur[1] == 0xBB) &&
910 (ctxt->input->cur[2] == 0xBF)) {
911 ctxt->input->cur += 3;
912 }
913 return(0);
916 /*The raw input characters are encoded
917 *in UTF-16. As we expect this function
918 *to be called after xmlCharEncInFunc, we expect
919 *ctxt->input->cur to contain UTF-8 encoded characters.
920 *So the raw UTF16 Byte Order Mark
921 *has also been converted into
922 *an UTF-8 BOM. Let's skip that BOM.
923 */
924 if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) &&
925 (ctxt->input->cur[0] == 0xEF) &&
926 (ctxt->input->cur[1] == 0xBB) &&
927 (ctxt->input->cur[2] == 0xBF)) {
928 ctxt->input->cur += 3;
929 }
930 len = 90;
931 break;
933 len = 90;
934 break;
939 len = 180;
940 break;
955 len = 45;
956 break;
957 }
959 if (handler == NULL) {
960 /*
961 * Default handlers.
962 */
963 switch (enc) {
965 /* default encoding, no conversion should be needed */
967 return(0);
969 if ((ctxt->inputNr == 1) &&
970 (ctxt->encoding == NULL) &&
971 (ctxt->input != NULL) &&
972 (ctxt->input->encoding != NULL)) {
973 ctxt->encoding = xmlStrdup(ctxt->input->encoding);
974 }
975 ctxt->charset = enc;
976 return(0);
977 default:
979 "encoding not supported: %s\n",
981 /*
982 * TODO: We could recover from errors in external entities
983 * if we didn't stop the parser. But most callers of this
984 * function don't check the return value.
985 */
986 xmlStopParser(ctxt);
987 return(-1);
988 }
989 }
991 if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
992 /*
993 * on encoding conversion errors, stop the parser
994 */
995 xmlStopParser(ctxt);
997 }
998 return(ret);
999}
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlGetCharEncodingHandler(xmlCharEncoding enc)
Definition: encoding.c:1544
@ XML_CHAR_ENCODING_8859_6
Definition: encoding.h:73
@ XML_CHAR_ENCODING_8859_7
Definition: encoding.h:74
@ XML_CHAR_ENCODING_8859_2
Definition: encoding.h:69
@ XML_CHAR_ENCODING_8859_4
Definition: encoding.h:71
@ XML_CHAR_ENCODING_8859_8
Definition: encoding.h:75
@ XML_CHAR_ENCODING_UTF16BE
Definition: encoding.h:61
@ XML_CHAR_ENCODING_UCS2
Definition: encoding.h:67
@ XML_CHAR_ENCODING_2022_JP
Definition: encoding.h:77
@ XML_CHAR_ENCODING_8859_3
Definition: encoding.h:70
@ XML_CHAR_ENCODING_EBCDIC
Definition: encoding.h:64
@ XML_CHAR_ENCODING_UCS4LE
Definition: encoding.h:62
@ XML_CHAR_ENCODING_ERROR
Definition: encoding.h:57
@ XML_CHAR_ENCODING_UCS4_3412
Definition: encoding.h:66
@ XML_CHAR_ENCODING_UCS4BE
Definition: encoding.h:63
@ XML_CHAR_ENCODING_8859_9
Definition: encoding.h:76
@ XML_CHAR_ENCODING_UTF16LE
Definition: encoding.h:60
@ XML_CHAR_ENCODING_8859_5
Definition: encoding.h:72
@ XML_CHAR_ENCODING_ASCII
Definition: encoding.h:80
@ XML_CHAR_ENCODING_SHIFT_JIS
Definition: encoding.h:78
@ XML_CHAR_ENCODING_UCS4_2143
Definition: encoding.h:65
@ XML_CHAR_ENCODING_EUC_JP
Definition: encoding.h:79
XMLPUBFUN const char *XMLCALL xmlGetCharEncodingName(xmlCharEncoding enc)
Definition: encoding.c:1254
static int xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler, int len)
@ XML_I18N_CONV_FAILED
Definition: xmlerror.h:833
@ XML_ERR_UNKNOWN_ENCODING
Definition: xmlerror.h:131

Referenced by xmlCtxtResetPush(), xmlNewIOInputStream(), xmlParseDocument(), xmlParseExternalEntityPrivate(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), xmlParsePEReference(), and xmlSAX2ExternalSubset().

◆ xmlSwitchInputEncoding()

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

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

DEPRECATED: Use xmlSwitchToEncoding

change the input functions when discovering the character encoding of a given entity.

Returns 0 in case of success, -1 otherwise

Definition at line 1156 of file parserInternals.c.

1157 {
1158 return(xmlSwitchInputEncodingInt(ctxt, input, handler, -1));
1159}

◆ xmlSwitchToEncoding()

XMLPUBFUN int XMLCALL xmlSwitchToEncoding ( xmlParserCtxtPtr  ctxt,
xmlCharEncodingHandlerPtr  handler 
)

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

change the input functions when discovering the character encoding of a given entity.

Returns 0 in case of success, -1 otherwise

Definition at line 1172 of file parserInternals.c.

1173{
1174 if (ctxt == NULL)
1175 return(-1);
1176 return(xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, -1));
1177}

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

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 31 of file parserInternals.h.

◆ xmlStringComment

XMLPUBVAR const xmlChar xmlStringComment[]

Definition at line 314 of file parserInternals.h.

◆ xmlStringText

XMLPUBVAR const xmlChar xmlStringText[]

Global variables used for predefined strings.

Definition at line 312 of file parserInternals.h.

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

◆ xmlStringTextNoenc