File: 42-JSON-2_2.patch

package info (click to toggle)
sqlite3 3.16.2-5+deb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 88,416 kB
  • sloc: ansic: 195,593; tcl: 14,245; sh: 10,163; yacc: 1,246; makefile: 1,058; cs: 299; cpp: 128
file content (46 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Index: sqlite3/ext/misc/json1.c
==================================================================
--- sqlite3/ext/misc/json1.c
+++ sqlite3/ext/misc/json1.c
@@ -784,11 +784,14 @@
     /* Parse string */
     u8 jnFlags = 0;
     j = i+1;
     for(;;){
       c = z[j];
-      if( c<=0x1f ) return -1;  /* Control characters not allowed in strings */
+      if( (c & ~0x1f)==0 ){
+        /* Control characters are not allowed in strings */
+        return -1;
+      }
       if( c=='\\' ){
         c = z[++j];
         if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
            || c=='n' || c=='r' || c=='t'
            || (c=='u' && jsonIs4Hex(z+j+1)) ){

Index: sqlite3/test/json101.test
==================================================================
--- sqlite3/test/json101.test
+++ sqlite3/test/json101.test
@@ -353,10 +353,19 @@
   SELECT b FROM t8;
 } {{["abc\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#xyz"]}}
 do_execsql_test json-8.2 {
   SELECT a=json_extract(b,'$[0]') FROM t8;
 } {1}
+
+# 2017-04-12.  Regression reported on the mailing list by Rolf Ade
+#
+do_execsql_test json-8.3 {
+  SELECT json_valid(char(0x22,0xe4,0x22));
+} {1}
+do_execsql_test json-8.4 {
+  SELECT unicode(json_extract(char(0x22,228,0x22),'$'));
+} {228}
 
 # The json_quote() function transforms an SQL value into a JSON value.
 # String values are quoted and interior quotes are escaped.  NULL values
 # are rendered as the unquoted string "null".
 #