Fossil SCM
The IIS web server does not define REQUEST_URI, instead is uses PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the beginning.
Commit
54fdd1a5d714fc0ec90ece08757d42d597ba6562907f4771720b1566cddb0436
Parent
9a2ec393db85641…
1 file changed
+17
+17
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -949,17 +949,34 @@ | ||
| 949 | 949 | const char *zType; |
| 950 | 950 | int len; |
| 951 | 951 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 952 | 952 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 953 | 953 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 954 | +#ifdef _WIN32 | |
| 955 | + const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); | |
| 956 | +#endif | |
| 954 | 957 | |
| 955 | 958 | #ifdef FOSSIL_ENABLE_JSON |
| 956 | 959 | json_main_bootstrap(); |
| 957 | 960 | #endif |
| 958 | 961 | g.isHTTP = 1; |
| 959 | 962 | cgi_destination(CGI_BODY); |
| 960 | 963 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 964 | +#ifdef _WIN32 | |
| 965 | + /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses | |
| 966 | + ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as | |
| 967 | + ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the | |
| 968 | + ** beginning. */ | |
| 969 | + if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ | |
| 970 | + int i, j; | |
| 971 | + cgi_set_parameter("REQUEST_URI", zPathInfo); | |
| 972 | + for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} | |
| 973 | + for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} | |
| 974 | + zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); | |
| 975 | + cgi_replace_parameter("PATH_INFO", zPathInfo); | |
| 976 | + } | |
| 977 | +#endif | |
| 961 | 978 | if( zRequestUri==0 ){ |
| 962 | 979 | const char *z = zPathInfo; |
| 963 | 980 | if( zPathInfo==0 ){ |
| 964 | 981 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 965 | 982 | } |
| 966 | 983 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -949,17 +949,34 @@ | |
| 949 | const char *zType; |
| 950 | int len; |
| 951 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 952 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 953 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 954 | |
| 955 | #ifdef FOSSIL_ENABLE_JSON |
| 956 | json_main_bootstrap(); |
| 957 | #endif |
| 958 | g.isHTTP = 1; |
| 959 | cgi_destination(CGI_BODY); |
| 960 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 961 | if( zRequestUri==0 ){ |
| 962 | const char *z = zPathInfo; |
| 963 | if( zPathInfo==0 ){ |
| 964 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 965 | } |
| 966 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -949,17 +949,34 @@ | |
| 949 | const char *zType; |
| 950 | int len; |
| 951 | const char *zRequestUri = cgi_parameter("REQUEST_URI",0); |
| 952 | const char *zScriptName = cgi_parameter("SCRIPT_NAME",0); |
| 953 | const char *zPathInfo = cgi_parameter("PATH_INFO",0); |
| 954 | #ifdef _WIN32 |
| 955 | const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0); |
| 956 | #endif |
| 957 | |
| 958 | #ifdef FOSSIL_ENABLE_JSON |
| 959 | json_main_bootstrap(); |
| 960 | #endif |
| 961 | g.isHTTP = 1; |
| 962 | cgi_destination(CGI_BODY); |
| 963 | if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME"); |
| 964 | #ifdef _WIN32 |
| 965 | /* The Microsoft IIS web server does not define REQUEST_URI, instead it uses |
| 966 | ** PATH_INFO for virtually the same purpose. Define REQUEST_URI the same as |
| 967 | ** PATH_INFO and redefine PATH_INFO with SCRIPT_NAME removed from the |
| 968 | ** beginning. */ |
| 969 | if( zServerSoftware && strstr(zServerSoftware, "Microsoft-IIS") ){ |
| 970 | int i, j; |
| 971 | cgi_set_parameter("REQUEST_URI", zPathInfo); |
| 972 | for(i=0; zPathInfo[i]==zScriptName[i] && zPathInfo[i]; i++){} |
| 973 | for(j=i; zPathInfo[j] && zPathInfo[j]!='?'; j++){} |
| 974 | zPathInfo = mprintf("%.*s", j-i, zPathInfo+i); |
| 975 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 976 | } |
| 977 | #endif |
| 978 | if( zRequestUri==0 ){ |
| 979 | const char *z = zPathInfo; |
| 980 | if( zPathInfo==0 ){ |
| 981 | malformed_request("missing PATH_INFO and/or REQUEST_URI"); |
| 982 | } |
| 983 |