Fossil SCM

Use the built-in SQLite caseless string comparison functions instead of the C-library strcasecmp(). Accept mime-type application/x-fossil-uncompressed and avoid decompression when seen.

drh 2010-12-09 13:56 trunk
Commit 0b6c414c6f4473fcfb32a17a1bd856071bcc736b
+4 -2
--- src/cgi.c
+++ src/cgi.c
@@ -246,11 +246,11 @@
246246
char *zBuf = strdup(zMatch);
247247
if( zBuf!=0 ){
248248
char *zTok = 0;
249249
char *zPos;
250250
for( zTok = strtok_r(zBuf, ",\"",&zPos);
251
- zTok && strcasecmp(zTok,zETag);
251
+ zTok && fossil_stricmp(zTok,zETag);
252252
zTok = strtok_r(0, ",\"",&zPos)){}
253253
free(zBuf);
254254
if(zTok) return 1;
255255
}
256256
}
@@ -692,10 +692,12 @@
692692
}
693693
}else if( strcmp(zType, "application/x-fossil")==0 ){
694694
blob_read_from_channel(&g.cgiIn, g.httpIn, len);
695695
blob_uncompress(&g.cgiIn, &g.cgiIn);
696696
}else if( strcmp(zType, "application/x-fossil-debug")==0 ){
697
+ blob_read_from_channel(&g.cgiIn, g.httpIn, len);
698
+ }else if( strcmp(zType, "application/x-fossil-uncompressed")==0 ){
697699
blob_read_from_channel(&g.cgiIn, g.httpIn, len);
698700
}
699701
}
700702
701703
z = (char*)P("HTTP_COOKIE");
@@ -1194,11 +1196,11 @@
11941196
&t.tm_mday, zMonth, &t.tm_year, &t.tm_hour, &t.tm_min,
11951197
&t.tm_sec)){
11961198
11971199
if( t.tm_year > 1900 ) t.tm_year -= 1900;
11981200
for(t.tm_mon=0; azMonths[t.tm_mon]; t.tm_mon++){
1199
- if( !strncasecmp( azMonths[t.tm_mon], zMonth, 3 )){
1201
+ if( !fossil_strnicmp( azMonths[t.tm_mon], zMonth, 3 )){
12001202
return mkgmtime(&t);
12011203
}
12021204
}
12031205
}
12041206
12051207
--- src/cgi.c
+++ src/cgi.c
@@ -246,11 +246,11 @@
246 char *zBuf = strdup(zMatch);
247 if( zBuf!=0 ){
248 char *zTok = 0;
249 char *zPos;
250 for( zTok = strtok_r(zBuf, ",\"",&zPos);
251 zTok && strcasecmp(zTok,zETag);
252 zTok = strtok_r(0, ",\"",&zPos)){}
253 free(zBuf);
254 if(zTok) return 1;
255 }
256 }
@@ -692,10 +692,12 @@
692 }
693 }else if( strcmp(zType, "application/x-fossil")==0 ){
694 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
695 blob_uncompress(&g.cgiIn, &g.cgiIn);
696 }else if( strcmp(zType, "application/x-fossil-debug")==0 ){
 
 
697 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
698 }
699 }
700
701 z = (char*)P("HTTP_COOKIE");
@@ -1194,11 +1196,11 @@
1194 &t.tm_mday, zMonth, &t.tm_year, &t.tm_hour, &t.tm_min,
1195 &t.tm_sec)){
1196
1197 if( t.tm_year > 1900 ) t.tm_year -= 1900;
1198 for(t.tm_mon=0; azMonths[t.tm_mon]; t.tm_mon++){
1199 if( !strncasecmp( azMonths[t.tm_mon], zMonth, 3 )){
1200 return mkgmtime(&t);
1201 }
1202 }
1203 }
1204
1205
--- src/cgi.c
+++ src/cgi.c
@@ -246,11 +246,11 @@
246 char *zBuf = strdup(zMatch);
247 if( zBuf!=0 ){
248 char *zTok = 0;
249 char *zPos;
250 for( zTok = strtok_r(zBuf, ",\"",&zPos);
251 zTok && fossil_stricmp(zTok,zETag);
252 zTok = strtok_r(0, ",\"",&zPos)){}
253 free(zBuf);
254 if(zTok) return 1;
255 }
256 }
@@ -692,10 +692,12 @@
692 }
693 }else if( strcmp(zType, "application/x-fossil")==0 ){
694 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
695 blob_uncompress(&g.cgiIn, &g.cgiIn);
696 }else if( strcmp(zType, "application/x-fossil-debug")==0 ){
697 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
698 }else if( strcmp(zType, "application/x-fossil-uncompressed")==0 ){
699 blob_read_from_channel(&g.cgiIn, g.httpIn, len);
700 }
701 }
702
703 z = (char*)P("HTTP_COOKIE");
@@ -1194,11 +1196,11 @@
1196 &t.tm_mday, zMonth, &t.tm_year, &t.tm_hour, &t.tm_min,
1197 &t.tm_sec)){
1198
1199 if( t.tm_year > 1900 ) t.tm_year -= 1900;
1200 for(t.tm_mon=0; azMonths[t.tm_mon]; t.tm_mon++){
1201 if( !fossil_strnicmp( azMonths[t.tm_mon], zMonth, 3 )){
1202 return mkgmtime(&t);
1203 }
1204 }
1205 }
1206
1207
+15 -8
--- src/http.c
+++ src/http.c
@@ -138,10 +138,11 @@
138138
int rc; /* Result code */
139139
int iHttpVersion; /* Which version of HTTP protocol server uses */
140140
char *zLine; /* A single line of the reply header */
141141
int i; /* Loop counter */
142142
int isError = 0; /* True if the reply is an error message */
143
+ int isCompressed = 1; /* True if the reply is compressed */
143144
144145
if( transport_open() ){
145146
fossil_warning(transport_errmsg());
146147
return 1;
147148
}
@@ -196,11 +197,11 @@
196197
*/
197198
closeConnection = 1;
198199
iLength = -1;
199200
while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
200201
/* printf("[%s]\n", zLine); fflush(stdout); */
201
- if( strncasecmp(zLine, "http/1.", 7)==0 ){
202
+ if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
202203
if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
203204
if( rc!=200 && rc!=302 ){
204205
int ii;
205206
for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
206207
while( zLine[ii]==' ' ) ii++;
@@ -210,23 +211,23 @@
210211
if( iHttpVersion==0 ){
211212
closeConnection = 1;
212213
}else{
213214
closeConnection = 0;
214215
}
215
- }else if( strncasecmp(zLine, "content-length:", 15)==0 ){
216
+ }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){
216217
for(i=15; fossil_isspace(zLine[i]); i++){}
217218
iLength = atoi(&zLine[i]);
218
- }else if( strncasecmp(zLine, "connection:", 11)==0 ){
219
+ }else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){
219220
char c;
220221
for(i=11; fossil_isspace(zLine[i]); i++){}
221222
c = zLine[i];
222223
if( c=='c' || c=='C' ){
223224
closeConnection = 1;
224225
}else if( c=='k' || c=='K' ){
225226
closeConnection = 0;
226227
}
227
- }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
228
+ }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){
228229
int i, j;
229230
for(i=9; zLine[i] && zLine[i]==' '; i++){}
230231
if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
231232
j = strlen(zLine) - 1;
232233
while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){
@@ -235,12 +236,19 @@
235236
}
236237
fossil_print("redirect to %s\n", &zLine[i]);
237238
url_parse(&zLine[i]);
238239
transport_close();
239240
return http_exchange(pSend, pReply, useLogin);
240
- }else if( strncasecmp(zLine, "content-type: text/html", 23)==0 ){
241
- isError = 1;
241
+ }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
242
+ if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
243
+ isCompressed = 0;
244
+ }else if( fossil_strnicmp(&zLine[14],
245
+ "application/x-fossil-uncompressed", -1)==0 ){
246
+ isCompressed = 0;
247
+ }else if( fossil_strnicmp(&zLine[14], "application/x-fossil", -1)!=0 ){
248
+ isError = 1;
249
+ }
242250
}
243251
}
244252
if( rc!=200 ){
245253
fossil_warning("\"location:\" missing from 302 redirect reply");
246254
goto write_err;
@@ -269,14 +277,13 @@
269277
z[j] = z[i];
270278
}
271279
z[j] = 0;
272280
fossil_fatal("server sends error: %s", z);
273281
}
282
+ if( isCompressed ) blob_uncompress(pReply, pReply);
274283
if( g.fHttpTrace ){
275284
/*printf("HTTP RECEIVE:\n%s\n=======================\n",blob_str(pReply));*/
276
- }else{
277
- blob_uncompress(pReply, pReply);
278285
}
279286
280287
/*
281288
** Close the connection to the server if appropriate.
282289
**
283290
--- src/http.c
+++ src/http.c
@@ -138,10 +138,11 @@
138 int rc; /* Result code */
139 int iHttpVersion; /* Which version of HTTP protocol server uses */
140 char *zLine; /* A single line of the reply header */
141 int i; /* Loop counter */
142 int isError = 0; /* True if the reply is an error message */
 
143
144 if( transport_open() ){
145 fossil_warning(transport_errmsg());
146 return 1;
147 }
@@ -196,11 +197,11 @@
196 */
197 closeConnection = 1;
198 iLength = -1;
199 while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
200 /* printf("[%s]\n", zLine); fflush(stdout); */
201 if( strncasecmp(zLine, "http/1.", 7)==0 ){
202 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
203 if( rc!=200 && rc!=302 ){
204 int ii;
205 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
206 while( zLine[ii]==' ' ) ii++;
@@ -210,23 +211,23 @@
210 if( iHttpVersion==0 ){
211 closeConnection = 1;
212 }else{
213 closeConnection = 0;
214 }
215 }else if( strncasecmp(zLine, "content-length:", 15)==0 ){
216 for(i=15; fossil_isspace(zLine[i]); i++){}
217 iLength = atoi(&zLine[i]);
218 }else if( strncasecmp(zLine, "connection:", 11)==0 ){
219 char c;
220 for(i=11; fossil_isspace(zLine[i]); i++){}
221 c = zLine[i];
222 if( c=='c' || c=='C' ){
223 closeConnection = 1;
224 }else if( c=='k' || c=='K' ){
225 closeConnection = 0;
226 }
227 }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
228 int i, j;
229 for(i=9; zLine[i] && zLine[i]==' '; i++){}
230 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
231 j = strlen(zLine) - 1;
232 while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){
@@ -235,12 +236,19 @@
235 }
236 fossil_print("redirect to %s\n", &zLine[i]);
237 url_parse(&zLine[i]);
238 transport_close();
239 return http_exchange(pSend, pReply, useLogin);
240 }else if( strncasecmp(zLine, "content-type: text/html", 23)==0 ){
241 isError = 1;
 
 
 
 
 
 
 
242 }
243 }
244 if( rc!=200 ){
245 fossil_warning("\"location:\" missing from 302 redirect reply");
246 goto write_err;
@@ -269,14 +277,13 @@
269 z[j] = z[i];
270 }
271 z[j] = 0;
272 fossil_fatal("server sends error: %s", z);
273 }
 
274 if( g.fHttpTrace ){
275 /*printf("HTTP RECEIVE:\n%s\n=======================\n",blob_str(pReply));*/
276 }else{
277 blob_uncompress(pReply, pReply);
278 }
279
280 /*
281 ** Close the connection to the server if appropriate.
282 **
283
--- src/http.c
+++ src/http.c
@@ -138,10 +138,11 @@
138 int rc; /* Result code */
139 int iHttpVersion; /* Which version of HTTP protocol server uses */
140 char *zLine; /* A single line of the reply header */
141 int i; /* Loop counter */
142 int isError = 0; /* True if the reply is an error message */
143 int isCompressed = 1; /* True if the reply is compressed */
144
145 if( transport_open() ){
146 fossil_warning(transport_errmsg());
147 return 1;
148 }
@@ -196,11 +197,11 @@
197 */
198 closeConnection = 1;
199 iLength = -1;
200 while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
201 /* printf("[%s]\n", zLine); fflush(stdout); */
202 if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){
203 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
204 if( rc!=200 && rc!=302 ){
205 int ii;
206 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
207 while( zLine[ii]==' ' ) ii++;
@@ -210,23 +211,23 @@
211 if( iHttpVersion==0 ){
212 closeConnection = 1;
213 }else{
214 closeConnection = 0;
215 }
216 }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){
217 for(i=15; fossil_isspace(zLine[i]); i++){}
218 iLength = atoi(&zLine[i]);
219 }else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){
220 char c;
221 for(i=11; fossil_isspace(zLine[i]); i++){}
222 c = zLine[i];
223 if( c=='c' || c=='C' ){
224 closeConnection = 1;
225 }else if( c=='k' || c=='K' ){
226 closeConnection = 0;
227 }
228 }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){
229 int i, j;
230 for(i=9; zLine[i] && zLine[i]==' '; i++){}
231 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
232 j = strlen(zLine) - 1;
233 while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){
@@ -235,12 +236,19 @@
236 }
237 fossil_print("redirect to %s\n", &zLine[i]);
238 url_parse(&zLine[i]);
239 transport_close();
240 return http_exchange(pSend, pReply, useLogin);
241 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
242 if( fossil_strnicmp(&zLine[14], "application/x-fossil-debug", -1)==0 ){
243 isCompressed = 0;
244 }else if( fossil_strnicmp(&zLine[14],
245 "application/x-fossil-uncompressed", -1)==0 ){
246 isCompressed = 0;
247 }else if( fossil_strnicmp(&zLine[14], "application/x-fossil", -1)!=0 ){
248 isError = 1;
249 }
250 }
251 }
252 if( rc!=200 ){
253 fossil_warning("\"location:\" missing from 302 redirect reply");
254 goto write_err;
@@ -269,14 +277,13 @@
277 z[j] = z[i];
278 }
279 z[j] = 0;
280 fossil_fatal("server sends error: %s", z);
281 }
282 if( isCompressed ) blob_uncompress(pReply, pReply);
283 if( g.fHttpTrace ){
284 /*printf("HTTP RECEIVE:\n%s\n=======================\n",blob_str(pReply));*/
 
 
285 }
286
287 /*
288 ** Close the connection to the server if appropriate.
289 **
290
+1 -1
--- src/login.c
+++ src/login.c
@@ -109,11 +109,11 @@
109109
if( zPassword==0 ) return 0;
110110
if( strcmp(zUsername,"anonymous")!=0 ) return 0;
111111
zCS = P("cs"); /* The "cs" parameter is the "captcha seed" */
112112
if( zCS==0 ) return 0;
113113
zPw = captcha_decode((unsigned int)atoi(zCS));
114
- if( strcasecmp(zPw, zPassword)!=0 ) return 0;
114
+ if( fossil_stricmp(zPw, zPassword)!=0 ) return 0;
115115
uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'"
116116
" AND length(pw)>0 AND length(cap)>0");
117117
return uid;
118118
}
119119
120120
--- src/login.c
+++ src/login.c
@@ -109,11 +109,11 @@
109 if( zPassword==0 ) return 0;
110 if( strcmp(zUsername,"anonymous")!=0 ) return 0;
111 zCS = P("cs"); /* The "cs" parameter is the "captcha seed" */
112 if( zCS==0 ) return 0;
113 zPw = captcha_decode((unsigned int)atoi(zCS));
114 if( strcasecmp(zPw, zPassword)!=0 ) return 0;
115 uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'"
116 " AND length(pw)>0 AND length(cap)>0");
117 return uid;
118 }
119
120
--- src/login.c
+++ src/login.c
@@ -109,11 +109,11 @@
109 if( zPassword==0 ) return 0;
110 if( strcmp(zUsername,"anonymous")!=0 ) return 0;
111 zCS = P("cs"); /* The "cs" parameter is the "captcha seed" */
112 if( zCS==0 ) return 0;
113 zPw = captcha_decode((unsigned int)atoi(zCS));
114 if( fossil_stricmp(zPw, zPassword)!=0 ) return 0;
115 uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'"
116 " AND length(pw)>0 AND length(cap)>0");
117 return uid;
118 }
119
120
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -245,11 +245,10 @@
245245
INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(DMDIR)\extra\include
246246
247247
#SSL = -DFOSSIL_ENABLE_SSL=1
248248
SSL =
249249
250
-DMCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp
251250
I18N = -DFOSSIL_I18N=0
252251
253252
CFLAGS = -o
254253
BCC = $(DMDIR)\bin\dmc $(CFLAGS)
255254
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(I18N) $(SSL) $(INCL)
@@ -383,11 +382,10 @@
383382
ZLIBDIR = $(MSCDIR)\extra\lib
384383
ZLIB = zlib.lib
385384
386385
INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
387386
388
-MSCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp
389387
I18N = -DFOSSIL_I18N=0
390388
391389
CFLAGS = -nologo -MT -O2
392390
BCC = $(CC) $(CFLAGS)
393391
TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(I18N) $(SSL) $(INCL)
@@ -546,11 +544,11 @@
546544
547545
# define standard C-compiler and flags, used to compile
548546
# the fossil binary. Some special definitions follow for
549547
# special files follow
550548
CC=$(PellesCDir)\bin\pocc.exe
551
-DEFINES=-DFOSSIL_I18N=0 -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp -D_pgmptr=g.argv[0]
549
+DEFINES=-DFOSSIL_I18N=0 -D_pgmptr=g.argv[0]
552550
CCFLAGS=-T$(TARGETMACHINE_CC)-coff -Ot -W2 -Gd -Go -Ze -MT $(DEFINES)
553551
INCLUDE=/I $(PellesCDir)\Include\Win /I $(PellesCDir)\Include /I $(ZLIBSRCDIR) /I $(SRCDIR)
554552
555553
# define commands for building the windows resource files
556554
RESOURCE=fossil.res
557555
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -245,11 +245,10 @@
245 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(DMDIR)\extra\include
246
247 #SSL = -DFOSSIL_ENABLE_SSL=1
248 SSL =
249
250 DMCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp
251 I18N = -DFOSSIL_I18N=0
252
253 CFLAGS = -o
254 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
255 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(I18N) $(SSL) $(INCL)
@@ -383,11 +382,10 @@
383 ZLIBDIR = $(MSCDIR)\extra\lib
384 ZLIB = zlib.lib
385
386 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
387
388 MSCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp
389 I18N = -DFOSSIL_I18N=0
390
391 CFLAGS = -nologo -MT -O2
392 BCC = $(CC) $(CFLAGS)
393 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(I18N) $(SSL) $(INCL)
@@ -546,11 +544,11 @@
546
547 # define standard C-compiler and flags, used to compile
548 # the fossil binary. Some special definitions follow for
549 # special files follow
550 CC=$(PellesCDir)\bin\pocc.exe
551 DEFINES=-DFOSSIL_I18N=0 -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp -D_pgmptr=g.argv[0]
552 CCFLAGS=-T$(TARGETMACHINE_CC)-coff -Ot -W2 -Gd -Go -Ze -MT $(DEFINES)
553 INCLUDE=/I $(PellesCDir)\Include\Win /I $(PellesCDir)\Include /I $(ZLIBSRCDIR) /I $(SRCDIR)
554
555 # define commands for building the windows resource files
556 RESOURCE=fossil.res
557
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -245,11 +245,10 @@
245 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(DMDIR)\extra\include
246
247 #SSL = -DFOSSIL_ENABLE_SSL=1
248 SSL =
249
 
250 I18N = -DFOSSIL_I18N=0
251
252 CFLAGS = -o
253 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
254 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(I18N) $(SSL) $(INCL)
@@ -383,11 +382,10 @@
382 ZLIBDIR = $(MSCDIR)\extra\lib
383 ZLIB = zlib.lib
384
385 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
386
 
387 I18N = -DFOSSIL_I18N=0
388
389 CFLAGS = -nologo -MT -O2
390 BCC = $(CC) $(CFLAGS)
391 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(I18N) $(SSL) $(INCL)
@@ -546,11 +544,11 @@
544
545 # define standard C-compiler and flags, used to compile
546 # the fossil binary. Some special definitions follow for
547 # special files follow
548 CC=$(PellesCDir)\bin\pocc.exe
549 DEFINES=-DFOSSIL_I18N=0 -D_pgmptr=g.argv[0]
550 CCFLAGS=-T$(TARGETMACHINE_CC)-coff -Ot -W2 -Gd -Go -Ze -MT $(DEFINES)
551 INCLUDE=/I $(PellesCDir)\Include\Win /I $(PellesCDir)\Include /I $(ZLIBSRCDIR) /I $(SRCDIR)
552
553 # define commands for building the windows resource files
554 RESOURCE=fossil.res
555
+28
--- src/printf.c
+++ src/printf.c
@@ -812,5 +812,33 @@
812812
cgi_vprintf(zFormat, ap);
813813
}else{
814814
vprintf(zFormat, ap);
815815
}
816816
}
817
+
818
+/*
819
+** Case insensitive string comparison.
820
+*/
821
+int fossil_strnicmp(const char *zA, const char *zB, int nByte){
822
+ if( zA==0 ){
823
+ if( zB==0 ) return 0;
824
+ return -1;
825
+ }else if( zB==0 ){
826
+ return +1;
827
+ }
828
+ if( nByte<0 ) nByte = strlen(zB);
829
+ return sqlite3_strnicmp(zA, zB, nByte);
830
+}
831
+int fossil_stricmp(const char *zA, const char *zB){
832
+ int nByte;
833
+ int rc;
834
+ if( zA==0 ){
835
+ if( zB==0 ) return 0;
836
+ return -1;
837
+ }else if( zB==0 ){
838
+ return +1;
839
+ }
840
+ nByte = strlen(zB);
841
+ rc = sqlite3_strnicmp(zA, zB, nByte);
842
+ if( rc==0 && zA[nByte] ) rc = 1;
843
+ return rc;
844
+}
817845
--- src/printf.c
+++ src/printf.c
@@ -812,5 +812,33 @@
812 cgi_vprintf(zFormat, ap);
813 }else{
814 vprintf(zFormat, ap);
815 }
816 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
--- src/printf.c
+++ src/printf.c
@@ -812,5 +812,33 @@
812 cgi_vprintf(zFormat, ap);
813 }else{
814 vprintf(zFormat, ap);
815 }
816 }
817
818 /*
819 ** Case insensitive string comparison.
820 */
821 int fossil_strnicmp(const char *zA, const char *zB, int nByte){
822 if( zA==0 ){
823 if( zB==0 ) return 0;
824 return -1;
825 }else if( zB==0 ){
826 return +1;
827 }
828 if( nByte<0 ) nByte = strlen(zB);
829 return sqlite3_strnicmp(zA, zB, nByte);
830 }
831 int fossil_stricmp(const char *zA, const char *zB){
832 int nByte;
833 int rc;
834 if( zA==0 ){
835 if( zB==0 ) return 0;
836 return -1;
837 }else if( zB==0 ){
838 return +1;
839 }
840 nByte = strlen(zB);
841 rc = sqlite3_strnicmp(zA, zB, nByte);
842 if( rc==0 && zA[nByte] ) rc = 1;
843 return rc;
844 }
845
+2 -2
--- src/report.c
+++ src/report.c
@@ -176,11 +176,11 @@
176176
"tag",
177177
"tagxref",
178178
};
179179
int i;
180180
for(i=0; i<sizeof(azAllowed)/sizeof(azAllowed[0]); i++){
181
- if( strcasecmp(zArg1, azAllowed[i])==0 ) break;
181
+ if( fossil_stricmp(zArg1, azAllowed[i])==0 ) break;
182182
}
183183
if( i>=sizeof(azAllowed)/sizeof(azAllowed[0]) ){
184184
*(char**)pError = mprintf("access to table \"%s\" is restricted",zArg1);
185185
rc = SQLITE_DENY;
186186
}else if( !g.okRdAddr && strncmp(zArg2, "private_", 8)==0 ){
@@ -213,11 +213,11 @@
213213
214214
/* First make sure the SQL is a single query command by verifying that
215215
** the first token is "SELECT" and that there are no unquoted semicolons.
216216
*/
217217
for(i=0; fossil_isspace(zSql[i]); i++){}
218
- if( strncasecmp(&zSql[i],"select",6)!=0 ){
218
+ if( fossil_strnicmp(&zSql[i],"select",6)!=0 ){
219219
return mprintf("The SQL must be a SELECT statement");
220220
}
221221
for(i=0; zSql[i]; i++){
222222
if( zSql[i]==';' ){
223223
int bad;
224224
--- src/report.c
+++ src/report.c
@@ -176,11 +176,11 @@
176 "tag",
177 "tagxref",
178 };
179 int i;
180 for(i=0; i<sizeof(azAllowed)/sizeof(azAllowed[0]); i++){
181 if( strcasecmp(zArg1, azAllowed[i])==0 ) break;
182 }
183 if( i>=sizeof(azAllowed)/sizeof(azAllowed[0]) ){
184 *(char**)pError = mprintf("access to table \"%s\" is restricted",zArg1);
185 rc = SQLITE_DENY;
186 }else if( !g.okRdAddr && strncmp(zArg2, "private_", 8)==0 ){
@@ -213,11 +213,11 @@
213
214 /* First make sure the SQL is a single query command by verifying that
215 ** the first token is "SELECT" and that there are no unquoted semicolons.
216 */
217 for(i=0; fossil_isspace(zSql[i]); i++){}
218 if( strncasecmp(&zSql[i],"select",6)!=0 ){
219 return mprintf("The SQL must be a SELECT statement");
220 }
221 for(i=0; zSql[i]; i++){
222 if( zSql[i]==';' ){
223 int bad;
224
--- src/report.c
+++ src/report.c
@@ -176,11 +176,11 @@
176 "tag",
177 "tagxref",
178 };
179 int i;
180 for(i=0; i<sizeof(azAllowed)/sizeof(azAllowed[0]); i++){
181 if( fossil_stricmp(zArg1, azAllowed[i])==0 ) break;
182 }
183 if( i>=sizeof(azAllowed)/sizeof(azAllowed[0]) ){
184 *(char**)pError = mprintf("access to table \"%s\" is restricted",zArg1);
185 rc = SQLITE_DENY;
186 }else if( !g.okRdAddr && strncmp(zArg2, "private_", 8)==0 ){
@@ -213,11 +213,11 @@
213
214 /* First make sure the SQL is a single query command by verifying that
215 ** the first token is "SELECT" and that there are no unquoted semicolons.
216 */
217 for(i=0; fossil_isspace(zSql[i]); i++){}
218 if( fossil_strnicmp(&zSql[i],"select",6)!=0 ){
219 return mprintf("The SQL must be a SELECT statement");
220 }
221 for(i=0; zSql[i]; i++){
222 if( zSql[i]==';' ){
223 int bad;
224
+2 -2
--- src/wiki.c
+++ src/wiki.c
@@ -115,12 +115,12 @@
115115
116116
/*
117117
** Return true if the given pagename is the name of the sandbox
118118
*/
119119
static int is_sandbox(const char *zPagename){
120
- return strcasecmp(zPagename,"sandbox")==0 ||
121
- strcasecmp(zPagename,"sand box")==0;
120
+ return fossil_stricmp(zPagename,"sandbox")==0 ||
121
+ fossil_stricmp(zPagename,"sand box")==0;
122122
}
123123
124124
/*
125125
** WEBPAGE: wiki
126126
** URL: /wiki?name=PAGENAME
127127
--- src/wiki.c
+++ src/wiki.c
@@ -115,12 +115,12 @@
115
116 /*
117 ** Return true if the given pagename is the name of the sandbox
118 */
119 static int is_sandbox(const char *zPagename){
120 return strcasecmp(zPagename,"sandbox")==0 ||
121 strcasecmp(zPagename,"sand box")==0;
122 }
123
124 /*
125 ** WEBPAGE: wiki
126 ** URL: /wiki?name=PAGENAME
127
--- src/wiki.c
+++ src/wiki.c
@@ -115,12 +115,12 @@
115
116 /*
117 ** Return true if the given pagename is the name of the sandbox
118 */
119 static int is_sandbox(const char *zPagename){
120 return fossil_stricmp(zPagename,"sandbox")==0 ||
121 fossil_stricmp(zPagename,"sand box")==0;
122 }
123
124 /*
125 ** WEBPAGE: wiki
126 ** URL: /wiki?name=PAGENAME
127
+1 -1
--- src/winhttp.c
+++ src/winhttp.c
@@ -48,11 +48,11 @@
4848
*/
4949
static int find_content_length(const char *zHdr){
5050
while( *zHdr ){
5151
if( zHdr[0]=='\n' ){
5252
if( zHdr[1]=='\r' ) return 0;
53
- if( strncasecmp(&zHdr[1], "content-length:", 15)==0 ){
53
+ if( fossil_strnicmp(&zHdr[1], "content-length:", 15)==0 ){
5454
return atoi(&zHdr[17]);
5555
}
5656
}
5757
zHdr++;
5858
}
5959
--- src/winhttp.c
+++ src/winhttp.c
@@ -48,11 +48,11 @@
48 */
49 static int find_content_length(const char *zHdr){
50 while( *zHdr ){
51 if( zHdr[0]=='\n' ){
52 if( zHdr[1]=='\r' ) return 0;
53 if( strncasecmp(&zHdr[1], "content-length:", 15)==0 ){
54 return atoi(&zHdr[17]);
55 }
56 }
57 zHdr++;
58 }
59
--- src/winhttp.c
+++ src/winhttp.c
@@ -48,11 +48,11 @@
48 */
49 static int find_content_length(const char *zHdr){
50 while( *zHdr ){
51 if( zHdr[0]=='\n' ){
52 if( zHdr[1]=='\r' ) return 0;
53 if( fossil_strnicmp(&zHdr[1], "content-length:", 15)==0 ){
54 return atoi(&zHdr[17]);
55 }
56 }
57 zHdr++;
58 }
59

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button