| 5008 | } |
| 5009 | |
| 5010 | static enum XML_Error PTRCALL |
| 5011 | entityValueInitProcessor(XML_Parser parser, const char *s, const char *end, |
| 5012 | const char **nextPtr) { |
| 5013 | int tok; |
| 5014 | const char *start = s; |
| 5015 | const char *next = start; |
| 5016 | parser->m_eventPtr = start; |
| 5017 | |
| 5018 | for (;;) { |
| 5019 | tok = XmlPrologTok(parser->m_encoding, start, end, &next); |
| 5020 | /* Note: Except for XML_TOK_BOM below, these bytes are accounted later in: |
| 5021 | - storeEntityValue |
| 5022 | - processXmlDecl |
| 5023 | */ |
| 5024 | parser->m_eventEndPtr = next; |
| 5025 | if (tok <= 0) { |
| 5026 | if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { |
| 5027 | *nextPtr = s; |
| 5028 | return XML_ERROR_NONE; |
| 5029 | } |
| 5030 | switch (tok) { |
| 5031 | case XML_TOK_INVALID: |
| 5032 | return XML_ERROR_INVALID_TOKEN; |
| 5033 | case XML_TOK_PARTIAL: |
| 5034 | return XML_ERROR_UNCLOSED_TOKEN; |
| 5035 | case XML_TOK_PARTIAL_CHAR: |
| 5036 | return XML_ERROR_PARTIAL_CHAR; |
| 5037 | case XML_TOK_NONE: /* start == end */ |
| 5038 | default: |
| 5039 | break; |
| 5040 | } |
| 5041 | /* found end of entity value - can store it now */ |
| 5042 | return storeEntityValue(parser, parser->m_encoding, s, end, |
| 5043 | XML_ACCOUNT_DIRECT, NULL); |
| 5044 | } else if (tok == XML_TOK_XML_DECL) { |
| 5045 | enum XML_Error result; |
| 5046 | result = processXmlDecl(parser, 0, start, next); |
| 5047 | if (result != XML_ERROR_NONE) |
| 5048 | return result; |
| 5049 | /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For |
| 5050 | * that to happen, a parameter entity parsing handler must have attempted |
| 5051 | * to suspend the parser, which fails and raises an error. The parser can |
| 5052 | * be aborted, but can't be suspended. |
| 5053 | */ |
| 5054 | if (parser->m_parsingStatus.parsing == XML_FINISHED) |
| 5055 | return XML_ERROR_ABORTED; |
| 5056 | *nextPtr = next; |
| 5057 | /* stop scanning for text declaration - we found one */ |
| 5058 | parser->m_processor = entityValueProcessor; |
| 5059 | return entityValueProcessor(parser, next, end, nextPtr); |
| 5060 | } |
| 5061 | /* XmlPrologTok has now set the encoding based on the BOM it found, and we |
| 5062 | must move s and nextPtr forward to consume the BOM. |
| 5063 | |
| 5064 | If we didn't, and got XML_TOK_NONE from the next XmlPrologTok call, we |
| 5065 | would leave the BOM in the buffer and return. On the next call to this |
| 5066 | function, our XmlPrologTok call would return XML_TOK_INVALID, since it |
| 5067 | is not valid to have multiple BOMs. |
no test coverage detected
searching dependent graphs…