mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-12 04:20:01 -05:00
string(JSON): Include invalid JSON in parse error
This commit is contained in:
@@ -1059,7 +1059,8 @@ Json::Value ReadJson(std::string const& jsonstr)
|
||||
std::string error;
|
||||
if (!jsonReader->parse(jsonstr.data(), jsonstr.data() + jsonstr.size(),
|
||||
&json, &error)) {
|
||||
throw json_error(cmStrCat("failed parsing json string: "_s, error));
|
||||
throw json_error(
|
||||
cmStrCat("failed parsing json string:\n"_s, jsonstr, '\n', error));
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -53,24 +53,26 @@ foreach(i RANGE ${length})
|
||||
endforeach()
|
||||
|
||||
has_key_index(staticSystemInformation "${contents}" ${hasStaticInfo})
|
||||
has_key_index(OSName "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(familyId "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(hostname "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(modelId "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorName "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(vendorID "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(vendorString "${staticSystemInformation}" ${hasStaticInfo})
|
||||
if (NOT hasStaticInfo STREQUAL UNEXPECTED)
|
||||
has_key_index(OSName "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(familyId "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(hostname "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(modelId "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(processorName "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(vendorID "${staticSystemInformation}" ${hasStaticInfo})
|
||||
has_key_index(vendorString "${staticSystemInformation}" ${hasStaticInfo})
|
||||
endif()
|
||||
|
||||
get_filename_component(dataDir ${index} DIRECTORY)
|
||||
get_filename_component(v1 ${dataDir} DIRECTORY)
|
||||
|
||||
1
Tests/RunCMake/string/JSONBadJson-result.txt
Normal file
1
Tests/RunCMake/string/JSONBadJson-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
26
Tests/RunCMake/string/JSONBadJson-stderr.txt
Normal file
26
Tests/RunCMake/string/JSONBadJson-stderr.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
CMake Error at JSONBadJson.cmake:1 \(string\):
|
||||
string sub-command JSON failed parsing json string:
|
||||
|
||||
invalid
|
||||
|
||||
\* Line 1, Column 1
|
||||
|
||||
Syntax error: value, object or array expected.
|
||||
|
||||
.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at JSONBadJson.cmake:2 \(string\):
|
||||
string sub-command JSON failed parsing json string:
|
||||
|
||||
value
|
||||
|
||||
\* Line 1, Column 1
|
||||
|
||||
Syntax error: value, object or array expected.
|
||||
|
||||
.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
3
Tests/RunCMake/string/JSONBadJson.cmake
Normal file
3
Tests/RunCMake/string/JSONBadJson.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
string(JSON badInput SET invalid key \"value\")
|
||||
string(JSON badValue SET {} key value)
|
||||
string(JSON good SET {} key \"value\")
|
||||
@@ -6,6 +6,7 @@ run_cmake(JSONNoJson)
|
||||
run_cmake(JSONWrongMode)
|
||||
run_cmake(JSONOneArg)
|
||||
run_cmake(JSONNoArgs)
|
||||
run_cmake(JSONBadJson)
|
||||
|
||||
run_cmake(Append)
|
||||
run_cmake(AppendNoArgs)
|
||||
|
||||
Reference in New Issue
Block a user