diff options
author | K. R. Walker <tyu@eridex.org> | 2024-08-19 18:00:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-08-19 18:25:31 (GMT) |
commit | b1f956529a7abefba03f5902ba187956c730afb9 (patch) | |
tree | a8cc30305a05b76c9e5f1a707b019e3ebefe5275 /Source | |
parent | 97bb92ace5fa26e20a0d0f87131dce9567048985 (diff) | |
download | CMake-b1f956529a7abefba03f5902ba187956c730afb9.zip CMake-b1f956529a7abefba03f5902ba187956c730afb9.tar.gz CMake-b1f956529a7abefba03f5902ba187956c730afb9.tar.bz2 |
CPack/NSIS: Fix matching of reserved component names
"Console" unexpectedly matches the reserved name regex. This revealed
that `cmCPackNSISGenerator::CreateComponentDescription()` needs to use
the name returned by `GetSanitizedDirOrFileName()` for the component
file glob.
Fix the change from commit a1af593291 (CPack: Support arbitrary
component name when packaging, 2024-05-01, v3.30.0-rc1~151^2~1) to
address these issues and add related checks to the `CPackNSISGenerator`
test case.
Issue: #23612
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 03b8766..b025570 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1552,6 +1552,7 @@ std::string cmCPackGenerator::GetSanitizedDirOrFileName( #ifdef _WIN32 // Given name matches a reserved name (on Windows)? // Then return it prepended with an underscore. + // See https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file cmsys::RegularExpression reserved_pattern("^(" "[Cc][Oo][Nn]|" "[Pp][Rr][Nn]|" @@ -1559,7 +1560,7 @@ std::string cmCPackGenerator::GetSanitizedDirOrFileName( "[Nn][Uu][Ll]|" "[Cc][Oo][Mm][1-9]|" "[Ll][Pp][Tt][1-9]" - ")([.].+)?"); + ")[.]?$"); if (reserved_pattern.find(name)) { return "_" + name; } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 43b1d76..155bc9e 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -863,8 +863,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( /* clang-format on */ componentCode += out.str(); } else { - componentCode += - " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n"; + componentCode += " File /r \"${INST_DIR}\\" + + this->GetSanitizedDirOrFileName(component->Name) + "\\*.*\"\n"; } componentCode += "SectionEnd\n"; |