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

Function xmlParseAttValueInternal

ThirdParty/libxml2/vtklibxml2/parser.c:4302–4531  ·  view source on GitHub ↗

* xmlParseAttValueInternal: * @ctxt: an XML parser context * @len: attribute len result * @alloc: whether the attribute was reallocated as a new string * @normalize: if 1 then further non-CDATA normalization must be done * * parse a value for an attribute. * NOTE: if no normalization is needed, the routine will return pointers * directly from the data buffer. * * 3.3.3 Attribut

Source from the content-addressed store, hash-verified

4300 * caller if it was copied, this can be detected by val[*len] == 0.
4301 */
4302static xmlChar *
4303xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *attlen, int *alloc,
4304 int normalize, int isNamespace) {
4305 unsigned maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4306 XML_MAX_HUGE_LENGTH :
4307 XML_MAX_TEXT_LENGTH;
4308 xmlSBuf buf;
4309 xmlChar *ret;
4310 int c, l, quote, flags, chunkSize;
4311 int inSpace = 1;
4312 int replaceEntities;
4313
4314 /* Always expand namespace URIs */
4315 replaceEntities = (ctxt->replaceEntities) || (isNamespace);
4316
4317 xmlSBufInit(&buf, maxLength);
4318
4319 GROW;
4320
4321 quote = CUR;
4322 if ((quote != '"') && (quote != '\'')) {
4323 xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
4324 return(NULL);
4325 }
4326 NEXTL(1);
4327
4328 if (ctxt->inSubset == 0)
4329 flags = XML_ENT_CHECKED | XML_ENT_VALIDATED;
4330 else
4331 flags = XML_ENT_VALIDATED;
4332
4333 inSpace = 1;
4334 chunkSize = 0;
4335
4336 while (1) {
4337 if (PARSER_STOPPED(ctxt))
4338 goto error;
4339
4340 if (CUR_PTR >= ctxt->input->end) {
4341 xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
4342 "AttValue: ' expected\n");
4343 goto error;
4344 }
4345
4346 /*
4347 * TODO: Check growth threshold
4348 */
4349 if (ctxt->input->end - CUR_PTR < 10)
4350 GROW;
4351
4352 c = CUR;
4353
4354 if (c >= 0x80) {
4355 l = xmlUTF8MultibyteLen(ctxt, CUR_PTR,
4356 "invalid character in attribute value\n");
4357 if (l == 0) {
4358 if (chunkSize > 0) {
4359 xmlSBufAddString(&buf, CUR_PTR - chunkSize, chunkSize);

Callers 2

xmlParseAttValueFunction · 0.85
xmlParseAttribute2Function · 0.85

Calls 15

xmlSBufInitFunction · 0.85
xmlFatalErrFunction · 0.85
xmlUTF8MultibyteLenFunction · 0.85
xmlSBufAddStringFunction · 0.85
xmlSBufAddReplCharFunction · 0.85
xmlSBufAddCStringFunction · 0.85
xmlParseCharRefFunction · 0.85
xmlSBufAddCharFunction · 0.85
xmlLookupGeneralEntityFunction · 0.85
xmlCheckEntityInAttValueFunction · 0.85

Tested by

no test coverage detected