Skip to content

Commit

Permalink
Fix panic on invalid globs (Keats#820)
Browse files Browse the repository at this point in the history
Closes Keats#819
  • Loading branch information
Keats committed Mar 15, 2023
1 parent 226d010 commit 1f95878
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.18.1 (2023-03-15)

- Fix panic on invalid globs to Tera::new

## 1.18.0 (2023-03-08)

- Add `abs` filter
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tera"
version = "1.18.0"
version = "1.18.1"
authors = ["Vincent Prouillet <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand Down
10 changes: 9 additions & 1 deletion src/tera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Tera {
// See https://github.com/Keats/tera/issues/574 for the Tera discussion
// and https://github.com/Gilnaa/globwalk/issues/28 for the upstream issue.
let (parent_dir, glob_end) = glob.split_at(glob.find('*').unwrap());
let parent_dir = std::fs::canonicalize(parent_dir).unwrap();
let parent_dir = std::fs::canonicalize(parent_dir)?;
let dir = parent_dir.join(glob_end).into_os_string().into_string().unwrap();

// We are parsing all the templates on instantiation
Expand Down Expand Up @@ -1219,4 +1219,12 @@ mod tests {
}
}
}

// https://github.com/Keats/tera/issues/819
#[test]
fn doesnt_panic_on_invalid_glob() {
let tera = Tera::new("\\dev/null/*");
println!("{:?}", tera);
assert!(tera.is_err());
}
}

0 comments on commit 1f95878

Please sign in to comment.