diff --git a/include/vcpkg/base/json.h b/include/vcpkg/base/json.h index 9b33d870ff..a4d808099e 100644 --- a/include/vcpkg/base/json.h +++ b/include/vcpkg/base/json.h @@ -130,6 +130,7 @@ namespace vcpkg::Json static Value integer(int64_t i) noexcept; static Value number(double d) noexcept; static Value string(std::string&& s) noexcept; + static Value string_valid(std::string&& s) noexcept; template, int> = 0> static Value string(const StringLike& s) noexcept { diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp index 45dd74a8a9..0233cbaf65 100644 --- a/src/vcpkg/base/json.cpp +++ b/src/vcpkg/base/json.cpp @@ -336,6 +336,12 @@ namespace vcpkg::Json val.underlying_ = std::make_unique(ValueKindConstant(), std::move(s)); return val; } + Value Value::string_valid(std::string&& s) noexcept + { + Value val; + val.underlying_ = std::make_unique(ValueKindConstant(), std::move(s)); + return val; + } Value Value::array(Array&& arr) noexcept { Value val; @@ -699,6 +705,7 @@ namespace vcpkg::Json } add_error(msg::format(msgUnexpectedEOFMidString)); + vcpkg::Checks::msg_exit_with_message(VCPKG_LINE_INFO, msgInvalidString); return res; } @@ -1036,7 +1043,7 @@ namespace vcpkg::Json { case '{': return parse_object(); case '[': return parse_array(); - case '"': return Value::string(parse_string()); + case '"': return Value::string_valid(parse_string()); case 'n': case 't': case 'f': return parse_keyword();