MCPcopy Create free account
hub / github.com/Kitware/VTK / htmlParseNameComplex

Function htmlParseNameComplex

ThirdParty/libxml2/vtklibxml2/HTMLparser.c:2560–2614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2558}
2559
2560static const xmlChar *
2561htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
2562 int len = 0, l;
2563 int c;
2564 int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
2565 XML_MAX_TEXT_LENGTH :
2566 XML_MAX_NAME_LENGTH;
2567 const xmlChar *base = ctxt->input->base;
2568 const xmlChar *ret;
2569
2570 /*
2571 * Handler for more complex cases
2572 */
2573 c = CUR_CHAR(l);
2574 if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
2575 (!IS_LETTER(c) && (c != '_') &&
2576 (c != ':'))) {
2577 return(NULL);
2578 }
2579
2580 while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
2581 ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
2582 (c == '.') || (c == '-') ||
2583 (c == '_') || (c == ':') ||
2584 (IS_COMBINING(c)) ||
2585 (IS_EXTENDER(c)))) {
2586 len += l;
2587 if (len > maxLength) {
2588 htmlParseErr(ctxt, XML_ERR_NAME_TOO_LONG, "name too long", NULL, NULL);
2589 return(NULL);
2590 }
2591 NEXTL(l);
2592 c = CUR_CHAR(l);
2593 if (ctxt->input->base != base) {
2594 /*
2595 * We changed encoding from an unknown encoding
2596 * Input buffer changed location, so we better start again
2597 */
2598 return(htmlParseNameComplex(ctxt));
2599 }
2600 }
2601
2602 if (ctxt->input->cur - ctxt->input->base < len) {
2603 /* Sanity check */
2604 htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
2605 "unexpected change of input buffer", NULL, NULL);
2606 return (NULL);
2607 }
2608
2609 ret = xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len);
2610 if (ret == NULL)
2611 htmlErrMemory(ctxt);
2612
2613 return(ret);
2614}
2615
2616
2617/**

Callers 1

htmlParseNameFunction · 0.85

Calls 2

xmlDictLookupFunction · 0.85
htmlErrMemoryFunction · 0.85

Tested by

no test coverage detected