| 7552 | } |
| 7553 | |
| 7554 | static void |
| 7555 | xmlHandleUndeclaredEntity(xmlParserCtxtPtr ctxt, const xmlChar *name) { |
| 7556 | /* |
| 7557 | * [ WFC: Entity Declared ] |
| 7558 | * In a document without any DTD, a document with only an |
| 7559 | * internal DTD subset which contains no parameter entity |
| 7560 | * references, or a document with "standalone='yes'", the |
| 7561 | * Name given in the entity reference must match that in an |
| 7562 | * entity declaration, except that well-formed documents |
| 7563 | * need not declare any of the following entities: amp, lt, |
| 7564 | * gt, apos, quot. |
| 7565 | * The declaration of a parameter entity must precede any |
| 7566 | * reference to it. |
| 7567 | * Similarly, the declaration of a general entity must |
| 7568 | * precede any reference to it which appears in a default |
| 7569 | * value in an attribute-list declaration. Note that if |
| 7570 | * entities are declared in the external subset or in |
| 7571 | * external parameter entities, a non-validating processor |
| 7572 | * is not obligated to read and process their declarations; |
| 7573 | * for such documents, the rule that an entity must be |
| 7574 | * declared is a well-formedness constraint only if |
| 7575 | * standalone='yes'. |
| 7576 | */ |
| 7577 | if ((ctxt->standalone == 1) || |
| 7578 | ((ctxt->hasExternalSubset == 0) && |
| 7579 | (ctxt->hasPErefs == 0))) { |
| 7580 | xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, |
| 7581 | "Entity '%s' not defined\n", name); |
| 7582 | } else if (ctxt->validate) { |
| 7583 | /* |
| 7584 | * [ VC: Entity Declared ] |
| 7585 | * In a document with an external subset or external |
| 7586 | * parameter entities with "standalone='no'", ... |
| 7587 | * ... The declaration of a parameter entity must |
| 7588 | * precede any reference to it... |
| 7589 | */ |
| 7590 | xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, |
| 7591 | "Entity '%s' not defined\n", name, NULL); |
| 7592 | } else if ((ctxt->loadsubset) || |
| 7593 | ((ctxt->replaceEntities) && |
| 7594 | ((ctxt->options & XML_PARSE_NO_XXE) == 0))) { |
| 7595 | /* |
| 7596 | * Also raise a non-fatal error |
| 7597 | * |
| 7598 | * - if the external subset is loaded and all entity declarations |
| 7599 | * should be available, or |
| 7600 | * - entity substition was requested without restricting |
| 7601 | * external entity access. |
| 7602 | */ |
| 7603 | xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY, |
| 7604 | "Entity '%s' not defined\n", name); |
| 7605 | } else { |
| 7606 | xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, |
| 7607 | "Entity '%s' not defined\n", name, NULL); |
| 7608 | } |
| 7609 | |
| 7610 | ctxt->valid = 0; |
| 7611 | } |
no outgoing calls
no test coverage detected