Enforce UCASE_ATTR

This commit is contained in:
Wilson Lin 2018-08-04 22:37:41 +12:00
parent 71c5ffd6fd
commit 036dbb4c4b
2 changed files with 11 additions and 4 deletions

View File

@ -9,17 +9,24 @@
#include "../../util/hbchar.h"
#include "../../util/pipe.c"
void hbsh_attr(hbu_pipe_t pipe) {
#include "../streamoptions.c"
void hbsh_attr(hbs_options_t so, hbu_pipe_t pipe) {
hbu_buffer_t name = hbu_buffer_create();
while (1) {
// Char matched by $attrname required at least once
hbu_buffer_append(name, hbu_pipe_require_predicate(pipe, &hbr_attrname_check, "attribute name"));
hb_char_t c = hbu_pipe_require_predicate(pipe, &hbr_attrname_check, "attribute name");
if (!hbs_options_supressed_error(so, HBE_PARSE_UCASE_ATTR)) {
hbu_pipe_error(pipe, HBE_PARSE_UCASE_ATTR, "Uppercase letter in attribute name");
}
hbu_buffer_append(name, c);
// Don't use hbu_pipe_accept_while_predicate as advanced checks might be needed
hb_char_t n = hbu_pipe_peek(pipe);
// TODO Check against UCASEATTR
if (!hbr_attrname_check(n)) {
break;
}

View File

@ -41,7 +41,7 @@ void hbs_tag(hbs_options_t so, hbu_pipe_t pipe) {
// TODO Check for whitespace between attributes and before self-closing tag
hbu_pipe_skip_while_predicate(pipe, &hbr_whitespace_check);
hbsh_attr(pipe);
hbsh_attr(so, pipe);
}
hb_char_t *tag_name = hbu_buffer_underlying(opening_name);