Fossil SCM

Always redirect to a fully qualified URL. Give the setup user an opportunity to redirecct from test_env for testing purposes.

drh 2011-03-22 18:47 trunk
Commit 63958fc5a726ba0060c09f0591279ac22a70efce
2 files changed +1 -1 +5
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -345,11 +345,11 @@
345345
char *zLocation;
346346
CGIDEBUG(("redirect to %s\n", zURL));
347347
if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){
348348
zLocation = mprintf("Location: %s\r\n", zURL);
349349
}else{
350
- zLocation = mprintf("Location: %s/%s\r\n", g.zTop, zURL);
350
+ zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
351351
}
352352
cgi_append_header(zLocation);
353353
cgi_reset_content();
354354
cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
355355
cgi_set_status(302, "Moved Temporarily");
356356
--- src/cgi.c
+++ src/cgi.c
@@ -345,11 +345,11 @@
345 char *zLocation;
346 CGIDEBUG(("redirect to %s\n", zURL));
347 if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){
348 zLocation = mprintf("Location: %s\r\n", zURL);
349 }else{
350 zLocation = mprintf("Location: %s/%s\r\n", g.zTop, zURL);
351 }
352 cgi_append_header(zLocation);
353 cgi_reset_content();
354 cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
355 cgi_set_status(302, "Moved Temporarily");
356
--- src/cgi.c
+++ src/cgi.c
@@ -345,11 +345,11 @@
345 char *zLocation;
346 CGIDEBUG(("redirect to %s\n", zURL));
347 if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){
348 zLocation = mprintf("Location: %s\r\n", zURL);
349 }else{
350 zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL);
351 }
352 cgi_append_header(zLocation);
353 cgi_reset_content();
354 cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL);
355 cgi_set_status(302, "Moved Temporarily");
356
--- src/style.c
+++ src/style.c
@@ -791,14 +791,19 @@
791791
792792
/*
793793
** WEBPAGE: test_env
794794
*/
795795
void page_test_env(void){
796
+ login_check_credentials();
796797
style_header("Environment Test");
797798
#if !defined(_WIN32)
798799
@ uid=%d(getuid()), gid=%d(getgid())<br />
799800
#endif
800801
@ g.zBaseURL = %h(g.zBaseURL)<br />
801802
@ g.zTop = %h(g.zTop)<br />
802803
cgi_print_all();
804
+ if( g.okSetup ){
805
+ const char *zRedir = P("redirect");
806
+ if( zRedir ) cgi_redirect(zRedir);
807
+ }
803808
style_footer();
804809
}
805810
--- src/style.c
+++ src/style.c
@@ -791,14 +791,19 @@
791
792 /*
793 ** WEBPAGE: test_env
794 */
795 void page_test_env(void){
 
796 style_header("Environment Test");
797 #if !defined(_WIN32)
798 @ uid=%d(getuid()), gid=%d(getgid())<br />
799 #endif
800 @ g.zBaseURL = %h(g.zBaseURL)<br />
801 @ g.zTop = %h(g.zTop)<br />
802 cgi_print_all();
 
 
 
 
803 style_footer();
804 }
805
--- src/style.c
+++ src/style.c
@@ -791,14 +791,19 @@
791
792 /*
793 ** WEBPAGE: test_env
794 */
795 void page_test_env(void){
796 login_check_credentials();
797 style_header("Environment Test");
798 #if !defined(_WIN32)
799 @ uid=%d(getuid()), gid=%d(getgid())<br />
800 #endif
801 @ g.zBaseURL = %h(g.zBaseURL)<br />
802 @ g.zTop = %h(g.zTop)<br />
803 cgi_print_all();
804 if( g.okSetup ){
805 const char *zRedir = P("redirect");
806 if( zRedir ) cgi_redirect(zRedir);
807 }
808 style_footer();
809 }
810

Keyboard Shortcuts

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