Ignore malformed attributes in XML
This commit is contained in:
parent
4310325aba
commit
fe14c0386c
@ -279,6 +279,9 @@ static void nsvg__parseElement(char* s,
|
||||
|
||||
// Get attribs
|
||||
while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
|
||||
char* attr_ptr = NULL;
|
||||
char* value_ptr = NULL;
|
||||
|
||||
// Skip white space before the attrib name
|
||||
while (*s && nsvg__isspace(*s)) s++;
|
||||
if (!*s) break;
|
||||
@ -286,7 +289,7 @@ static void nsvg__parseElement(char* s,
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
attr[nattr++] = s;
|
||||
attr_ptr = s;
|
||||
// Find end of the attrib name.
|
||||
while (*s && !nsvg__isspace(*s) && *s != '=') s++;
|
||||
if (*s) { *s++ = '\0'; }
|
||||
@ -296,9 +299,15 @@ static void nsvg__parseElement(char* s,
|
||||
quote = *s;
|
||||
s++;
|
||||
// Store value and find the end of it.
|
||||
attr[nattr++] = s;
|
||||
value_ptr = s;
|
||||
while (*s && *s != quote) s++;
|
||||
if (*s) { *s++ = '\0'; }
|
||||
|
||||
// Store only well formed attributes
|
||||
if (attr_ptr && value_ptr) {
|
||||
attr[nattr++] = attr_ptr;
|
||||
attr[nattr++] = value_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
// List terminator
|
||||
|
Loading…
Reference in New Issue
Block a user