Skip to content

Commit 5ff4d7b

Browse files
committed
Merge branch 'develop' of https://github.com/nlohmann/json into develop
2 parents fcda998 + 9ec0e4c commit 5ff4d7b

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Example:
148148
include(FetchContent)
149149
150150
FetchContent_Declare(json
151-
GIT_REPOSITORY https://github.com/nlohmann/json
151+
GIT_REPOSITORY https://github.com/nlohmann/json.git
152152
GIT_TAG v3.7.3)
153153
154154
FetchContent_GetProperties(json)

include/nlohmann/detail/input/input_adapters.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,14 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
331331
return input_stream_adapter(stream);
332332
}
333333

334-
template<typename CharT,
334+
template<typename CharT, typename SizeT,
335335
typename std::enable_if<
336336
std::is_pointer<CharT>::value and
337337
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
338+
not std::is_same<SizeT, bool>::value and
338339
sizeof(typename std::remove_pointer<CharT>::type) == 1,
339340
int>::type = 0>
340-
input_buffer_adapter input_adapter(CharT b, std::size_t l)
341+
input_buffer_adapter input_adapter(CharT b, SizeT l)
341342
{
342343
return input_buffer_adapter(reinterpret_cast<const char*>(b), l);
343344
}

single_include/nlohmann/json.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -4753,13 +4753,14 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
47534753
return input_stream_adapter(stream);
47544754
}
47554755

4756-
template<typename CharT,
4756+
template<typename CharT, typename SizeT,
47574757
typename std::enable_if<
47584758
std::is_pointer<CharT>::value and
47594759
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
4760+
not std::is_same<SizeT, bool>::value and
47604761
sizeof(typename std::remove_pointer<CharT>::type) == 1,
47614762
int>::type = 0>
4762-
input_buffer_adapter input_adapter(CharT b, std::size_t l)
4763+
input_buffer_adapter input_adapter(CharT b, SizeT l)
47634764
{
47644765
return input_buffer_adapter(reinterpret_cast<const char*>(b), l);
47654766
}

test/src/unit-regression.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,28 @@ TEST_CASE("regression tests")
18901890
json j = val;
18911891
}
18921892

1893+
SECTION("issue #1715 - json::from_cbor does not respect allow_exceptions = false when input is string literal")
1894+
{
1895+
SECTION("string literal")
1896+
{
1897+
json cbor = json::from_cbor("B", true, false);
1898+
CHECK(cbor.is_discarded());
1899+
}
1900+
1901+
SECTION("string array")
1902+
{
1903+
const char input[] = { 'B', 0x00 };
1904+
json cbor = json::from_cbor(input, true, false);
1905+
CHECK(cbor.is_discarded());
1906+
}
1907+
1908+
SECTION("std::string")
1909+
{
1910+
json cbor = json::from_cbor(std::string("B"), true, false);
1911+
CHECK(cbor.is_discarded());
1912+
}
1913+
}
1914+
18931915
SECTION("issue #1805 - A pair<T1, T2> is json constructible only if T1 and T2 are json constructible")
18941916
{
18951917
static_assert(!std::is_constructible<json, std::pair<std::string, NotSerializableData>>::value, "");

0 commit comments

Comments
 (0)