fix(downloads): allow the deliberate join_absolute_paths lint in a test
The assertion documents that PathBuf::join discards its base when handed an absolute path — which is why confinement has to happen after the join, not instead of it. clippy::join_absolute_paths flags that shape, correctly for production code, so the lint is allowed here rather than the test weakened. Worth recording: this lint would not have caught the original defect. The real join sites pass a variable, and it only fires on a literal.
This commit is contained in:
@@ -2568,10 +2568,19 @@ mod tests {
|
|||||||
|
|
||||||
// Why the absolute case needs its own guard rather than folding: the
|
// Why the absolute case needs its own guard rather than folding: the
|
||||||
// join the download path performs discards the base entirely.
|
// join the download path performs discards the base entirely.
|
||||||
assert_eq!(
|
//
|
||||||
PathBuf::from(root).join("/etc/cron.d/pwn"),
|
// clippy::join_absolute_paths flags exactly this shape, and is right to
|
||||||
PathBuf::from("/etc/cron.d/pwn")
|
// in production code — here the discarded base *is* the assertion, so
|
||||||
);
|
// the lint is allowed rather than the code changed. Note the lint would
|
||||||
|
// not have caught the original defect: the real join sites take a
|
||||||
|
// variable, and the lint only fires on a literal starting with `/`.
|
||||||
|
#[allow(clippy::join_absolute_paths)]
|
||||||
|
{
|
||||||
|
assert_eq!(
|
||||||
|
PathBuf::from(root).join("/etc/cron.d/pwn"),
|
||||||
|
PathBuf::from("/etc/cron.d/pwn")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The paths the app builds for itself have to survive unchanged: files are
|
/// The paths the app builds for itself have to survive unchanged: files are
|
||||||
|
|||||||
Reference in New Issue
Block a user