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.
Commit
0b6c414c6f4473fcfb32a17a1bd856071bcc736b
Parent
e154a4386b660f3…
8 files changed
+4
-2
+15
-8
+1
-1
+1
-3
+28
+2
-2
+2
-2
+1
-1
+4
-2
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -246,11 +246,11 @@ | ||
| 246 | 246 | char *zBuf = strdup(zMatch); |
| 247 | 247 | if( zBuf!=0 ){ |
| 248 | 248 | char *zTok = 0; |
| 249 | 249 | char *zPos; |
| 250 | 250 | for( zTok = strtok_r(zBuf, ",\"",&zPos); |
| 251 | - zTok && strcasecmp(zTok,zETag); | |
| 251 | + zTok && fossil_stricmp(zTok,zETag); | |
| 252 | 252 | zTok = strtok_r(0, ",\"",&zPos)){} |
| 253 | 253 | free(zBuf); |
| 254 | 254 | if(zTok) return 1; |
| 255 | 255 | } |
| 256 | 256 | } |
| @@ -692,10 +692,12 @@ | ||
| 692 | 692 | } |
| 693 | 693 | }else if( strcmp(zType, "application/x-fossil")==0 ){ |
| 694 | 694 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 695 | 695 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 696 | 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 ){ | |
| 697 | 699 | blob_read_from_channel(&g.cgiIn, g.httpIn, len); |
| 698 | 700 | } |
| 699 | 701 | } |
| 700 | 702 | |
| 701 | 703 | z = (char*)P("HTTP_COOKIE"); |
| @@ -1194,11 +1196,11 @@ | ||
| 1194 | 1196 | &t.tm_mday, zMonth, &t.tm_year, &t.tm_hour, &t.tm_min, |
| 1195 | 1197 | &t.tm_sec)){ |
| 1196 | 1198 | |
| 1197 | 1199 | if( t.tm_year > 1900 ) t.tm_year -= 1900; |
| 1198 | 1200 | 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 )){ | |
| 1200 | 1202 | return mkgmtime(&t); |
| 1201 | 1203 | } |
| 1202 | 1204 | } |
| 1203 | 1205 | } |
| 1204 | 1206 | |
| 1205 | 1207 |
| --- 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 @@ | ||
| 138 | 138 | int rc; /* Result code */ |
| 139 | 139 | int iHttpVersion; /* Which version of HTTP protocol server uses */ |
| 140 | 140 | char *zLine; /* A single line of the reply header */ |
| 141 | 141 | int i; /* Loop counter */ |
| 142 | 142 | int isError = 0; /* True if the reply is an error message */ |
| 143 | + int isCompressed = 1; /* True if the reply is compressed */ | |
| 143 | 144 | |
| 144 | 145 | if( transport_open() ){ |
| 145 | 146 | fossil_warning(transport_errmsg()); |
| 146 | 147 | return 1; |
| 147 | 148 | } |
| @@ -196,11 +197,11 @@ | ||
| 196 | 197 | */ |
| 197 | 198 | closeConnection = 1; |
| 198 | 199 | iLength = -1; |
| 199 | 200 | while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){ |
| 200 | 201 | /* printf("[%s]\n", zLine); fflush(stdout); */ |
| 201 | - if( strncasecmp(zLine, "http/1.", 7)==0 ){ | |
| 202 | + if( fossil_strnicmp(zLine, "http/1.", 7)==0 ){ | |
| 202 | 203 | if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err; |
| 203 | 204 | if( rc!=200 && rc!=302 ){ |
| 204 | 205 | int ii; |
| 205 | 206 | for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){} |
| 206 | 207 | while( zLine[ii]==' ' ) ii++; |
| @@ -210,23 +211,23 @@ | ||
| 210 | 211 | if( iHttpVersion==0 ){ |
| 211 | 212 | closeConnection = 1; |
| 212 | 213 | }else{ |
| 213 | 214 | closeConnection = 0; |
| 214 | 215 | } |
| 215 | - }else if( strncasecmp(zLine, "content-length:", 15)==0 ){ | |
| 216 | + }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){ | |
| 216 | 217 | for(i=15; fossil_isspace(zLine[i]); i++){} |
| 217 | 218 | iLength = atoi(&zLine[i]); |
| 218 | - }else if( strncasecmp(zLine, "connection:", 11)==0 ){ | |
| 219 | + }else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){ | |
| 219 | 220 | char c; |
| 220 | 221 | for(i=11; fossil_isspace(zLine[i]); i++){} |
| 221 | 222 | c = zLine[i]; |
| 222 | 223 | if( c=='c' || c=='C' ){ |
| 223 | 224 | closeConnection = 1; |
| 224 | 225 | }else if( c=='k' || c=='K' ){ |
| 225 | 226 | closeConnection = 0; |
| 226 | 227 | } |
| 227 | - }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){ | |
| 228 | + }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){ | |
| 228 | 229 | int i, j; |
| 229 | 230 | for(i=9; zLine[i] && zLine[i]==' '; i++){} |
| 230 | 231 | if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine); |
| 231 | 232 | j = strlen(zLine) - 1; |
| 232 | 233 | while( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ){ |
| @@ -235,12 +236,19 @@ | ||
| 235 | 236 | } |
| 236 | 237 | fossil_print("redirect to %s\n", &zLine[i]); |
| 237 | 238 | url_parse(&zLine[i]); |
| 238 | 239 | transport_close(); |
| 239 | 240 | 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 | + } | |
| 242 | 250 | } |
| 243 | 251 | } |
| 244 | 252 | if( rc!=200 ){ |
| 245 | 253 | fossil_warning("\"location:\" missing from 302 redirect reply"); |
| 246 | 254 | goto write_err; |
| @@ -269,14 +277,13 @@ | ||
| 269 | 277 | z[j] = z[i]; |
| 270 | 278 | } |
| 271 | 279 | z[j] = 0; |
| 272 | 280 | fossil_fatal("server sends error: %s", z); |
| 273 | 281 | } |
| 282 | + if( isCompressed ) blob_uncompress(pReply, pReply); | |
| 274 | 283 | if( g.fHttpTrace ){ |
| 275 | 284 | /*printf("HTTP RECEIVE:\n%s\n=======================\n",blob_str(pReply));*/ |
| 276 | - }else{ | |
| 277 | - blob_uncompress(pReply, pReply); | |
| 278 | 285 | } |
| 279 | 286 | |
| 280 | 287 | /* |
| 281 | 288 | ** Close the connection to the server if appropriate. |
| 282 | 289 | ** |
| 283 | 290 |
| --- 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 @@ | ||
| 109 | 109 | if( zPassword==0 ) return 0; |
| 110 | 110 | if( strcmp(zUsername,"anonymous")!=0 ) return 0; |
| 111 | 111 | zCS = P("cs"); /* The "cs" parameter is the "captcha seed" */ |
| 112 | 112 | if( zCS==0 ) return 0; |
| 113 | 113 | zPw = captcha_decode((unsigned int)atoi(zCS)); |
| 114 | - if( strcasecmp(zPw, zPassword)!=0 ) return 0; | |
| 114 | + if( fossil_stricmp(zPw, zPassword)!=0 ) return 0; | |
| 115 | 115 | uid = db_int(0, "SELECT uid FROM user WHERE login='anonymous'" |
| 116 | 116 | " AND length(pw)>0 AND length(cap)>0"); |
| 117 | 117 | return uid; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 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( 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 |
+1
-3
| --- src/makemake.tcl | ||
| +++ src/makemake.tcl | ||
| @@ -245,11 +245,10 @@ | ||
| 245 | 245 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(DMDIR)\extra\include |
| 246 | 246 | |
| 247 | 247 | #SSL = -DFOSSIL_ENABLE_SSL=1 |
| 248 | 248 | SSL = |
| 249 | 249 | |
| 250 | -DMCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp | |
| 251 | 250 | I18N = -DFOSSIL_I18N=0 |
| 252 | 251 | |
| 253 | 252 | CFLAGS = -o |
| 254 | 253 | BCC = $(DMDIR)\bin\dmc $(CFLAGS) |
| 255 | 254 | TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(I18N) $(SSL) $(INCL) |
| @@ -383,11 +382,10 @@ | ||
| 383 | 382 | ZLIBDIR = $(MSCDIR)\extra\lib |
| 384 | 383 | ZLIB = zlib.lib |
| 385 | 384 | |
| 386 | 385 | INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR) |
| 387 | 386 | |
| 388 | -MSCDEF = -Dstrncasecmp=memicmp -Dstrcasecmp=stricmp | |
| 389 | 387 | I18N = -DFOSSIL_I18N=0 |
| 390 | 388 | |
| 391 | 389 | CFLAGS = -nologo -MT -O2 |
| 392 | 390 | BCC = $(CC) $(CFLAGS) |
| 393 | 391 | TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(I18N) $(SSL) $(INCL) |
| @@ -546,11 +544,11 @@ | ||
| 546 | 544 | |
| 547 | 545 | # define standard C-compiler and flags, used to compile |
| 548 | 546 | # the fossil binary. Some special definitions follow for |
| 549 | 547 | # special files follow |
| 550 | 548 | 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] | |
| 552 | 550 | CCFLAGS=-T$(TARGETMACHINE_CC)-coff -Ot -W2 -Gd -Go -Ze -MT $(DEFINES) |
| 553 | 551 | INCLUDE=/I $(PellesCDir)\Include\Win /I $(PellesCDir)\Include /I $(ZLIBSRCDIR) /I $(SRCDIR) |
| 554 | 552 | |
| 555 | 553 | # define commands for building the windows resource files |
| 556 | 554 | RESOURCE=fossil.res |
| 557 | 555 |
| --- 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 @@ | ||
| 812 | 812 | cgi_vprintf(zFormat, ap); |
| 813 | 813 | }else{ |
| 814 | 814 | vprintf(zFormat, ap); |
| 815 | 815 | } |
| 816 | 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 | +} | |
| 817 | 845 |
| --- 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 @@ | ||
| 176 | 176 | "tag", |
| 177 | 177 | "tagxref", |
| 178 | 178 | }; |
| 179 | 179 | int i; |
| 180 | 180 | 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; | |
| 182 | 182 | } |
| 183 | 183 | if( i>=sizeof(azAllowed)/sizeof(azAllowed[0]) ){ |
| 184 | 184 | *(char**)pError = mprintf("access to table \"%s\" is restricted",zArg1); |
| 185 | 185 | rc = SQLITE_DENY; |
| 186 | 186 | }else if( !g.okRdAddr && strncmp(zArg2, "private_", 8)==0 ){ |
| @@ -213,11 +213,11 @@ | ||
| 213 | 213 | |
| 214 | 214 | /* First make sure the SQL is a single query command by verifying that |
| 215 | 215 | ** the first token is "SELECT" and that there are no unquoted semicolons. |
| 216 | 216 | */ |
| 217 | 217 | 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 ){ | |
| 219 | 219 | return mprintf("The SQL must be a SELECT statement"); |
| 220 | 220 | } |
| 221 | 221 | for(i=0; zSql[i]; i++){ |
| 222 | 222 | if( zSql[i]==';' ){ |
| 223 | 223 | int bad; |
| 224 | 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( 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 @@ | ||
| 115 | 115 | |
| 116 | 116 | /* |
| 117 | 117 | ** Return true if the given pagename is the name of the sandbox |
| 118 | 118 | */ |
| 119 | 119 | 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; | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /* |
| 125 | 125 | ** WEBPAGE: wiki |
| 126 | 126 | ** URL: /wiki?name=PAGENAME |
| 127 | 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 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 @@ | ||
| 48 | 48 | */ |
| 49 | 49 | static int find_content_length(const char *zHdr){ |
| 50 | 50 | while( *zHdr ){ |
| 51 | 51 | if( zHdr[0]=='\n' ){ |
| 52 | 52 | 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 ){ | |
| 54 | 54 | return atoi(&zHdr[17]); |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | zHdr++; |
| 58 | 58 | } |
| 59 | 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( 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 |