mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-01 22:58:40 -04:00
scanner: Reject attributes that are not valid for an element
This would be caught by the DTD but DTD validation is not fatal by default. Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
parent
2a122485b3
commit
b39e45c48d
1 changed files with 9 additions and 4 deletions
|
|
@ -770,22 +770,27 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
allow_null = atts[i + 1];
|
allow_null = atts[i + 1];
|
||||||
else if (strcmp(atts[i], "enum") == 0)
|
else if (strcmp(atts[i], "enum") == 0)
|
||||||
enumeration_name = atts[i + 1];
|
enumeration_name = atts[i + 1];
|
||||||
else if (strcmp(atts[i], "bitfield") == 0)
|
else if (strcmp(atts[i], "bitfield") == 0) {
|
||||||
|
if (strcmp(element_name, "enum"))
|
||||||
|
fail(&ctx->loc, "bitfield attribute only valid on enum element");
|
||||||
bitfield = atts[i + 1];
|
bitfield = atts[i + 1];
|
||||||
else
|
} else {
|
||||||
fail(&ctx->loc, "invalid attribute name (%s)", atts[i]);
|
fail(&ctx->loc, "invalid attribute name (%s)", atts[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->character_data_length = 0;
|
ctx->character_data_length = 0;
|
||||||
if (strcmp(element_name, "protocol") == 0) {
|
if (strcmp(element_name, "protocol") == 0) {
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
fail(&ctx->loc, "no protocol name given");
|
fail(&ctx->loc, "no protocol name given");
|
||||||
|
if (atts[2])
|
||||||
|
fail(&ctx->loc, "Unexpected attribute for protocol element");
|
||||||
validate_identifier(&ctx->loc, name, STANDALONE_IDENT);
|
validate_identifier(&ctx->loc, name, STANDALONE_IDENT);
|
||||||
ctx->protocol->name = xstrdup(name);
|
ctx->protocol->name = xstrdup(name);
|
||||||
ctx->protocol->uppercase_name = uppercase_dup(name);
|
ctx->protocol->uppercase_name = uppercase_dup(name);
|
||||||
} else if (strcmp(element_name, "copyright") == 0) {
|
} else if (strcmp(element_name, "copyright") == 0) {
|
||||||
|
if (atts[0])
|
||||||
|
fail(&ctx->loc, "copyright element takes no attributes");
|
||||||
} else if (strcmp(element_name, "interface") == 0) {
|
} else if (strcmp(element_name, "interface") == 0) {
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
fail(&ctx->loc, "no interface name given");
|
fail(&ctx->loc, "no interface name given");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue