* xmlParseStringPEReference: * @ctxt: an XML parser context * @str: a pointer to an index in the string * * parse PEReference declarations * * [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 onl
| 8064 | * str is updated to the current value of the index |
| 8065 | */ |
| 8066 | static xmlEntityPtr |
| 8067 | xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) { |
| 8068 | const xmlChar *ptr; |
| 8069 | xmlChar cur; |
| 8070 | xmlChar *name; |
| 8071 | xmlEntityPtr entity = NULL; |
| 8072 | |
| 8073 | if ((str == NULL) || (*str == NULL)) return(NULL); |
| 8074 | ptr = *str; |
| 8075 | cur = *ptr; |
| 8076 | if (cur != '%') |
| 8077 | return(NULL); |
| 8078 | ptr++; |
| 8079 | name = xmlParseStringName(ctxt, &ptr); |
| 8080 | if (name == NULL) { |
| 8081 | xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED, |
| 8082 | "xmlParseStringPEReference: no name\n"); |
| 8083 | *str = ptr; |
| 8084 | return(NULL); |
| 8085 | } |
| 8086 | cur = *ptr; |
| 8087 | if (cur != ';') { |
| 8088 | xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL); |
| 8089 | xmlFree(name); |
| 8090 | *str = ptr; |
| 8091 | return(NULL); |
| 8092 | } |
| 8093 | ptr++; |
| 8094 | |
| 8095 | /* Must be set before xmlHandleUndeclaredEntity */ |
| 8096 | ctxt->hasPErefs = 1; |
| 8097 | |
| 8098 | /* |
| 8099 | * Request the entity from SAX |
| 8100 | */ |
| 8101 | if ((ctxt->sax != NULL) && |
| 8102 | (ctxt->sax->getParameterEntity != NULL)) |
| 8103 | entity = ctxt->sax->getParameterEntity(ctxt->userData, name); |
| 8104 | |
| 8105 | if (entity == NULL) { |
| 8106 | xmlHandleUndeclaredEntity(ctxt, name); |
| 8107 | } else { |
| 8108 | /* |
| 8109 | * Internal checking in case the entity quest barfed |
| 8110 | */ |
| 8111 | if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) && |
| 8112 | (entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) { |
| 8113 | xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY, |
| 8114 | "%%%s; is not a parameter entity\n", |
| 8115 | name, NULL); |
| 8116 | } |
| 8117 | } |
| 8118 | |
| 8119 | xmlFree(name); |
| 8120 | *str = ptr; |
| 8121 | return(entity); |
| 8122 | } |
| 8123 |
no test coverage detected