-
-
Notifications
You must be signed in to change notification settings - Fork 920
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
fix: throw error when asset is empty #3379
Conversation
path: input.clone(), | ||
}) | ||
let path = | ||
std::path::absolute(manifest_dir.join(raw.trim_start_matches('/'))).map_err(|err| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::path::absolute
does not check if the path exists (unlike canonicalize) so this error does not trigger when the path doesn't exist
|
||
// 3. Ensure the path is not the current dir or exist outside the current dir | ||
if path == manifest_dir || !path.starts_with(manifest_dir) || !path.exists() { | ||
return Err(AssetParseError::InvalidPath { path }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, this case triggers which gives the wrong error message
Looks good overall once the error message is fixed. I don't think the first if statement to check if the path should change behavior because the other changes have more robust checks that thow errors for |
While working on the docsite I found that if you passed
asset!("")
on accident, then we'd end up copying the entire current directory over. This is not good. It also causes newdx serve
to hang infinitely since we get stuck on clearing the assets dir.This fixes that by throwing an error if the path is empty and ensuring the final path is a child of the crate.