-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitize patch input to protect against CMake Language limitations (#773
) ## Description The CMake language outlines a couple of limitations of the language ( https://cmake.org/cmake/help/v3.14/manual/cmake-language.7.html#lists ) which makes parsing abitrary files in CMake problematic. We work around unbalanced `[`, `]` when parsing git patch files by transforming those characters into unique placeholders. Fixes #769 ## Checklist - [x] I am familiar with the [Contributing Guidelines](https://github.com/rapidsai/rapids-cmake/blob/HEAD/CONTRIBUTING.md). - [x] New or existing tests cover these changes. - [x] The documentation is up to date with these changes.
- Loading branch information
1 parent
f484e92
commit 252ea3a
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#============================================================================= | ||
# Copyright (c) 2025, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/detail/convert_patch_json.cmake) | ||
|
||
set(bug | ||
[=[ | ||
int function(not_parsed[ | ||
N], properly ) { | ||
}]=]) | ||
|
||
set(file_path "${CMAKE_BINARY_DIR}/bug.txt") | ||
file(WRITE ${file_path} "${bug}" ) | ||
|
||
rapids_cpm_convert_patch_json(FROM_FILE_TO_JSON json FILE_VAR file_path) | ||
|
||
set(expected_output [==[[ "int function(not_parsed[", "N], properly ) {", "}" ]]==]) | ||
string(JSON json_content GET "${json}" "content") | ||
if(NOT (expected_output STREQUAL json_content)) | ||
message(FATAL_ERROR "exp: `${expected_output}`\ngot: `${json_content}`") | ||
endif() |