Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enhancements to the redirector so that it accepts the redirect value as the $PATH_INFO and so that it can redirect to a relative URL. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
122a31ddfc9d405faeb2634d30eabd6a |
| User & Date: | drh 2011-03-23 19:08:08.951 |
Context
|
2011-03-24
| ||
| 01:51 | Update the built-in SQLite to the latest version from the SQLite trunk. check-in: 3d2e8b2ddf user: drh tags: trunk | |
|
2011-03-23
| ||
| 19:08 | Enhancements to the redirector so that it accepts the redirect value as the $PATH_INFO and so that it can redirect to a relative URL. check-in: 122a31ddfc user: drh tags: trunk | |
| 17:24 | Fix to the prior check-in ([a99e9c9164]) so that ticket hyperlinks are displayed correctly. check-in: 733361a55e user: drh tags: trunk | |
Changes
Changes to src/cgi.c.
| ︙ | ︙ | |||
340 341 342 343 344 345 346 |
** Do a redirect request to the URL given in the argument.
**
** The URL must be relative to the base of the fossil server.
*/
void cgi_redirect(const char *zURL){
char *zLocation;
CGIDEBUG(("redirect to %s\n", zURL));
| | > > > | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
** Do a redirect request to the URL given in the argument.
**
** The URL must be relative to the base of the fossil server.
*/
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 ){
zLocation = mprintf("Location: %s\r\n", zURL);
}else if( *zURL=='/' ){
zLocation = mprintf("Location: %.*s%s\r\n",
strlen(g.zBaseURL)-strlen(g.zTop), g.zBaseURL, 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", zLocation);
cgi_set_status(302, "Moved Temporarily");
free(zLocation);
cgi_reply();
fossil_exit(0);
}
void cgi_redirectf(const char *zFormat, ...){
va_list ap;
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
794 795 796 797 798 799 800 |
/*
** Set the g.zBaseURL value to the full URL for the toplevel of
** the fossil tree. Set g.zTop to g.zBaseURL without the
** leading "http://" and the host and port.
*/
void set_base_url(void){
int i;
| | | | > > > > | 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
/*
** Set the g.zBaseURL value to the full URL for the toplevel of
** the fossil tree. Set g.zTop to g.zBaseURL without the
** leading "http://" and the host and port.
*/
void set_base_url(void){
int i;
const char *zHost;
const char *zMode;
const char *zCur;
if( g.zBaseURL!=0 ) return;
zHost = PD("HTTP_HOST","");
zMode = PD("HTTPS","off");
zCur = PD("SCRIPT_NAME","/");
i = strlen(zCur);
while( i>0 && zCur[i-1]=='/' ) i--;
if( strcmp(zMode,"on")==0 ){
g.zBaseURL = mprintf("https://%s%.*s", zHost, i, zCur);
g.zTop = &g.zBaseURL[8+strlen(zHost)];
}else{
g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
|
| ︙ | ︙ | |||
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 |
** Then a redirect is made to URL if no match is found. Otherwise a
** very primative error message is returned.
*/
void redirect_web_page(int nRedirect, char **azRedirect){
int i; /* Loop counter */
const char *zNotFound = 0; /* Not found URL */
const char *zName = P("name");
if( zName && validate16(zName, strlen(zName)) ){
for(i=0; i<nRedirect; i++){
if( strcmp(azRedirect[i*2],"*")==0 ){
zNotFound = azRedirect[i*2+1];
continue;
}
db_open_repository(azRedirect[i*2]);
| > > > > > | 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 |
** Then a redirect is made to URL if no match is found. Otherwise a
** very primative error message is returned.
*/
void redirect_web_page(int nRedirect, char **azRedirect){
int i; /* Loop counter */
const char *zNotFound = 0; /* Not found URL */
const char *zName = P("name");
set_base_url();
if( zName==0 ){
zName = P("SCRIPT_NAME");
if( zName && zName[0]=='/' ) zName++;
}
if( zName && validate16(zName, strlen(zName)) ){
for(i=0; i<nRedirect; i++){
if( strcmp(azRedirect[i*2],"*")==0 ){
zNotFound = azRedirect[i*2+1];
continue;
}
db_open_repository(azRedirect[i*2]);
|
| ︙ | ︙ |