/ Check-in [86675ae0]
Login

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

Overview
Comment:Merge the SQLITE_ENABLE_URI_00_ERROR compile-time option.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 86675ae0abc78960a2faec55d115804acfc3be6d
User & Date: drh 2016-10-26 13:58:47
Context
2016-10-26
16:05
If all branches of an OR optimize scan that is the rhs of a LEFT JOIN use the same index, set the index cursor to return NULL values if there are no matches for a row on the lhs. Fix for ticket [34a579141b2c5ac] check-in: ec9dab80 user: dan tags: trunk
15:46
If all branches of an OR optimize scan that is the rhs of a LEFT JOIN use the same index, set the index cursor to return NULL values if there are no matches for a row on the lhs. Closed-Leaf check-in: e7b9bc67 user: dan tags: leftjoin-or-fix
13:58
Merge the SQLITE_ENABLE_URI_00_ERROR compile-time option. check-in: 86675ae0 user: drh tags: trunk
13:44
Add extra tests to check the result of including a %00 escape in a URI when ENABLE_URI_00_ERROR is defined. Closed-Leaf check-in: 1aaa06e3 user: dan tags: uri-00-error
2016-10-25
15:06
Add test case to demonstrate a "BEGIN EXCLUSIVE" command returning SQLITE_BUSY_SNAPSHOT. check-in: b1158564 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/ctime.c.

   150    150     "ENABLE_STAT3",
   151    151   #endif
   152    152   #if SQLITE_ENABLE_UNLOCK_NOTIFY
   153    153     "ENABLE_UNLOCK_NOTIFY",
   154    154   #endif
   155    155   #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
   156    156     "ENABLE_UPDATE_DELETE_LIMIT",
          157  +#endif
          158  +#if defined(SQLITE_ENABLE_URI_00_ERROR)
          159  +  "ENABLE_URI_00_ERROR",
   157    160   #endif
   158    161   #if SQLITE_HAS_CODEC
   159    162     "HAS_CODEC",
   160    163   #endif
   161    164   #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
   162    165     "HAVE_ISNAN",
   163    166   #endif

Changes to src/main.c.

  2611   2611          && sqlite3Isxdigit(zUri[iIn+1]) 
  2612   2612         ){
  2613   2613           int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);
  2614   2614           octet += sqlite3HexToInt(zUri[iIn++]);
  2615   2615   
  2616   2616           assert( octet>=0 && octet<256 );
  2617   2617           if( octet==0 ){
         2618  +#ifndef SQLITE_ENABLE_URI_00_ERROR
  2618   2619             /* This branch is taken when "%00" appears within the URI. In this
  2619   2620             ** case we ignore all text in the remainder of the path, name or
  2620   2621             ** value currently being parsed. So ignore the current character
  2621   2622             ** and skip to the next "?", "=" or "&", as appropriate. */
  2622   2623             while( (c = zUri[iIn])!=0 && c!='#' 
  2623   2624                 && (eState!=0 || c!='?')
  2624   2625                 && (eState!=1 || (c!='=' && c!='&'))
  2625   2626                 && (eState!=2 || c!='&')
  2626   2627             ){
  2627   2628               iIn++;
  2628   2629             }
  2629   2630             continue;
         2631  +#else
         2632  +          /* If ENABLE_URI_00_ERROR is defined, "%00" in a URI is an error. */
         2633  +          *pzErrMsg = sqlite3_mprintf("unexpected %%00 in uri");
         2634  +          rc = SQLITE_ERROR;
         2635  +          goto parse_uri_out;
         2636  +#endif
  2630   2637           }
  2631   2638           c = octet;
  2632   2639         }else if( eState==1 && (c=='&' || c=='=') ){
  2633   2640           if( zFile[iOut-1]==0 ){
  2634   2641             /* An empty option name. Ignore this option altogether. */
  2635   2642             while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++;
  2636   2643             continue;

Changes to src/test_config.c.

   709    709   #endif
   710    710   
   711    711   #ifdef SQLITE_ENABLE_SQLLOG
   712    712     Tcl_SetVar2(interp, "sqlite_options", "sqllog", "1", TCL_GLOBAL_ONLY);
   713    713   #else
   714    714     Tcl_SetVar2(interp, "sqlite_options", "sqllog", "0", TCL_GLOBAL_ONLY);
   715    715   #endif
          716  +
          717  +#ifdef SQLITE_ENABLE_URI_00_ERROR
          718  +  Tcl_SetVar2(interp, "sqlite_options", "uri_00_error", "1", TCL_GLOBAL_ONLY);
          719  +#else
          720  +  Tcl_SetVar2(interp, "sqlite_options", "uri_00_error", "0", TCL_GLOBAL_ONLY);
          721  +#endif
   716    722   
   717    723   #define LINKVAR(x) { \
   718    724       static const int cv_ ## x = SQLITE_ ## x; \
   719    725       Tcl_LinkVar(interp, "SQLITE_" #x, (char *)&(cv_ ## x), \
   720    726                   TCL_LINK_INT | TCL_LINK_READ_ONLY); }
   721    727   
   722    728     LINKVAR( MAX_LENGTH );

Changes to test/uri.test.

    50     50   
    51     51     15     test.db?mork=1#boris                 test.db?mork=1#boris
    52     52     16     file://localhostPWD/test.db%3Fhello  test.db?hello
    53     53   } {
    54     54     
    55     55   
    56     56     ifcapable !curdir { if {$tn==3} break }
           57  +
           58  +  ifcapable uri_00_error {
           59  +    if {[string first %00 $uri]>=0} continue
           60  +  }
    57     61   
    58     62     if {$tcl_platform(platform)=="windows"} {
    59     63       #
    60     64       # NOTE: Due to limits on legal characters for file names imposed by
    61     65       #       Windows, we must skip the final two tests here (i.e. the
    62     66       #       question mark is illegal in a file name on Windows).
    63     67       #
................................................................................
   119    123     10     file:test.db?hello=%00world&xyz=             {hello {} xyz {}}
   120    124     11     file:test.db?=#ravada                        {}
   121    125     12     file:test.db?&&&&&&&&hello=world&&&&&&&      {hello world}
   122    126   
   123    127     13     test.db?&&&&&&&&hello=world&&&&&&&           {}
   124    128     14     http:test.db?hello&world                     {}
   125    129   } {
          130  +
          131  +  ifcapable uri_00_error {
          132  +    if {[string first %00 $uri]>=0} continue
          133  +  }
   126    134   
   127    135     if {$tcl_platform(platform) == "windows" && $tn>12} {
   128    136       continue
   129    137     }
   130    138   
   131    139     set ::arglist ""
   132    140     set DB [sqlite3_open $uri]

Added test/uri2.test.

            1  +# 2016 October 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# Tests for SQLITE_ENABLE_URI_00_ERROR builds.
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +
           17  +ifcapable !uri_00_error {
           18  +  finish_test
           19  +  return
           20  +}
           21  +
           22  +set testprefix uri2
           23  +db close
           24  +sqlite3_shutdown
           25  +sqlite3_config_uri 1
           26  +
           27  +foreach {tn uri} {
           28  +  1 file:test.db%00trailing
           29  +  2 file:test.db?%00trailing=1
           30  +  3 file:test.db?trailing=1%00
           31  +  4 file:test.db?trailing=1&abc%00def
           32  +  5 file:test.db?trailing=1&abc%00def
           33  +} {
           34  +  do_test 1.$tn.1 {
           35  +    set rc [catch { sqlite3 db $uri } msg]
           36  +    list $rc $msg
           37  +  } {1 {unexpected %00 in uri}}
           38  +
           39  +  do_test 1.$tn.2 {
           40  +    set DB2 [sqlite3_open $uri]
           41  +    sqlite3_errcode $DB2
           42  +  } {SQLITE_ERROR}
           43  +
           44  +  catch { sqlite3_close $DB2 }
           45  +
           46  +  do_test 1.$tn.2 {
           47  +    sqlite3 db ""
           48  +    catchsql { ATTACH $uri AS aux }
           49  +  } {1 {unexpected %00 in uri}}
           50  +
           51  +  do_test 1.$tn.3 {
           52  +    sqlite3_errcode db
           53  +  } {SQLITE_ERROR}
           54  +
           55  +  catch { db close }
           56  +}
           57  +
           58  +reset_db
           59  +do_test 2.0 {
           60  +  expr {[lsearch [execsql {PRAGMA compile_options}] ENABLE_URI_00_ERROR] >= 0}
           61  +} 1
           62  +
           63  +finish_test