You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If project path looks like D:\folder[\rocket-project\, then call rocket::build().attach(Template::fairing()) crashes program with this error:
> cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
Running `target\debug\rocket-issue.exe`
thread 'main' panicked at C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rocket_dyn_templates-0.1.0-rc.3\src\context.rs:43:47:
called `Result::unwrap()` on an `Err` value: PatternError { pos: 9, msg: "invalid range pattern" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\rocket-issue.exe` (exit code: 101)
To Reproduce
Absolute path to project must contain open square bracket. Symlinks will be ignored.
Cargo.toml
[package]
name = "rocket-issue"version = "0.1.0"edition = "2021"
[dependencies]
rocket = "0.5.0-rc.3"
[dependencies.rocket_dyn_templates]
version = "0.1.0-rc.3"features = ["handlebars"]
# same with "tera"
I don't think this bracket should be considered as special character, and app must work normally.
Environment:
OS Distribution and Kernel: Windows 10 Home 22H2, Arch Linux x86_64 6.5.7-arch1-1 (same behavior on both systems)
Rocket Version: 0.5.0-rc.3
rocket_dyn_templates version: 0.1.0-rc.3
Additional Context
With path looks like D:\[folder]\rocket-project\ app runs normally, but can't find any templates automatically by Template::fairing (writes Known templates: .). File addition via Template::custom(|t| t.tera.add_template_files(...)) works.
The text was updated successfully, but these errors were encountered:
We use the path as a prefix to a string we construct and parse as a glob pattern. In this case, the path contains special characters that are recognized by the glob pattern parser but are ultimately used incorrectly, resulting in this error.
Looking at the relevant piece of code, what we're doing here is rather odd:
We effectively use glob to find all of the files in a given directory with a certain extension. Using glob for this feels like overkill and has resulted in the bug here. Instead, we simply need to walk the directory (e.g., using the walkdir crate) and filter out files that don't have the extension we're looking for. That would be simpler and avoid the problems here. I'll work on making this change now.
Previously, `dyn_templates` walked the user-provided `template_dir` path by
constructing a glob pattern prefixed with `template_dir`. If `template_dir`
contained characters recognized by the glob pattern parser, then at best the
pattern failed to parse, and at worst, incorrect directories were searched.
This commit removes the use of `glob` to walk the templates directory and
instead uses `walkdir`, obviating the issues described above.
Fixes#2627.
Description
If project path looks like
D:\folder[\rocket-project\
, then callrocket::build().attach(Template::fairing())
crashes program with this error:To Reproduce
Absolute path to project must contain open square bracket. Symlinks will be ignored.
Cargo.toml
main.rs
Expected Behavior
I don't think this bracket should be considered as special character, and app must work normally.
Environment:
Additional Context
With path looks like
D:\[folder]\rocket-project\
app runs normally, but can't find any templates automatically byTemplate::fairing
(writesKnown templates: .
). File addition viaTemplate::custom(|t| t.tera.add_template_files(...))
works.The text was updated successfully, but these errors were encountered: