Fossil SCM
Always redirect to a fully qualified URL. Give the setup user an opportunity to redirecct from test_env for testing purposes.
Commit
63958fc5a726ba0060c09f0591279ac22a70efce
Parent
be0e8041307397b…
2 files changed
+1
-1
+5
+1
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -345,11 +345,11 @@ | ||
| 345 | 345 | char *zLocation; |
| 346 | 346 | CGIDEBUG(("redirect to %s\n", zURL)); |
| 347 | 347 | if( strncmp(zURL,"http:",5)==0 || strncmp(zURL,"https:",6)==0 || *zURL=='/' ){ |
| 348 | 348 | zLocation = mprintf("Location: %s\r\n", zURL); |
| 349 | 349 | }else{ |
| 350 | - zLocation = mprintf("Location: %s/%s\r\n", g.zTop, zURL); | |
| 350 | + zLocation = mprintf("Location: %s/%s\r\n", g.zBaseURL, zURL); | |
| 351 | 351 | } |
| 352 | 352 | cgi_append_header(zLocation); |
| 353 | 353 | cgi_reset_content(); |
| 354 | 354 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); |
| 355 | 355 | cgi_set_status(302, "Moved Temporarily"); |
| 356 | 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.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 |
+5
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -791,14 +791,19 @@ | ||
| 791 | 791 | |
| 792 | 792 | /* |
| 793 | 793 | ** WEBPAGE: test_env |
| 794 | 794 | */ |
| 795 | 795 | void page_test_env(void){ |
| 796 | + login_check_credentials(); | |
| 796 | 797 | style_header("Environment Test"); |
| 797 | 798 | #if !defined(_WIN32) |
| 798 | 799 | @ uid=%d(getuid()), gid=%d(getgid())<br /> |
| 799 | 800 | #endif |
| 800 | 801 | @ g.zBaseURL = %h(g.zBaseURL)<br /> |
| 801 | 802 | @ g.zTop = %h(g.zTop)<br /> |
| 802 | 803 | cgi_print_all(); |
| 804 | + if( g.okSetup ){ | |
| 805 | + const char *zRedir = P("redirect"); | |
| 806 | + if( zRedir ) cgi_redirect(zRedir); | |
| 807 | + } | |
| 803 | 808 | style_footer(); |
| 804 | 809 | } |
| 805 | 810 |
| --- 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 |