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.

tsbg 2019-08-31 13:53 iis-cgi
Commit 54fdd1a5d714fc0ec90ece08757d42d597ba6562907f4771720b1566cddb0436
1 file changed +17
+17
--- src/cgi.c
+++ src/cgi.c
@@ -949,17 +949,34 @@
949949
const char *zType;
950950
int len;
951951
const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
952952
const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
953953
const char *zPathInfo = cgi_parameter("PATH_INFO",0);
954
+#ifdef _WIN32
955
+ const char *zServerSoftware = cgi_parameter("SERVER_SOFTWARE",0);
956
+#endif
954957
955958
#ifdef FOSSIL_ENABLE_JSON
956959
json_main_bootstrap();
957960
#endif
958961
g.isHTTP = 1;
959962
cgi_destination(CGI_BODY);
960963
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
961978
if( zRequestUri==0 ){
962979
const char *z = zPathInfo;
963980
if( zPathInfo==0 ){
964981
malformed_request("missing PATH_INFO and/or REQUEST_URI");
965982
}
966983
--- 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

Keyboard Shortcuts

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