Skip to content

Commit 4872386

Browse files
committed
Require a space after the inline comment tag name (i.e. after #)
1 parent 5850f73 commit 4872386

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

ext/liquid_c/block.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ static VALUE block_body_initialize(VALUE self, VALUE parse_context)
120120
return Qnil;
121121
}
122122

123-
static int is_id(int c)
123+
static int is_tag_name_char(int c)
124124
{
125-
return rb_isalnum(c) || c == '_';
125+
return rb_isalnum(c) || c == '_' || c == '#';
126126
}
127127

128128
static tag_markup_t internal_block_body_parse(block_body_t *body, parse_context_t *parse_context)
@@ -204,18 +204,13 @@ static tag_markup_t internal_block_body_parse(block_body_t *body, parse_context_
204204

205205
// Imitate \s*(\w+)\s*(.*)? regex
206206
const char *name_start = read_while(start, end, rb_isspace);
207-
const char *name_end = read_while(name_start, end, is_id);
207+
const char *name_end = read_while(name_start, end, is_tag_name_char);
208208
long name_len = name_end - name_start;
209209

210210
if (name_len == 0) {
211-
if (name_start < end && *name_start == '#') { // inline comment
212-
name_end++;
213-
name_len++;
214-
} else {
215-
VALUE str = rb_enc_str_new(token.str_trimmed, token.len_trimmed, utf8_encoding);
216-
unknown_tag = (tag_markup_t) { str, str };
217-
goto loop_break;
218-
}
211+
VALUE str = rb_enc_str_new(token.str_trimmed, token.len_trimmed, utf8_encoding);
212+
unknown_tag = (tag_markup_t) { str, str };
213+
goto loop_break;
219214
}
220215

221216
if (name_len == 6 && strncmp(name_start, "liquid", 6) == 0) {

0 commit comments

Comments
 (0)