* htmlParseLookupCommentEnd: * @ctxt: an HTML parser context * * Try to find a comment end tag in the input stream * The search includes "-->" as well as WHATWG-recommended incorrectly-closed tags. * (See https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-closed-comment) * This function has a side effect of (possibly) incrementing ctxt->checkIndex * to avoid rescann
| 5195 | * Returns the index to the current parsing point if the full sequence is available, -1 otherwise. |
| 5196 | */ |
| 5197 | static int |
| 5198 | htmlParseLookupCommentEnd(htmlParserCtxtPtr ctxt) |
| 5199 | { |
| 5200 | int mark = 0; |
| 5201 | int offset; |
| 5202 | |
| 5203 | while (1) { |
| 5204 | mark = htmlParseLookupSequence(ctxt, '-', '-', 0, 0); |
| 5205 | if (mark < 0) |
| 5206 | break; |
| 5207 | if ((NXT(mark+2) == '>') || |
| 5208 | ((NXT(mark+2) == '!') && (NXT(mark+3) == '>'))) { |
| 5209 | ctxt->checkIndex = 0; |
| 5210 | break; |
| 5211 | } |
| 5212 | offset = (NXT(mark+2) == '!') ? 3 : 2; |
| 5213 | if (mark + offset >= ctxt->input->end - ctxt->input->cur) { |
| 5214 | ctxt->checkIndex = mark; |
| 5215 | return(-1); |
| 5216 | } |
| 5217 | ctxt->checkIndex = mark + 1; |
| 5218 | } |
| 5219 | return mark; |
| 5220 | } |
| 5221 | |
| 5222 | |
| 5223 | /** |
no test coverage detected