| 10403 | */ |
| 10404 | |
| 10405 | void |
| 10406 | xmlParseXMLDecl(xmlParserCtxtPtr ctxt) { |
| 10407 | xmlChar *version; |
| 10408 | |
| 10409 | /* |
| 10410 | * This value for standalone indicates that the document has an |
| 10411 | * XML declaration but it does not have a standalone attribute. |
| 10412 | * It will be overwritten later if a standalone attribute is found. |
| 10413 | */ |
| 10414 | |
| 10415 | ctxt->standalone = -2; |
| 10416 | |
| 10417 | /* |
| 10418 | * We know that '<?xml' is here. |
| 10419 | */ |
| 10420 | SKIP(5); |
| 10421 | |
| 10422 | if (!IS_BLANK_CH(RAW)) { |
| 10423 | xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, |
| 10424 | "Blank needed after '<?xml'\n"); |
| 10425 | } |
| 10426 | SKIP_BLANKS; |
| 10427 | |
| 10428 | /* |
| 10429 | * We must have the VersionInfo here. |
| 10430 | */ |
| 10431 | version = xmlParseVersionInfo(ctxt); |
| 10432 | if (version == NULL) { |
| 10433 | xmlFatalErr(ctxt, XML_ERR_VERSION_MISSING, NULL); |
| 10434 | } else { |
| 10435 | if (!xmlStrEqual(version, (const xmlChar *) XML_DEFAULT_VERSION)) { |
| 10436 | /* |
| 10437 | * Changed here for XML-1.0 5th edition |
| 10438 | */ |
| 10439 | if (ctxt->options & XML_PARSE_OLD10) { |
| 10440 | xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION, |
| 10441 | "Unsupported version '%s'\n", |
| 10442 | version); |
| 10443 | } else { |
| 10444 | if ((version[0] == '1') && ((version[1] == '.'))) { |
| 10445 | xmlWarningMsg(ctxt, XML_WAR_UNKNOWN_VERSION, |
| 10446 | "Unsupported version '%s'\n", |
| 10447 | version, NULL); |
| 10448 | } else { |
| 10449 | xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION, |
| 10450 | "Unsupported version '%s'\n", |
| 10451 | version); |
| 10452 | } |
| 10453 | } |
| 10454 | } |
| 10455 | if (ctxt->version != NULL) |
| 10456 | xmlFree((void *) ctxt->version); |
| 10457 | ctxt->version = version; |
| 10458 | } |
| 10459 | |
| 10460 | /* |
| 10461 | * We may have the encoding declaration |
| 10462 | */ |
no test coverage detected