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:
dotCooCoo
2026-11-15 11:51:16 -08:00
parent 329aebc68c
commit 4b636ea642
3 changed files with 13 additions and 1 deletions
+3
View File
@@ -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) {