| 4265 | } |
| 4266 | |
| 4267 | static enum XML_Error |
| 4268 | processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s, |
| 4269 | const char *next) { |
| 4270 | const char *encodingName = NULL; |
| 4271 | const XML_Char *storedEncName = NULL; |
| 4272 | const ENCODING *newEncoding = NULL; |
| 4273 | const char *version = NULL; |
| 4274 | const char *versionend = NULL; |
| 4275 | const XML_Char *storedversion = NULL; |
| 4276 | int standalone = -1; |
| 4277 | |
| 4278 | #ifdef XML_DTD |
| 4279 | if (! accountingDiffTolerated(parser, XML_TOK_XML_DECL, s, next, __LINE__, |
| 4280 | XML_ACCOUNT_DIRECT)) { |
| 4281 | accountingOnAbort(parser); |
| 4282 | return XML_ERROR_AMPLIFICATION_LIMIT_BREACH; |
| 4283 | } |
| 4284 | #endif |
| 4285 | |
| 4286 | if (! (parser->m_ns ? XmlParseXmlDeclNS : XmlParseXmlDecl)( |
| 4287 | isGeneralTextEntity, parser->m_encoding, s, next, &parser->m_eventPtr, |
| 4288 | &version, &versionend, &encodingName, &newEncoding, &standalone)) { |
| 4289 | if (isGeneralTextEntity) |
| 4290 | return XML_ERROR_TEXT_DECL; |
| 4291 | else |
| 4292 | return XML_ERROR_XML_DECL; |
| 4293 | } |
| 4294 | if (! isGeneralTextEntity && standalone == 1) { |
| 4295 | parser->m_dtd->standalone = XML_TRUE; |
| 4296 | #ifdef XML_DTD |
| 4297 | if (parser->m_paramEntityParsing |
| 4298 | == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) |
| 4299 | parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
| 4300 | #endif /* XML_DTD */ |
| 4301 | } |
| 4302 | if (parser->m_xmlDeclHandler) { |
| 4303 | if (encodingName != NULL) { |
| 4304 | storedEncName = poolStoreString( |
| 4305 | &parser->m_temp2Pool, parser->m_encoding, encodingName, |
| 4306 | encodingName + XmlNameLength(parser->m_encoding, encodingName)); |
| 4307 | if (! storedEncName) |
| 4308 | return XML_ERROR_NO_MEMORY; |
| 4309 | poolFinish(&parser->m_temp2Pool); |
| 4310 | } |
| 4311 | if (version) { |
| 4312 | storedversion |
| 4313 | = poolStoreString(&parser->m_temp2Pool, parser->m_encoding, version, |
| 4314 | versionend - parser->m_encoding->minBytesPerChar); |
| 4315 | if (! storedversion) |
| 4316 | return XML_ERROR_NO_MEMORY; |
| 4317 | } |
| 4318 | parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName, |
| 4319 | standalone); |
| 4320 | } else if (parser->m_defaultHandler) |
| 4321 | reportDefault(parser, parser->m_encoding, s, next); |
| 4322 | if (parser->m_protocolEncodingName == NULL) { |
| 4323 | if (newEncoding) { |
| 4324 | /* Check that the specified encoding does not conflict with what |
no test coverage detected