mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
Merge pull request #569 from GuillaumeGomez/old-paths
Fix invalid handling of paths starting with `::`
This commit is contained in:
commit
e40da12343
@ -786,7 +786,10 @@ impl<'a> Generator<'a, '_> {
|
||||
quote_into!(buf, span, { #this #generics });
|
||||
continue;
|
||||
}
|
||||
buf.write_field(part, span);
|
||||
if i != 0 || !part.is_empty() {
|
||||
// Paths can start with `::`, meaning we can have an empty identifier first.
|
||||
buf.write_field(part, span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>{{::s!()}}<7D> <20>t<EFBFBD>
|
11
testing/tests/path.rs
Normal file
11
testing/tests/path.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use askama::Template;
|
||||
|
||||
// Ensure that paths starting with `::` are supported correctly.
|
||||
#[test]
|
||||
fn test_path_starting_with_colon() {
|
||||
#[derive(Template)]
|
||||
#[template(source = r#"<EFBFBD><EFBFBD><EFBFBD>{{::std::format!("")}}<7D> <20>t<EFBFBD>"#, ext = "txt")]
|
||||
struct X;
|
||||
|
||||
assert_eq!(X.render().unwrap(), "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>t<EFBFBD>");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user