Check-in [f66089ec43]
Not logged in
Overview

SHA1 Hash:f66089ec43a9dd200b3c7d20d27ab8d5876073f3
Date: 2007-10-23 18:04:19
User: drh
Comment:Untested, experimental patch for correct redirect to the /index page when only the CGI script name is specified.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/cgi.c from [fa39badf00] to [36809061c4].

@@ -295,13 +295,14 @@
 */
 void cgi_redirect(const char *zURL){
   char *zLocation;
   CGIDEBUG(("redirect to %s\n", zURL));
   if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){
-    cgi_panic("invalid redirect URL: %s", zURL);
-  }
-  zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
+    zLocation = mprintf("Location: %s\r\n", zURL);
+  }else{
+    zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
+  }
   cgi_append_header(zLocation);
   cgi_reset_content();
   cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
   cgi_set_status(302, "Moved Temporarily");
   free(zLocation);

Modified src/main.c from [d1ff45663d] to [5992525fce].

@@ -466,18 +466,14 @@
   ** page.
   */
   zPathInfo = P("PATH_INFO");
   if( zPathInfo==0 || zPathInfo[0]==0 ){
     const char *zUri;
-    char *zBase;
     zUri = PD("REQUEST_URI","/");
     for(i=0; zUri[i] && zUri[i]!='?' && zUri[i]!='#'; i++){}
     for(j=i; j>0 && zUri[j-1]!='/'; j--){}
-    zBase = mprintf("%.*s/index", i-j, &zUri[j]);
-    cgi_redirect(zBase);
-    cgi_reply();
-    return;
+    cgi_redirectf("%.*s/index", i, zUri);
   }else{
     zPath = mprintf("%s", zPathInfo);
   }
 
   /* Remove the leading "/" at the beginning of the path.