Fossil

Check-in [63958fc5a7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Always redirect to a fully qualified URL. Give the setup user an opportunity to redirecct from test_env for testing purposes.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 63958fc5a726ba0060c09f0591279ac22a70efce
User & Date: drh 2011-03-22 18:47:55.866
Context
2011-03-23
11:25
fix [1ee813d6] -- do not autocommit on wiki commit from cmdline ... (check-in: e1d91b9477 user: ron tags: trunk)
2011-03-22
18:47
Always redirect to a fully qualified URL. Give the setup user an opportunity to redirecct from test_env for testing purposes. ... (check-in: 63958fc5a7 user: drh tags: trunk)
17:00
Add the https-login setting which forces a switch to HTTPS for any non-anonymous login. ... (check-in: be0e804130 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/cgi.c.
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
*/
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=='/' ){
    zLocation = mprintf("Location: %s\r\n", zURL);
  }else{
    zLocation = mprintf("Location: %s/%s\r\n", g.zTop, 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);
  cgi_reply();







|







343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
*/
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=='/' ){
    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);
  cgi_reply();
Changes to src/style.c.
789
790
791
792
793
794
795

796
797
798
799
800
801
802




803
804
  g.isConst = 1;
}

/*
** WEBPAGE: test_env
*/
void page_test_env(void){

  style_header("Environment Test");
#if !defined(_WIN32)
  @ uid=%d(getuid()), gid=%d(getgid())<br />
#endif
  @ g.zBaseURL = %h(g.zBaseURL)<br />
  @ g.zTop = %h(g.zTop)<br />
  cgi_print_all();




  style_footer();
}







>







>
>
>
>


789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
  g.isConst = 1;
}

/*
** WEBPAGE: test_env
*/
void page_test_env(void){
  login_check_credentials();
  style_header("Environment Test");
#if !defined(_WIN32)
  @ uid=%d(getuid()), gid=%d(getgid())<br />
#endif
  @ g.zBaseURL = %h(g.zBaseURL)<br />
  @ g.zTop = %h(g.zTop)<br />
  cgi_print_all();
  if( g.okSetup ){
    const char *zRedir = P("redirect");
    if( zRedir ) cgi_redirect(zRedir);
  }
  style_footer();
}