Changeset: 0b811b335b14 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0b811b335b14
Added Files:
        sql/test/json/Tests/jsonutf16.Bug-7576.test
Modified Files:
        monetdb5/modules/atoms/json.c
        sql/test/json/Tests/All
Branch: Aug2024
Log Message:

fixes #7576: unescaping of UTF-16 surrogate pairs in json.text()


diffs (40 lines):

diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -1754,7 +1754,7 @@ JSONplaintext(char **r, size_t *l, size_
                                        } else if ((u & 0xFC00) == 0xD800) {
                                                /* high surrogate; must be 
followed by low surrogate */
                                                *(*r)++ = 0xF0 | (((u & 0x03C0) 
+ 0x0040) >> 8);
-                                               *(*r)++ = 0x80 | ((((u & 
0x03C0) + 0x0040) >> 2) & 0x3F);
+                                               *(*r)++ = 0x80 | ((((u & 0x3FF) 
+ 0x0040) >> 2) & 0x3F);
                                                **r = 0x80 | ((u & 0x0003) << 
4);       /* no increment */
                                                (*l) -= 2;
                                        } else if ((u & 0xFC00) == 0xDC00) {
diff --git a/sql/test/json/Tests/All b/sql/test/json/Tests/All
--- a/sql/test/json/Tests/All
+++ b/sql/test/json/Tests/All
@@ -18,3 +18,4 @@ jsonkeyarray.Bug-6858
 jsontext.Bug-6859
 jsonnumber.Bug-6932
 jsonparser.Bug-6943
+jsonutf16.Bug-7576
diff --git a/sql/test/json/Tests/jsonutf16.Bug-7576.test 
b/sql/test/json/Tests/jsonutf16.Bug-7576.test
new file mode 100644
--- /dev/null
+++ b/sql/test/json/Tests/jsonutf16.Bug-7576.test
@@ -0,0 +1,15 @@
+query T rowsort
+SELECT json.text('"\\uD83D\\uDC0D"')
+----
+🐍
+
+query T rowsort
+SELECT json.text('"\\u09B8"')
+----
+স
+
+query T rowsort
+SELECT json.text('"\\u00D8"')
+----
+Ø
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to