* htmlParseScript: * @ctxt: an HTML parser context * * parse the content of an HTML SCRIPT or STYLE element * http://www.w3.org/TR/html4/sgml/dtd.html#Script * http://www.w3.org/TR/html4/sgml/dtd.html#StyleSheet * http://www.w3.org/TR/html4/types.html#type-script * http://www.w3.org/TR/html4/types.html#h-6.15 * http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2.1 * * Script data ( %
| 3001 | * processing is identical as other attributes |
| 3002 | */ |
| 3003 | static void |
| 3004 | htmlParseScript(htmlParserCtxtPtr ctxt) { |
| 3005 | xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5]; |
| 3006 | int nbchar = 0; |
| 3007 | int cur,l; |
| 3008 | |
| 3009 | cur = CUR_CHAR(l); |
| 3010 | while (cur != 0) { |
| 3011 | if ((cur == '<') && (NXT(1) == '/')) { |
| 3012 | /* |
| 3013 | * One should break here, the specification is clear: |
| 3014 | * Authors should therefore escape "</" within the content. |
| 3015 | * Escape mechanisms are specific to each scripting or |
| 3016 | * style sheet language. |
| 3017 | * |
| 3018 | * In recovery mode, only break if end tag match the |
| 3019 | * current tag, effectively ignoring all tags inside the |
| 3020 | * script/style block and treating the entire block as |
| 3021 | * CDATA. |
| 3022 | */ |
| 3023 | if (ctxt->recovery) { |
| 3024 | if (xmlStrncasecmp(ctxt->name, ctxt->input->cur+2, |
| 3025 | xmlStrlen(ctxt->name)) == 0) |
| 3026 | { |
| 3027 | break; /* while */ |
| 3028 | } else { |
| 3029 | htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH, |
| 3030 | "Element %s embeds close tag\n", |
| 3031 | ctxt->name, NULL); |
| 3032 | } |
| 3033 | } else { |
| 3034 | if (((NXT(2) >= 'A') && (NXT(2) <= 'Z')) || |
| 3035 | ((NXT(2) >= 'a') && (NXT(2) <= 'z'))) |
| 3036 | { |
| 3037 | break; /* while */ |
| 3038 | } |
| 3039 | } |
| 3040 | } |
| 3041 | if (IS_CHAR(cur)) { |
| 3042 | COPY_BUF(l,buf,nbchar,cur); |
| 3043 | } else { |
| 3044 | htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, |
| 3045 | "Invalid char in CDATA 0x%X\n", cur); |
| 3046 | } |
| 3047 | NEXTL(l); |
| 3048 | if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) { |
| 3049 | buf[nbchar] = 0; |
| 3050 | if (ctxt->sax->cdataBlock!= NULL) { |
| 3051 | /* |
| 3052 | * Insert as CDATA, which is the same as HTML_PRESERVE_NODE |
| 3053 | */ |
| 3054 | ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar); |
| 3055 | } else if (ctxt->sax->characters != NULL) { |
| 3056 | ctxt->sax->characters(ctxt->userData, buf, nbchar); |
| 3057 | } |
| 3058 | nbchar = 0; |
| 3059 | SHRINK; |
| 3060 | } |
no test coverage detected