* xmlParseEntityValue: * @ctxt: an XML parser context * @orig: if non-NULL store a copy of the original entity value * * DEPRECATED: Internal function, don't use. * * parse a value for ENTITY declarations * * [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | * "'" ([^%&'] | PEReference | Reference)* "'" * * Returns the EntityValue parsed with reference s
| 3894 | * Returns the EntityValue parsed with reference substituted or NULL |
| 3895 | */ |
| 3896 | xmlChar * |
| 3897 | xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { |
| 3898 | unsigned maxLength = (ctxt->options & XML_PARSE_HUGE) ? |
| 3899 | XML_MAX_HUGE_LENGTH : |
| 3900 | XML_MAX_TEXT_LENGTH; |
| 3901 | xmlSBuf buf; |
| 3902 | const xmlChar *start; |
| 3903 | int quote, length; |
| 3904 | |
| 3905 | xmlSBufInit(&buf, maxLength); |
| 3906 | |
| 3907 | GROW; |
| 3908 | |
| 3909 | quote = CUR; |
| 3910 | if ((quote != '"') && (quote != '\'')) { |
| 3911 | xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL); |
| 3912 | return(NULL); |
| 3913 | } |
| 3914 | CUR_PTR++; |
| 3915 | |
| 3916 | length = 0; |
| 3917 | |
| 3918 | /* |
| 3919 | * Copy raw content of the entity into a buffer |
| 3920 | */ |
| 3921 | while (1) { |
| 3922 | int c; |
| 3923 | |
| 3924 | if (PARSER_STOPPED(ctxt)) |
| 3925 | goto error; |
| 3926 | |
| 3927 | if (CUR_PTR >= ctxt->input->end) { |
| 3928 | xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_NOT_FINISHED, NULL); |
| 3929 | goto error; |
| 3930 | } |
| 3931 | |
| 3932 | c = CUR; |
| 3933 | |
| 3934 | if (c == 0) { |
| 3935 | xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR, |
| 3936 | "invalid character in entity value\n"); |
| 3937 | goto error; |
| 3938 | } |
| 3939 | if (c == quote) |
| 3940 | break; |
| 3941 | NEXTL(1); |
| 3942 | length += 1; |
| 3943 | |
| 3944 | /* |
| 3945 | * TODO: Check growth threshold |
| 3946 | */ |
| 3947 | if (ctxt->input->end - CUR_PTR < 10) |
| 3948 | GROW; |
| 3949 | } |
| 3950 | |
| 3951 | start = CUR_PTR - length; |
| 3952 | |
| 3953 | if (orig != NULL) { |
no test coverage detected