diff --git a/include/sonic/internal/arch/simd_skip.h b/include/sonic/internal/arch/simd_skip.h index 80faea0..c3a2533 100644 --- a/include/sonic/internal/arch/simd_skip.h +++ b/include/sonic/internal/arch/simd_skip.h @@ -184,7 +184,9 @@ class SkipScanner { // parse escaped key kbuf.resize(sn + 32); uint8_t *nsrc = &kbuf[0]; - std::memcpy(nsrc, sp, sn); + + // parseStringInplace need `"` as the end + std::memcpy(nsrc, sp, sn + 1); sn = parseStringInplace(nsrc, err); if (err) { pos = (sp - data) + (nsrc - &kbuf[0]); diff --git a/tests/skip_test.cpp b/tests/skip_test.cpp index a22c825..1f59b60 100644 --- a/tests/skip_test.cpp +++ b/tests/skip_test.cpp @@ -79,6 +79,15 @@ TEST(GetOnDemand, SuccessEscapeCharacters) { R"("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\")"); TestGetOnDemand(R"({"a":"\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\""})", {"a"}, R"("\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"")"); + TestGetOnDemand(R"({"\"a\"":"\n\tHello,\nworld!\n"})", {"\"a\""}, + R"("\n\tHello,\nworld!\n")"); + TestGetOnDemand(R"({"123456789012345\"123":"sse_string", + "1234567890123456789012345678901\"123":"avx2_string", + "obj\n\t\\":{"name\\\\\\\\":"string\\\\"}, + "array\"\t\n\b\r":["\n\tHello,\nworld!\n", + "{\" / \b \f \n \r \t } [景] 测试中文 😀")], + "\"a\"":"\n\tHello,\nworld!\n"})", + {"\"a\""}, R"("\n\tHello,\nworld!\n")"); } TEST(GetOnDemand, Failed) { @@ -93,4 +102,4 @@ TEST(GetOnDemand, Failed) { TestGetOnDemandFailed(R"("\")", {}, ParseResult(kParseErrorInvalidChar, 3)); } -} // namespace \ No newline at end of file +} // namespace