From bb61d0fabce60e44a326edee1f3ead93ffa9517e Mon Sep 17 00:00:00 2001 From: xomx Date: Wed, 26 Mar 2025 19:05:57 +0100 Subject: [PATCH] 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 --- PowerEditor/src/MISC/Common/Common.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 8df09af21..943490b4b 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -1530,15 +1530,14 @@ bool isUnsupportedFileName(const wstring& fileName) 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; - size_t pos = fileName.find_first_of(L"."); - if (pos != std::string::npos) - fileNameOnly = fileName.substr(0, pos); + if (fileName.ends_with(L'.')) + fileNameOnly = fileName.substr(0, fileName.rfind(L".")); else fileNameOnly = fileName; - pos = fileNameOnly.find_last_of(L"\\"); + size_t pos = fileNameOnly.find_last_of(L"\\"); if (pos == std::string::npos) pos = fileNameOnly.find_last_of(L"/"); if (pos != std::string::npos)