* 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 ( %
| 2678 | * processing is identical as other attributes |
| 2679 | */ |
| 2680 | static void |
| 2681 | htmlParseScript(htmlParserCtxtPtr ctxt) { |
| 2682 | xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5]; |
| 2683 | int nbchar = 0; |
| 2684 | int cur,l; |
| 2685 | |
| 2686 | SHRINK; |
| 2687 | cur = CUR_CHAR(l); |
| 2688 | while (IS_CHAR_CH(cur)) { |
| 2689 | if ((cur == '<') && (NXT(1) == '/')) { |
| 2690 | /* |
| 2691 | * One should break here, the specification is clear: |
| 2692 | * Authors should therefore escape "</" within the content. |
| 2693 | * Escape mechanisms are specific to each scripting or |
| 2694 | * style sheet language. |
| 2695 | * |
| 2696 | * In recovery mode, only break if end tag match the |
| 2697 | * current tag, effectively ignoring all tags inside the |
| 2698 | * script/style block and treating the entire block as |
| 2699 | * CDATA. |
| 2700 | */ |
| 2701 | if (ctxt->recovery) { |
| 2702 | if (xmlStrncasecmp(ctxt->name, ctxt->input->cur+2, |
| 2703 | xmlStrlen(ctxt->name)) == 0) |
| 2704 | { |
| 2705 | break; /* while */ |
| 2706 | } else { |
| 2707 | htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH, |
| 2708 | "Element %s embeds close tag\n", |
| 2709 | ctxt->name, NULL); |
| 2710 | } |
| 2711 | } else { |
| 2712 | if (((NXT(2) >= 'A') && (NXT(2) <= 'Z')) || |
| 2713 | ((NXT(2) >= 'a') && (NXT(2) <= 'z'))) |
| 2714 | { |
| 2715 | break; /* while */ |
| 2716 | } |
| 2717 | } |
| 2718 | } |
| 2719 | COPY_BUF(l,buf,nbchar,cur); |
| 2720 | if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) { |
| 2721 | if (ctxt->sax->cdataBlock!= NULL) { |
| 2722 | /* |
| 2723 | * Insert as CDATA, which is the same as HTML_PRESERVE_NODE |
| 2724 | */ |
| 2725 | ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar); |
| 2726 | } else if (ctxt->sax->characters != NULL) { |
| 2727 | ctxt->sax->characters(ctxt->userData, buf, nbchar); |
| 2728 | } |
| 2729 | nbchar = 0; |
| 2730 | } |
| 2731 | GROW; |
| 2732 | NEXTL(l); |
| 2733 | cur = CUR_CHAR(l); |
| 2734 | } |
| 2735 | |
| 2736 | if ((!(IS_CHAR_CH(cur))) && (!((cur == 0) && (ctxt->progressive)))) { |
| 2737 | htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, |
no test coverage detected