mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 17:23:00 +00:00
File Info: a template name that is not a file name is refused
file.info.applyTemplate with a name such as a/b no longer opens the template its safe file name names (a-b.xmp): a name that matches no listed template and is not a file name as it is gives an error. docs/mcp.md cites the help page that describes metadata templates.
This commit is contained in:
@@ -257,6 +257,9 @@ fn template_bytes(s: &Session, p: &Value) -> Result<Vec<u8>> {
|
||||
.min_by_key(|f| (f != name, *f != own));
|
||||
if let Some(file) = listed {
|
||||
path = dir.join(file).to_string_lossy().into_owned();
|
||||
} else if std::path::Path::new(&path).file_stem().map(|s| s.to_string_lossy()).as_deref() != Some(name) {
|
||||
// A name that is not a file name as it is never opens another template.
|
||||
return Err(bad(APPLY, "the template name isn't usable as a file name"));
|
||||
}
|
||||
let plain_file = |path: &str| std::fs::symlink_metadata(path).is_ok_and(|m| m.is_file());
|
||||
if std::fs::symlink_metadata(&path).is_ok() && !plain_file(&path) {
|
||||
|
||||
Reference in New Issue
Block a user