From bf94e9f788da5acd17c7744889f26ccc958ec914 Mon Sep 17 00:00:00 2001 From: Jan Boon Date: Sat, 6 Apr 2024 03:14:39 +0800 Subject: [PATCH] reject whitespace and trailing dot --- common/common.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/common.cpp b/common/common.cpp index 63fdb2399..7d983a453 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1552,6 +1552,12 @@ bool validate_file_name(const std::string & filename) { } } + // Reject any leading or trailing ' ', or any trailing '.', these are stripped on Windows and will cause a different filename + // Unicode and other whitespace is not affected, only 0x20 space + if (filename.front() == ' ' || filename.back() == ' ' || filename.back() == '.') { + return false; + } + // Reject any ".." (currently stricter than necessary, it should be fine to just check for == ".." instead) if (filename.find("..") != std::string::npos) { return false;