Fix invalid dot-char(s) handling in filenames checking

Remove the restriction of file extesion on reserved name in Windows system.

Fix #16328, close #16331
This commit is contained in:
xomx 2025-03-26 19:05:57 +01:00 committed by Don Ho
parent 15b92c69d7
commit bb61d0fabc

View File

@ -1530,15 +1530,14 @@ bool isUnsupportedFileName(const wstring& fileName)
if (!invalidASCIIChar) if (!invalidASCIIChar)
{ {
// strip input string to a filename without a possible path and extension(s) // strip input string to a filename without a possible path and/or ending dot-char
wstring fileNameOnly; wstring fileNameOnly;
size_t pos = fileName.find_first_of(L"."); if (fileName.ends_with(L'.'))
if (pos != std::string::npos) fileNameOnly = fileName.substr(0, fileName.rfind(L"."));
fileNameOnly = fileName.substr(0, pos);
else else
fileNameOnly = fileName; fileNameOnly = fileName;
pos = fileNameOnly.find_last_of(L"\\"); size_t pos = fileNameOnly.find_last_of(L"\\");
if (pos == std::string::npos) if (pos == std::string::npos)
pos = fileNameOnly.find_last_of(L"/"); pos = fileNameOnly.find_last_of(L"/");
if (pos != std::string::npos) if (pos != std::string::npos)