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

Function xmlExpandEntityInAttValue

ThirdParty/libxml2/vtklibxml2/parser.c:4088–4236  ·  view source on GitHub ↗

* xmlExpandEntityInAttValue: * @ctxt: parser context * @buf: string buffer * @str: entity or attribute value * @pent: entity for entity value, NULL for attribute values * @normalize: whether to collapse whitespace * @inSpace: whitespace state * @depth: nesting depth * @check: whether to check for amplification * * Expand general entity references in an entity or attribute value.

Source from the content-addressed store, hash-verified

4086 * Perform attribute value normalization.
4087 */
4088static void
4089xmlExpandEntityInAttValue(xmlParserCtxtPtr ctxt, xmlSBuf *buf,
4090 const xmlChar *str, xmlEntityPtr pent, int normalize,
4091 int *inSpace, int depth, int check) {
4092 int maxDepth = (ctxt->options & XML_PARSE_HUGE) ? 40 : 20;
4093 int c, chunkSize;
4094
4095 if (str == NULL)
4096 return;
4097
4098 depth += 1;
4099 if (depth > maxDepth) {
4100 xmlFatalErrMsg(ctxt, XML_ERR_RESOURCE_LIMIT,
4101 "Maximum entity nesting depth exceeded");
4102 return;
4103 }
4104
4105 if (pent != NULL) {
4106 if (pent->flags & XML_ENT_EXPANDING) {
4107 xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
4108 xmlHaltParser(ctxt);
4109 return;
4110 }
4111
4112 if (check) {
4113 if (xmlParserEntityCheck(ctxt, pent->length))
4114 return;
4115 }
4116 }
4117
4118 chunkSize = 0;
4119
4120 /*
4121 * Note that entity values are already validated. No special
4122 * handling for multi-byte characters is needed.
4123 */
4124 while (!PARSER_STOPPED(ctxt)) {
4125 c = *str;
4126
4127 if (c != '&') {
4128 if (c == 0)
4129 break;
4130
4131 /*
4132 * If this function is called without an entity, it is used to
4133 * expand entities in an attribute content where less-than was
4134 * already unscaped and is allowed.
4135 */
4136 if ((pent != NULL) && (c == '<')) {
4137 xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
4138 "'<' in entity '%s' is not allowed in attributes "
4139 "values\n", pent->name);
4140 break;
4141 }
4142
4143 if (c <= 0x20) {
4144 if ((normalize) && (*inSpace)) {
4145 /* Skip char */

Callers 2

xmlParseAttValueInternalFunction · 0.85

Calls 9

xmlFatalErrFunction · 0.85
xmlHaltParserFunction · 0.85
xmlParserEntityCheckFunction · 0.85
xmlSBufAddStringFunction · 0.85
xmlSBufAddCStringFunction · 0.85
xmlParseStringCharRefFunction · 0.85
xmlSBufAddCharFunction · 0.85
xmlParseStringEntityRefFunction · 0.85
xmlLookupGeneralEntityFunction · 0.85

Tested by

no test coverage detected