From 06a9a3bdc3cde5f4bf766771815e95d8e5a8aa62 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 15 Oct 2020 15:37:39 +0200 Subject: file(CONFIGURE): Allow angle brackets in content Fixes: #21306 --- Source/cmFileCommand.cxx | 10 +--------- Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt | 1 + Tests/RunCMake/File_Configure/AngleBracketsContent.cmake | 6 ++++++ .../File_Configure/BadArgGeneratorExpressionContent-result.txt | 1 - .../File_Configure/BadArgGeneratorExpressionContent-stderr.txt | 5 ----- .../File_Configure/BadArgGeneratorExpressionContent.cmake | 4 ---- Tests/RunCMake/File_Configure/RunCMakeTest.cmake | 2 +- 7 files changed, 9 insertions(+), 20 deletions(-) create mode 100644 Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt create mode 100644 Tests/RunCMake/File_Configure/AngleBracketsContent.cmake delete mode 100644 Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt delete mode 100644 Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt delete mode 100644 Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index be91846..8a3aad2 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2945,15 +2945,7 @@ bool HandleConfigureCommand(std::vector const& args, std::string outputFile = cmSystemTools::CollapseFullPath( args[2], status.GetMakefile().GetCurrentBinaryDirectory()); - std::string::size_type pos = input.find_first_of("<>"); - if (pos != std::string::npos) { - status.SetError(cmStrCat("CONFIGURE called with CONTENT containing a \"", - input[pos], - "\". This character is not allowed.")); - return false; - } - - pos = outputFile.find_first_of("<>"); + std::string::size_type pos = outputFile.find_first_of("<>"); if (pos != std::string::npos) { status.SetError(cmStrCat("CONFIGURE called with OUTPUT containing a \"", outputFile[pos], diff --git a/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt b/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt new file mode 100644 index 0000000..08c2ada --- /dev/null +++ b/Tests/RunCMake/File_Configure/AngleBracketsContent-stderr.txt @@ -0,0 +1 @@ +^foo-\$$ diff --git a/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake b/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake new file mode 100644 index 0000000..04c63bb --- /dev/null +++ b/Tests/RunCMake/File_Configure/AngleBracketsContent.cmake @@ -0,0 +1,6 @@ +file(CONFIGURE + OUTPUT "file.txt" + CONTENT "foo-$" +) +file(READ ${CMAKE_CURRENT_BINARY_DIR}/file.txt out) +message("${out}") diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt deleted file mode 100644 index acda654..0000000 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -CMake Error at BadArgGeneratorExpressionContent.cmake:[0-9]+ \(file\): - file CONFIGURE called with CONTENT containing a "<". This character is not - allowed. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake b/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake deleted file mode 100644 index 75fe9e5..0000000 --- a/Tests/RunCMake/File_Configure/BadArgGeneratorExpressionContent.cmake +++ /dev/null @@ -1,4 +0,0 @@ -file(CONFIGURE - OUTPUT "file.txt" - CONTENT "foo-$" -) diff --git a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake index 0337014..e79de79 100644 --- a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake @@ -1,7 +1,7 @@ include(RunCMake) +run_cmake(AngleBracketsContent) run_cmake(BadArg) -run_cmake(BadArgGeneratorExpressionContent) run_cmake(BadArgGeneratorExpressionOutput) run_cmake(DirOutput) run_cmake(NewLineStyle-NoArg) -- cgit v0.12