/ Check-in [196d66d3]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improvements to JSON string dequoting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 196d66d34d9783622e6f2f79eafea1488fc6f5cf
User & Date: drh 2015-08-24 12:42:41
Context
2015-08-24
15:39
Disallow the use of COLLATE clauses and the ASC and DESC keywords within foreign key constraints and in the argument list to common table expressions. check-in: 83cbc4d8 user: drh tags: trunk
12:42
Improvements to JSON string dequoting. check-in: 196d66d3 user: drh tags: trunk
02:32
Fix corner-case problems in the type and atom columns of json_each() and json_tree(). check-in: f0aba0e1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/json1.c.

   450    450           zOut = sqlite3_malloc( n+1 );
   451    451           if( zOut==0 ){
   452    452             sqlite3_result_error_nomem(pCtx);
   453    453             break;
   454    454           }
   455    455           for(i=1, j=0; i<n-1; i++){
   456    456             char c = z[i];
   457         -          if( c!='\\' && z[i+1] ){
          457  +          if( c!='\\' ){
   458    458               zOut[j++] = c;
   459    459             }else{
   460    460               c = z[++i];
   461         -            if( c=='u' && z[1] ){
          461  +            if( c=='u' ){
   462    462                 u32 v = 0, k;
   463         -              for(k=0; k<4 && z[i+1]; i++, k++){
          463  +              for(k=0; k<4 && i<n-2; i++, k++){
   464    464                   c = z[i+1];
   465    465                   if( c>='0' && c<='9' ) v = v*16 + c - '0';
   466    466                   else if( c>='A' && c<='F' ) v = v*16 + c - 'A' + 10;
   467    467                   else if( c>='a' && c<='f' ) v = v*16 + c - 'a' + 10;
   468    468                   else break;
   469    469                 }
          470  +              if( v==0 ) break;
   470    471                 if( v<=0x7f ){
   471    472                   zOut[j++] = v;
   472    473                 }else if( v<=0x7ff ){
   473    474                   zOut[j++] = 0xc0 | (v>>6);
   474    475                   zOut[j++] = 0x80 | (v&0x3f);
   475         -              }else if( v<=0xffff ){
          476  +              }else{
   476    477                   zOut[j++] = 0xe0 | (v>>12);
   477    478                   zOut[j++] = 0x80 | ((v>>6)&0x3f);
   478    479                   zOut[j++] = 0x80 | (v&0x3f);
   479         -              }else if( v<=0x10ffff ){
   480         -                zOut[j++] = 0xf0 | (v>>18);
   481         -                zOut[j++] = 0x80 | ((v>>12)&0x3f);
   482         -                zOut[j++] = 0x80 | ((v>>6)&0x3f);
   483         -                zOut[j++] = 0x80 | (v&0x3f);
   484    480                 }
   485    481               }else{
   486    482                 if( c=='b' ){
   487    483                   c = '\b';
   488    484                 }else if( c=='f' ){
   489    485                   c = '\f';
   490    486                 }else if( c=='n' ){