Fossil SCM

Use the SCRIPT_NAME environment variable rather than REQUEST_URI to find the base name of the CGI script.

drh 2008-05-13 00:19 trunk
Commit c23469468bc6a8a47bb33bb94e61dcaa5058d3d9
1 file changed +4 -15
+4 -15
--- src/main.c
+++ src/main.c
@@ -427,25 +427,14 @@
427427
*/
428428
void set_base_url(void){
429429
int i;
430430
const char *zHost = PD("HTTP_HOST","");
431431
const char *zMode = PD("HTTPS","off");
432
- const char *zCur = PD("REQUEST_URI","/");
433
-
434
- for(i=0; zCur[i] && zCur[i]!='?' && zCur[i]!='#'; i++){}
435
- if( g.zExtra ){
436
- /* Skip to start of extra stuff, then pass over any /'s that might
437
- ** have separated the document root from the extra stuff. This
438
- ** ensures that the redirection actually redirects the root, not
439
- ** something deep down at the bottom of a URL.
440
- */
441
- i -= strlen(g.zExtra);
442
- while( i>0 && zCur[i-1]=='/' ){ i--; }
443
- }
444
- while( i>0 && zCur[i-1]!='/' ){ i--; }
445
- while( i>0 && zCur[i-1]=='/' ){ i--; }
446
-
432
+ const char *zCur = PD("SCRIPT_NAME","/");
433
+
434
+ i = strlen(zCur);
435
+ while( i>0 && zCur[i-1]=='/' ) i--;
447436
if( strcmp(zMode,"on")==0 ){
448437
g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
449438
g.zTop = &g.zBaseURL[8+strlen(zHost)];
450439
}else{
451440
g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
452441
--- src/main.c
+++ src/main.c
@@ -427,25 +427,14 @@
427 */
428 void set_base_url(void){
429 int i;
430 const char *zHost = PD("HTTP_HOST","");
431 const char *zMode = PD("HTTPS","off");
432 const char *zCur = PD("REQUEST_URI","/");
433
434 for(i=0; zCur[i] && zCur[i]!='?' && zCur[i]!='#'; i++){}
435 if( g.zExtra ){
436 /* Skip to start of extra stuff, then pass over any /'s that might
437 ** have separated the document root from the extra stuff. This
438 ** ensures that the redirection actually redirects the root, not
439 ** something deep down at the bottom of a URL.
440 */
441 i -= strlen(g.zExtra);
442 while( i>0 && zCur[i-1]=='/' ){ i--; }
443 }
444 while( i>0 && zCur[i-1]!='/' ){ i--; }
445 while( i>0 && zCur[i-1]=='/' ){ i--; }
446
447 if( strcmp(zMode,"on")==0 ){
448 g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
449 g.zTop = &g.zBaseURL[8+strlen(zHost)];
450 }else{
451 g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
452
--- src/main.c
+++ src/main.c
@@ -427,25 +427,14 @@
427 */
428 void set_base_url(void){
429 int i;
430 const char *zHost = PD("HTTP_HOST","");
431 const char *zMode = PD("HTTPS","off");
432 const char *zCur = PD("SCRIPT_NAME","/");
433
434 i = strlen(zCur);
435 while( i>0 && zCur[i-1]=='/' ) i--;
 
 
 
 
 
 
 
 
 
 
 
436 if( strcmp(zMode,"on")==0 ){
437 g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
438 g.zTop = &g.zBaseURL[8+strlen(zHost)];
439 }else{
440 g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
441

Keyboard Shortcuts

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