- Timestamp:
- Sep 10, 2018 10:46:31 AM (6 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/json.cpp
r74175 r74179 695 695 { 696 696 /* The must be a low surrogate pair following the high one: */ 697 rc = VINF_SUCCESS; 697 698 ch = rtJsonTokenizerGetCh(pTokenizer); 698 699 if (ch == '\\') … … 741 742 if (RT_SUCCESS(rc)) 742 743 { 743 Assert(cchStr + RTStrCpSize(uc) < cchStrMax); 744 char *pszNext = RTStrPutCp(&pszDecoded[cchStr], uc); 745 Assert((size_t)(pszNext - &pszDecoded[cchStr]) == RTStrCpSize(uc)); 746 cchStr += pszNext - &pszDecoded[cchStr]; 747 break; 744 if ( uc != 0 745 && uc != 0xfffe 746 && uc != 0xffff) 747 { 748 Assert(cchStr + RTStrCpSize(uc) < cchStrMax); 749 char *pszNext = RTStrPutCp(&pszDecoded[cchStr], uc); 750 Assert((size_t)(pszNext - &pszDecoded[cchStr]) == RTStrCpSize(uc)); 751 cchStr += pszNext - &pszDecoded[cchStr]; 752 break; 753 } 754 rc = RTErrInfoSetF(pTokenizer->pErrInfo, VERR_JSON_INVALID_CODEPOINT, 755 "Invalid \\u code point: %#x (line %zu col %zu)", 756 uc, pTokenizer->Pos.iLine, pTokenizer->Pos.iChStart); 748 757 } 749 758 } … … 758 767 rc = RTErrInfoSetF(pTokenizer->pErrInfo, rc, "Missing UTF-16 surrogate pair (line %zu col %zu)", 759 768 pTokenizer->Pos.iLine, pTokenizer->Pos.iChStart); 760 else 769 else if (rc == VERR_JSON_BAD_SURROGATE_PAIR_SEQUENCE) 761 770 rc = RTErrInfoSetF(pTokenizer->pErrInfo, rc, "Invalid UTF-16 surrogate pair (line %zu col %zu)", 762 771 pTokenizer->Pos.iLine, pTokenizer->Pos.iChStart); -
trunk/src/VBox/Runtime/testcase/tstRTCRest-1.cpp
r74176 r74179 1118 1118 RTTESTI_CHECK(obj4.isNull() == false); 1119 1119 1120 obj4.setNull(); 1121 RTTESTI_CHECK_RC(deserializeFromJson(&obj4, "\"42:\\uD801\\udC37\\ud852\\uDf62:42\"", /* U+10437 U+24B62 */ 1122 &ErrInfo, RT_XSTR(__LINE__)), VINF_SUCCESS); 1123 RTTESTI_CHECK(obj4 == "42:" "\xf0\x90\x90\xb7" "\xf0\xa4\xad\xa2" ":42"); 1124 RTTESTI_CHECK(obj4.isNull() == false); 1125 1120 1126 /* object goes to default state on failure: */ 1121 1127 obj4 = "asdf"; -
trunk/src/VBox/Runtime/testcase/tstRTJson.cpp
r74027 r74179 81 81 { "{\"positive\":20}", VINF_SUCCESS }, 82 82 { "{\"negative\":-20}", VINF_SUCCESS }, 83 { "\"\\u0001\"", VINF_SUCCESS }, 84 { "\"\\u000\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 85 { "\"\\u00\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 86 { "\"\\u0\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 87 { "\"\\u\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 88 { "\"\\uGhKl\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 89 { "\"\\u0000z\"", VERR_JSON_INVALID_CODEPOINT }, 90 { "\"\\uffff\"", VERR_JSON_INVALID_CODEPOINT }, 91 { "\"\\ufffe\"", VERR_JSON_INVALID_CODEPOINT }, 92 { "\"\\ufffd\"", VINF_SUCCESS}, 93 { "\"\\ufffd1\"", VINF_SUCCESS}, 94 { "\"\\ufffd12\"", VINF_SUCCESS}, 95 { "\"\\uD801\\udC37\\ud852\\uDf62\"", VINF_SUCCESS }, /* U+10437 U+24B62 */ 96 { "\"\\uD801 \\udC37\"", VERR_JSON_MISSING_SURROGATE_PAIR }, 97 { "\"\\uD801udC37\"", VERR_JSON_MISSING_SURROGATE_PAIR }, 98 { "\"\\uD801\"", VERR_JSON_MISSING_SURROGATE_PAIR }, 99 { "\"\\uD801\\\"", VERR_JSON_MISSING_SURROGATE_PAIR }, 100 { "\"\\uD801\\u\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 101 { "\"\\uD801\\ud\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 102 { "\"\\uD801\\udc\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 103 { "\"\\uD801\\udc3\"", VERR_JSON_INVALID_UTF16_ESCAPE_SEQUENCE }, 104 { "\"\\uD801\\uDc37\"", VINF_SUCCESS}, 105 { "\"\\uDbff\\uDfff\"", VINF_SUCCESS}, 83 106 }; 84 107 for (unsigned iTest = 0; iTest < RT_ELEMENTS(aTests); iTest++)
Note:
See TracChangeset
for help on using the changeset viewer.