mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Fixing issue 1870 (#1871)
This commit is contained in:
@@ -48,6 +48,4 @@ simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uin
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_ARM64_STRINGPARSING_H
|
||||
|
||||
@@ -31,6 +31,4 @@ simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uin
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_FALLBACK_STRINGPARSING_H
|
||||
|
||||
@@ -43,6 +43,4 @@ simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uin
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_HASWELL_STRINGPARSING_H
|
||||
|
||||
@@ -43,6 +43,4 @@ simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uin
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_ICELAKE_STRINGPARSING_H
|
||||
|
||||
@@ -60,6 +60,4 @@ backslash_and_quote::copy_and_find(const uint8_t *src, uint8_t *dst) {
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_PPC64_STRINGPARSING_H
|
||||
|
||||
@@ -41,6 +41,4 @@ simdjson_inline backslash_and_quote backslash_and_quote::copy_and_find(const uin
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // namespace simdjson
|
||||
|
||||
#include "simdjson/generic/stringparsing.h"
|
||||
|
||||
#endif // SIMDJSON_WESTMERE_STRINGPARSING_H
|
||||
|
||||
@@ -47,7 +47,12 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
|
||||
// multilingual plane check
|
||||
uint32_t code_point = jsoncharutils::hex_to_u32_nocheck(*src_ptr + 2);
|
||||
*src_ptr += 6;
|
||||
// check for low surrogate for characters outside the Basic
|
||||
if (code_point >= 0xd800 && code_point < 0xdc00) {
|
||||
}
|
||||
|
||||
// If we found a high surrogate, we must
|
||||
// check for low surrogate for characters
|
||||
// outside the Basic
|
||||
// Multilingual Plane.
|
||||
if (code_point >= 0xd800 && code_point < 0xdc00) {
|
||||
if (((*src_ptr)[0] != '\\') || (*src_ptr)[1] != 'u') {
|
||||
@@ -67,6 +72,10 @@ simdjson_inline bool handle_unicode_codepoint(const uint8_t **src_ptr,
|
||||
code_point =
|
||||
(((code_point - 0xd800) << 10) | (code_point_2 - 0xdc00)) + 0x10000;
|
||||
*src_ptr += 6;
|
||||
} else if (code_point >= 0xdc00 && code_point <= 0xdfff) {
|
||||
// If we encounter a low surrogate (not preceded by a high surrogate)
|
||||
// then we have an error.
|
||||
return false;
|
||||
}
|
||||
size_t offset = jsoncharutils::codepoint_to_utf8(code_point, *dst_ptr);
|
||||
*dst_ptr += offset;
|
||||
|
||||
@@ -52,6 +52,17 @@ namespace misc_tests {
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
bool issue1870() {
|
||||
TEST_START();
|
||||
ondemand::parser parser;
|
||||
auto json = R"("\uDC00")"_padded;
|
||||
ondemand::document doc;
|
||||
ASSERT_SUCCESS(parser.iterate(json).get(doc));
|
||||
std::string_view view;
|
||||
ASSERT_ERROR( doc.get_string().get(view), STRING_ERROR );
|
||||
TEST_SUCCEED();
|
||||
}
|
||||
|
||||
bool issue1660() {
|
||||
TEST_START();
|
||||
ondemand::parser parser;
|
||||
@@ -447,6 +458,7 @@ namespace misc_tests {
|
||||
|
||||
bool run() {
|
||||
return
|
||||
issue1870() &&
|
||||
is_alive_root_array() &&
|
||||
is_alive_root_object() &&
|
||||
is_alive_array() &&
|
||||
|
||||
Reference in New Issue
Block a user