Fossil SCM
Changes to support CGI on IIS web servers.
Commit
c06e0b2d0a201aec744b708f1421ce0f4465cf490af4ee6c698609d3d0f1642a
Parent
c6dfb5580251648…
4 files changed
+20
-2
+20
-2
+10
-5
+10
-5
+20
-2
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -997,18 +997,35 @@ | ||
| 997 | 997 | char *zSemi; |
| 998 | 998 | int len; |
| 999 | 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | +#ifdef _WIN32 | |
| 1003 | + const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); | |
| 1004 | +#endif | |
| 1002 | 1005 | |
| 1003 | 1006 | #ifdef FOSSIL_ENABLE_JSON |
| 1004 | 1007 | int noJson = P("no_json")!=0; |
| 1005 | 1008 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1006 | 1009 | #endif |
| 1007 | 1010 | g.isHTTP = 1; |
| 1008 | 1011 | cgi_destination(CGI_BODY); |
| 1009 | 1012 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1013 | +#ifdef _WIN32 | |
| 1014 | + /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses | |
| 1015 | + ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as | |
| 1016 | + ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the | |
| 1017 | + ** beginning. */ | |
| 1018 | + if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ | |
| 1019 | + int i, j; | |
| 1020 | + cgi_set_parameter("REQUEST_URI", zPathInfo); | |
| 1021 | + for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} | |
| 1022 | + for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} | |
| 1023 | + zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); | |
| 1024 | + cgi_replace_parameter("PATH_INFO", zPathInfo); | |
| 1025 | + } | |
| 1026 | +#endif | |
| 1010 | 1027 | if( zRequestUri==0 ){ |
| 1011 | 1028 | const char *z = zPathInfo; |
| 1012 | 1029 | if( zPathInfo==0 ){ |
| 1013 | 1030 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1014 | 1031 | } |
| @@ -1169,15 +1186,16 @@ | ||
| 1169 | 1186 | } |
| 1170 | 1187 | } |
| 1171 | 1188 | |
| 1172 | 1189 | /* If no match is found and the name begins with an upper-case |
| 1173 | 1190 | ** letter, then check to see if there is an environment variable |
| 1174 | - ** with the given name. | |
| 1191 | + ** with the given name. Handle environment variables with empty values | |
| 1192 | + ** the same as non-existent environment variables. | |
| 1175 | 1193 | */ |
| 1176 | 1194 | if( zName && fossil_isupper(zName[0]) ){ |
| 1177 | 1195 | const char *zValue = fossil_getenv(zName); |
| 1178 | - if( zValue ){ | |
| 1196 | + if( zValue && zValue[0] ){ | |
| 1179 | 1197 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1180 | 1198 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1181 | 1199 | return zValue; |
| 1182 | 1200 | } |
| 1183 | 1201 | } |
| 1184 | 1202 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -997,18 +997,35 @@ | |
| 997 | char *zSemi; |
| 998 | int len; |
| 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | |
| 1003 | #ifdef FOSSIL_ENABLE_JSON |
| 1004 | int noJson = P("no_json")!=0; |
| 1005 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1006 | #endif |
| 1007 | g.isHTTP = 1; |
| 1008 | cgi_destination(CGI_BODY); |
| 1009 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1010 | if( zRequestUri==0 ){ |
| 1011 | const char *z = zPathInfo; |
| 1012 | if( zPathInfo==0 ){ |
| 1013 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1014 | } |
| @@ -1169,15 +1186,16 @@ | |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | /* If no match is found and the name begins with an upper-case |
| 1173 | ** letter, then check to see if there is an environment variable |
| 1174 | ** with the given name. |
| 1175 | */ |
| 1176 | if( zName && fossil_isupper(zName[0]) ){ |
| 1177 | const char *zValue = fossil_getenv(zName); |
| 1178 | if( zValue ){ |
| 1179 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1180 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1181 | return zValue; |
| 1182 | } |
| 1183 | } |
| 1184 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -997,18 +997,35 @@ | |
| 997 | char *zSemi; |
| 998 | int len; |
| 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | #ifdef _WIN32 |
| 1003 | const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); |
| 1004 | #endif |
| 1005 | |
| 1006 | #ifdef FOSSIL_ENABLE_JSON |
| 1007 | int noJson = P("no_json")!=0; |
| 1008 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1009 | #endif |
| 1010 | g.isHTTP = 1; |
| 1011 | cgi_destination(CGI_BODY); |
| 1012 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1013 | #ifdef _WIN32 |
| 1014 | /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses |
| 1015 | ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as |
| 1016 | ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the |
| 1017 | ** beginning. */ |
| 1018 | if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ |
| 1019 | int i, j; |
| 1020 | cgi_set_parameter("REQUEST_URI", zPathInfo); |
| 1021 | for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} |
| 1022 | for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} |
| 1023 | zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); |
| 1024 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1025 | } |
| 1026 | #endif |
| 1027 | if( zRequestUri==0 ){ |
| 1028 | const char *z = zPathInfo; |
| 1029 | if( zPathInfo==0 ){ |
| 1030 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1031 | } |
| @@ -1169,15 +1186,16 @@ | |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | /* If no match is found and the name begins with an upper-case |
| 1190 | ** letter, then check to see if there is an environment variable |
| 1191 | ** with the given name. Handle environment variables with empty values |
| 1192 | ** the same as non-existent environment variables. |
| 1193 | */ |
| 1194 | if( zName && fossil_isupper(zName[0]) ){ |
| 1195 | const char *zValue = fossil_getenv(zName); |
| 1196 | if( zValue && zValue[0] ){ |
| 1197 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1198 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1199 | return zValue; |
| 1200 | } |
| 1201 | } |
| 1202 |
+20
-2
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -997,18 +997,35 @@ | ||
| 997 | 997 | char *zSemi; |
| 998 | 998 | int len; |
| 999 | 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | +#ifdef _WIN32 | |
| 1003 | + const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); | |
| 1004 | +#endif | |
| 1002 | 1005 | |
| 1003 | 1006 | #ifdef FOSSIL_ENABLE_JSON |
| 1004 | 1007 | int noJson = P("no_json")!=0; |
| 1005 | 1008 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1006 | 1009 | #endif |
| 1007 | 1010 | g.isHTTP = 1; |
| 1008 | 1011 | cgi_destination(CGI_BODY); |
| 1009 | 1012 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1013 | +#ifdef _WIN32 | |
| 1014 | + /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses | |
| 1015 | + ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as | |
| 1016 | + ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the | |
| 1017 | + ** beginning. */ | |
| 1018 | + if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ | |
| 1019 | + int i, j; | |
| 1020 | + cgi_set_parameter("REQUEST_URI", zPathInfo); | |
| 1021 | + for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} | |
| 1022 | + for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} | |
| 1023 | + zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); | |
| 1024 | + cgi_replace_parameter("PATH_INFO", zPathInfo); | |
| 1025 | + } | |
| 1026 | +#endif | |
| 1010 | 1027 | if( zRequestUri==0 ){ |
| 1011 | 1028 | const char *z = zPathInfo; |
| 1012 | 1029 | if( zPathInfo==0 ){ |
| 1013 | 1030 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1014 | 1031 | } |
| @@ -1169,15 +1186,16 @@ | ||
| 1169 | 1186 | } |
| 1170 | 1187 | } |
| 1171 | 1188 | |
| 1172 | 1189 | /* If no match is found and the name begins with an upper-case |
| 1173 | 1190 | ** letter, then check to see if there is an environment variable |
| 1174 | - ** with the given name. | |
| 1191 | + ** with the given name. Handle environment variables with empty values | |
| 1192 | + ** the same as non-existent environment variables. | |
| 1175 | 1193 | */ |
| 1176 | 1194 | if( zName && fossil_isupper(zName[0]) ){ |
| 1177 | 1195 | const char *zValue = fossil_getenv(zName); |
| 1178 | - if( zValue ){ | |
| 1196 | + if( zValue && zValue[0] ){ | |
| 1179 | 1197 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1180 | 1198 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1181 | 1199 | return zValue; |
| 1182 | 1200 | } |
| 1183 | 1201 | } |
| 1184 | 1202 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -997,18 +997,35 @@ | |
| 997 | char *zSemi; |
| 998 | int len; |
| 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | |
| 1003 | #ifdef FOSSIL_ENABLE_JSON |
| 1004 | int noJson = P("no_json")!=0; |
| 1005 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1006 | #endif |
| 1007 | g.isHTTP = 1; |
| 1008 | cgi_destination(CGI_BODY); |
| 1009 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1010 | if( zRequestUri==0 ){ |
| 1011 | const char *z = zPathInfo; |
| 1012 | if( zPathInfo==0 ){ |
| 1013 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1014 | } |
| @@ -1169,15 +1186,16 @@ | |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | /* If no match is found and the name begins with an upper-case |
| 1173 | ** letter, then check to see if there is an environment variable |
| 1174 | ** with the given name. |
| 1175 | */ |
| 1176 | if( zName && fossil_isupper(zName[0]) ){ |
| 1177 | const char *zValue = fossil_getenv(zName); |
| 1178 | if( zValue ){ |
| 1179 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1180 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1181 | return zValue; |
| 1182 | } |
| 1183 | } |
| 1184 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -997,18 +997,35 @@ | |
| 997 | char *zSemi; |
| 998 | int len; |
| 999 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 1000 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 1001 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 1002 | #ifdef _WIN32 |
| 1003 | const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); |
| 1004 | #endif |
| 1005 | |
| 1006 | #ifdef FOSSIL_ENABLE_JSON |
| 1007 | int noJson = P("no_json")!=0; |
| 1008 | if( noJson==0 ){ json_main_bootstrap(); } |
| 1009 | #endif |
| 1010 | g.isHTTP = 1; |
| 1011 | cgi_destination(CGI_BODY); |
| 1012 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 1013 | #ifdef _WIN32 |
| 1014 | /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses |
| 1015 | ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as |
| 1016 | ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the |
| 1017 | ** beginning. */ |
| 1018 | if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ |
| 1019 | int i, j; |
| 1020 | cgi_set_parameter("REQUEST_URI", zPathInfo); |
| 1021 | for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} |
| 1022 | for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} |
| 1023 | zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); |
| 1024 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1025 | } |
| 1026 | #endif |
| 1027 | if( zRequestUri==0 ){ |
| 1028 | const char *z = zPathInfo; |
| 1029 | if( zPathInfo==0 ){ |
| 1030 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 1031 | } |
| @@ -1169,15 +1186,16 @@ | |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | /* If no match is found and the name begins with an upper-case |
| 1190 | ** letter, then check to see if there is an environment variable |
| 1191 | ** with the given name. Handle environment variables with empty values |
| 1192 | ** the same as non-existent environment variables. |
| 1193 | */ |
| 1194 | if( zName && fossil_isupper(zName[0]) ){ |
| 1195 | const char *zValue = fossil_getenv(zName); |
| 1196 | if( zValue && zValue[0] ){ |
| 1197 | cgi_set_parameter_nocopy(zName, zValue, 0); |
| 1198 | CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue)); |
| 1199 | return zValue; |
| 1200 | } |
| 1201 | } |
| 1202 |
+10
-5
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2035,21 +2035,26 @@ | ||
| 2035 | 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | 2039 | Blob config, line, key, value, value2; |
| 2040 | - if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ | |
| 2041 | - zFile = g.argv[2]; | |
| 2042 | - }else{ | |
| 2043 | - zFile = g.argv[1]; | |
| 2044 | - } | |
| 2040 | + /* Initialize the CGI environment. */ | |
| 2045 | 2041 | g.httpOut = stdout; |
| 2046 | 2042 | g.httpIn = stdin; |
| 2047 | 2043 | fossil_binary_mode(g.httpOut); |
| 2048 | 2044 | fossil_binary_mode(g.httpIn); |
| 2049 | 2045 | g.cgiOutput = 1; |
| 2050 | 2046 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2047 | + /* Read and parse the CGI control file. */ | |
| 2048 | + if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ | |
| 2049 | + zFile = g.argv[2]; | |
| 2050 | + }else if( g.argc>=2 ){ | |
| 2051 | + zFile = g.argv[1]; | |
| 2052 | + }else{ | |
| 2053 | + cgi_panic("No CGI control file specified"); | |
| 2054 | + } | |
| 2055 | + /* Read and parse the CGI control file. */ | |
| 2051 | 2056 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2052 | 2057 | while( blob_line(&config, &line) ){ |
| 2053 | 2058 | if( !blob_token(&line, &key) ) continue; |
| 2054 | 2059 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2055 | 2060 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2056 | 2061 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2035,21 +2035,26 @@ | |
| 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | Blob config, line, key, value, value2; |
| 2040 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2041 | zFile = g.argv[2]; |
| 2042 | }else{ |
| 2043 | zFile = g.argv[1]; |
| 2044 | } |
| 2045 | g.httpOut = stdout; |
| 2046 | g.httpIn = stdin; |
| 2047 | fossil_binary_mode(g.httpOut); |
| 2048 | fossil_binary_mode(g.httpIn); |
| 2049 | g.cgiOutput = 1; |
| 2050 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2051 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2052 | while( blob_line(&config, &line) ){ |
| 2053 | if( !blob_token(&line, &key) ) continue; |
| 2054 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2055 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2056 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2035,21 +2035,26 @@ | |
| 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | Blob config, line, key, value, value2; |
| 2040 | /* Initialize the CGI environment. */ |
| 2041 | g.httpOut = stdout; |
| 2042 | g.httpIn = stdin; |
| 2043 | fossil_binary_mode(g.httpOut); |
| 2044 | fossil_binary_mode(g.httpIn); |
| 2045 | g.cgiOutput = 1; |
| 2046 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2047 | /* Read and parse the CGI control file. */ |
| 2048 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2049 | zFile = g.argv[2]; |
| 2050 | }else if( g.argc>=2 ){ |
| 2051 | zFile = g.argv[1]; |
| 2052 | }else{ |
| 2053 | cgi_panic("No CGI control file specified"); |
| 2054 | } |
| 2055 | /* Read and parse the CGI control file. */ |
| 2056 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2057 | while( blob_line(&config, &line) ){ |
| 2058 | if( !blob_token(&line, &key) ) continue; |
| 2059 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2060 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2061 |
+10
-5
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2035,21 +2035,26 @@ | ||
| 2035 | 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | 2039 | Blob config, line, key, value, value2; |
| 2040 | - if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ | |
| 2041 | - zFile = g.argv[2]; | |
| 2042 | - }else{ | |
| 2043 | - zFile = g.argv[1]; | |
| 2044 | - } | |
| 2040 | + /* Initialize the CGI environment. */ | |
| 2045 | 2041 | g.httpOut = stdout; |
| 2046 | 2042 | g.httpIn = stdin; |
| 2047 | 2043 | fossil_binary_mode(g.httpOut); |
| 2048 | 2044 | fossil_binary_mode(g.httpIn); |
| 2049 | 2045 | g.cgiOutput = 1; |
| 2050 | 2046 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2047 | + /* Read and parse the CGI control file. */ | |
| 2048 | + if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ | |
| 2049 | + zFile = g.argv[2]; | |
| 2050 | + }else if( g.argc>=2 ){ | |
| 2051 | + zFile = g.argv[1]; | |
| 2052 | + }else{ | |
| 2053 | + cgi_panic("No CGI control file specified"); | |
| 2054 | + } | |
| 2055 | + /* Read and parse the CGI control file. */ | |
| 2051 | 2056 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2052 | 2057 | while( blob_line(&config, &line) ){ |
| 2053 | 2058 | if( !blob_token(&line, &key) ) continue; |
| 2054 | 2059 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2055 | 2060 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2056 | 2061 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2035,21 +2035,26 @@ | |
| 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | Blob config, line, key, value, value2; |
| 2040 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2041 | zFile = g.argv[2]; |
| 2042 | }else{ |
| 2043 | zFile = g.argv[1]; |
| 2044 | } |
| 2045 | g.httpOut = stdout; |
| 2046 | g.httpIn = stdin; |
| 2047 | fossil_binary_mode(g.httpOut); |
| 2048 | fossil_binary_mode(g.httpIn); |
| 2049 | g.cgiOutput = 1; |
| 2050 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2051 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2052 | while( blob_line(&config, &line) ){ |
| 2053 | if( !blob_token(&line, &key) ) continue; |
| 2054 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2055 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2056 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -2035,21 +2035,26 @@ | |
| 2035 | char **azRedirect = 0; /* List of repositories to redirect to */ |
| 2036 | int nRedirect = 0; /* Number of entries in azRedirect */ |
| 2037 | Glob *pFileGlob = 0; /* Pattern for files */ |
| 2038 | int allowRepoList = 0; /* Allow lists of repository files */ |
| 2039 | Blob config, line, key, value, value2; |
| 2040 | /* Initialize the CGI environment. */ |
| 2041 | g.httpOut = stdout; |
| 2042 | g.httpIn = stdin; |
| 2043 | fossil_binary_mode(g.httpOut); |
| 2044 | fossil_binary_mode(g.httpIn); |
| 2045 | g.cgiOutput = 1; |
| 2046 | fossil_set_timeout(FOSSIL_DEFAULT_TIMEOUT); |
| 2047 | /* Read and parse the CGI control file. */ |
| 2048 | if( g.argc==3 && fossil_strcmp(g.argv[1],"cgi")==0 ){ |
| 2049 | zFile = g.argv[2]; |
| 2050 | }else if( g.argc>=2 ){ |
| 2051 | zFile = g.argv[1]; |
| 2052 | }else{ |
| 2053 | cgi_panic("No CGI control file specified"); |
| 2054 | } |
| 2055 | /* Read and parse the CGI control file. */ |
| 2056 | blob_read_from_file(&config, zFile, ExtFILE); |
| 2057 | while( blob_line(&config, &line) ){ |
| 2058 | if( !blob_token(&line, &key) ) continue; |
| 2059 | if( blob_buffer(&key)[0]=='#' ) continue; |
| 2060 | if( blob_eq(&key, "repository:") && blob_tail(&line, &value) ){ |
| 2061 |