Skip to content

Commit 75e4cdb

Browse files
lu-zeroshssoichiro
andcommitted
Restrict acceptable characters for placeholders
Co-authored-by: Josh Holmer <jholmer.in@gmail.com>
1 parent 8fdcb82 commit 75e4cdb

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/tokenizer.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,22 @@ fn get_ident_named_placeholder_token<'i>(input: &mut &'i str) -> Result<Token<'i
384384
}
385385

386386
fn get_braced_named_placeholder_token<'i>(input: &mut &'i str) -> Result<Token<'i>> {
387-
delimited('{', take_until(1.., '}'), '}')
388-
.with_taken()
389-
.parse_next(input)
390-
.map(|(index, token)| {
391-
let index = Cow::Borrowed(index);
392-
Token {
393-
kind: TokenKind::Placeholder,
394-
value: token,
395-
key: Some(PlaceholderKind::Named(index)),
396-
alias: token,
397-
}
398-
})
387+
delimited(
388+
'{',
389+
take_while(1.., |c: char| c.is_alphanumeric() || c == '_'),
390+
'}',
391+
)
392+
.with_taken()
393+
.parse_next(input)
394+
.map(|(index, token)| {
395+
let index = Cow::Borrowed(index);
396+
Token {
397+
kind: TokenKind::Placeholder,
398+
value: token,
399+
key: Some(PlaceholderKind::Named(index)),
400+
alias: token,
401+
}
402+
})
399403
}
400404

401405
fn get_string_named_placeholder_token<'i>(

0 commit comments

Comments
 (0)