Skip to content

Commit

Permalink
illegal characters are illegal in raw strings, too
Browse files Browse the repository at this point in the history
  • Loading branch information
tjol committed May 14, 2024
1 parent 71c0c08 commit e6b2900
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ static kdl_tokenizer_status _pop_raw_string(kdl_tokenizer* self, kdl_token* dest
return KDL_TOKENIZER_ERROR;
}

if (end_quote_offset != 0 && c == '#') {
if (_kdl_is_illegal_char(self->charset, c)) {
return KDL_TOKENIZER_ERROR;
} else if (end_quote_offset != 0 && c == '#') {
++hashes_found;
} else if (c == '"') {
end_quote_offset = cur - self->document.data;
Expand Down
14 changes: 14 additions & 0 deletions tests/kdlv2_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ static void test_tokenizer_illegal_codepoints(void)
ASSERT(kdl_pop_token(tok, &token) == KDL_TOKENIZER_ERROR);

kdl_destroy_tokenizer(tok);

doc = kdl_str_from_cstr("/* multi-line comments also can't have \x15 */");
tok = kdl_create_string_tokenizer(doc);

ASSERT(kdl_pop_token(tok, &token) == KDL_TOKENIZER_ERROR);

kdl_destroy_tokenizer(tok);

doc = kdl_str_from_cstr("###\" multi-line strings must't \x10 \"###");
tok = kdl_create_string_tokenizer(doc);

ASSERT(kdl_pop_token(tok, &token) == KDL_TOKENIZER_ERROR);

kdl_destroy_tokenizer(tok);
}

void TEST_MAIN(void)
Expand Down

0 comments on commit e6b2900

Please sign in to comment.