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

Function htmlAttrDumpOutput

ThirdParty/libxml2/vtklibxml2/HTMLtree.c:651–711  ·  view source on GitHub ↗

* htmlAttrDumpOutput: * @buf: the HTML buffer output * @doc: the document * @cur: the attribute pointer * * Dump an HTML attribute */

Source from the content-addressed store, hash-verified

649 * Dump an HTML attribute
650 */
651static void
652htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
653 xmlChar *value;
654
655 /*
656 * The html output method should not escape a & character
657 * occurring in an attribute value immediately followed by
658 * a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
659 * This is implemented in xmlEncodeEntitiesReentrant
660 */
661
662 if (cur == NULL) {
663 return;
664 }
665 xmlOutputBufferWriteString(buf, " ");
666 if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
667 xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
668 xmlOutputBufferWriteString(buf, ":");
669 }
670 xmlOutputBufferWriteString(buf, (const char *)cur->name);
671 if ((cur->children != NULL) && (!htmlIsBooleanAttr(cur->name))) {
672 value = xmlNodeListGetString(doc, cur->children, 0);
673 if (value) {
674 xmlOutputBufferWriteString(buf, "=");
675 if ((cur->ns == NULL) && (cur->parent != NULL) &&
676 (cur->parent->ns == NULL) &&
677 ((!xmlStrcasecmp(cur->name, BAD_CAST "href")) ||
678 (!xmlStrcasecmp(cur->name, BAD_CAST "action")) ||
679 (!xmlStrcasecmp(cur->name, BAD_CAST "src")) ||
680 ((!xmlStrcasecmp(cur->name, BAD_CAST "name")) &&
681 (!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) {
682 xmlChar *escaped;
683 xmlChar *tmp = value;
684
685 while (IS_BLANK_CH(*tmp)) tmp++;
686
687 /*
688 * Angle brackets are technically illegal in URIs, but they're
689 * used in server side includes, for example. Curly brackets
690 * are illegal as well and often used in templates.
691 * Don't escape non-whitespace, printable ASCII chars for
692 * improved interoperability. Only escape space, control
693 * and non-ASCII chars.
694 */
695 escaped = xmlURIEscapeStr(tmp,
696 BAD_CAST "\"#$%&+,/:;<=>?@[\\]^`{|}");
697 if (escaped != NULL) {
698 xmlOutputBufferWriteQuotedString(buf, escaped);
699 xmlFree(escaped);
700 } else {
701 buf->error = XML_ERR_NO_MEMORY;
702 }
703 } else {
704 xmlOutputBufferWriteQuotedString(buf, value);
705 }
706 xmlFree(value);
707 } else {
708 buf->error = XML_ERR_NO_MEMORY;

Callers 1

htmlNodeDumpFormatOutputFunction · 0.85

Calls 6

htmlIsBooleanAttrFunction · 0.85
xmlNodeListGetStringFunction · 0.85
xmlStrcasecmpFunction · 0.85
xmlURIEscapeStrFunction · 0.85

Tested by

no test coverage detected