Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalize include paths before emitting #1107

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions askama_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ impl<'a> Generator<'a> {
Source::Source(_) => **path != self.input.path,
};
if path_is_valid {
let path = path.to_str().unwrap();
let canonical_path = path.canonicalize().unwrap();
let include_path = canonical_path.to_str().unwrap();
buf.writeln(
&quote! {
include_bytes!(#path);
include_bytes!(#include_path);
}
.to_string(),
)?;
Expand Down Expand Up @@ -786,10 +787,11 @@ impl<'a> Generator<'a> {

// Make sure the compiler understands that the generated code depends on the template file.
{
let path = path.to_str().unwrap();
let canonical_path = path.canonicalize().unwrap();
let include_path = canonical_path.to_str().unwrap();
buf.writeln(
&quote! {
include_bytes!(#path);
include_bytes!(#include_path);
}
.to_string(),
)?;
Expand Down
Loading