Skip to content

Commit

Permalink
Use char_indices() to get byte indices for characters
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Sep 11, 2023
1 parent 7eb687c commit f840fa6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion askama_parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl<'a> Suffix<'a> {
let mut in_str = false;
let mut escaped = false;

for (i, c) in input.chars().enumerate() {
for (i, c) in input.char_indices() {
if !(c == '(' || c == ')') || !in_str {
match c {
'(' => nested += 1,
Expand Down
7 changes: 7 additions & 0 deletions askama_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,10 @@ fn test_parse_array() {
)],
);
}

#[test]
fn fuzzed_unicode_slice() {
let d = "{eeuuu{b&{!!&{!!11{{
0!(!1q҄א!)!!!!!!n!";
assert!(Ast::from_str(d, &Syntax::default()).is_err());
}

0 comments on commit f840fa6

Please sign in to comment.