Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | When accessing using /draftN or /skn_X URL extensions, omit those extensions from the zBaseURL that is recorded in the config table. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
acb4397ee5d5dabde81c5782436ab59e |
| User & Date: | drh 2021-02-08 18:51:56.340 |
Context
|
2021-02-08
| ||
| 21:02 | Fix the "redirect: * URL" mechanism of CGI scripts. ... (check-in: dd6b2987cd user: drh tags: trunk) | |
| 18:51 | When accessing using /draftN or /skn_X URL extensions, omit those extensions from the zBaseURL that is recorded in the config table. ... (check-in: acb4397ee5 user: drh tags: trunk) | |
| 17:29 | Enhance the /cookies webpage to show all cookies and give the user an opportunity to delete them. ... (check-in: 7b00defa9d user: drh tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
181 182 183 184 185 186 187 188 189 190 191 192 193 194 | int fNoSync; /* Do not do an autosync ever. --nosync */ int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ char *zPath; /* Name of webpage being served */ char *zExtra; /* Extra path information past the webpage name */ char *zBaseURL; /* Full text of the URL being served */ char *zHttpsURL; /* zBaseURL translated to https: */ char *zTop; /* Parent directory of zPath */ const char *zExtRoot; /* Document root for the /ext sub-website */ const char *zContentType; /* The content type of the input HTTP request */ int iErrPriority; /* Priority of current error message */ char *zErrMsg; /* Text of an error message */ int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ Blob cgiIn; /* Input to an xfer www method */ int cgiOutput; /* 0: command-line 1: CGI. 2: after CGI */ | > | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | int fNoSync; /* Do not do an autosync ever. --nosync */ int fIPv4; /* Use only IPv4, not IPv6. --ipv4 */ char *zPath; /* Name of webpage being served */ char *zExtra; /* Extra path information past the webpage name */ char *zBaseURL; /* Full text of the URL being served */ char *zHttpsURL; /* zBaseURL translated to https: */ char *zTop; /* Parent directory of zPath */ int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ const char *zExtRoot; /* Document root for the /ext sub-website */ const char *zContentType; /* The content type of the input HTTP request */ int iErrPriority; /* Priority of current error message */ char *zErrMsg; /* Text of an error message */ int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ Blob cgiIn; /* Input to an xfer www method */ int cgiOutput; /* 0: command-line 1: CGI. 2: after CGI */ |
| ︙ | ︙ | |||
1380 1381 1382 1383 1384 1385 1386 1387 |
}else{
g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
g.zTop = &g.zBaseURL[7+strlen(zHost)];
g.zHttpsURL = mprintf("https://%s%.*s", zHost, i, zCur);
}
}
if( db_is_writeable("repository") ){
db_unprotect(PROTECT_CONFIG);
| > > > > > | | | > | 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 |
}else{
g.zBaseURL = mprintf("http://%s%.*s", zHost, i, zCur);
g.zTop = &g.zBaseURL[7+strlen(zHost)];
g.zHttpsURL = mprintf("https://%s%.*s", zHost, i, zCur);
}
}
if( db_is_writeable("repository") ){
int nBase = (int)strlen(g.zBaseURL);
char *zBase = g.zBaseURL;
if( g.nExtraURL>0 && g.nExtraURL<nBase-6 ){
zBase = fossil_strndup(g.zBaseURL, nBase - g.nExtraURL);
}
db_unprotect(PROTECT_CONFIG);
if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", zBase)){
db_multi_exec("INSERT INTO config(name,value,mtime)"
"VALUES('baseurl:%q',1,now())", zBase);
}else{
db_optional_sql("repository",
"REPLACE INTO config(name,value,mtime)"
"VALUES('baseurl:%q',1,now())", zBase
);
}
db_protect_pop();
if( zBase!=g.zBaseURL ) fossil_free(zBase);
}
}
/*
** Send an HTTP redirect back to the designated Index Page.
*/
NORETURN void fossil_redirect_home(void){
|
| ︙ | ︙ | |||
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 |
int iSkin = zPathInfo[6] - '0';
char *zNewScript;
skin_use_draft(iSkin);
zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin);
if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin);
if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
zPathInfo += 7;
cgi_replace_parameter("PATH_INFO", zPathInfo);
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
etag_cancel();
}else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
int i;
char *zAlt;
char *zErr;
char *z;
while( (z = strstr(zPathInfo+1,"/skn_"))!=0 ) zPathInfo = z;
for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
zAlt = mprintf("%.*s", i-5, zPathInfo+5);
zErr = skin_use_alternative(zAlt);
if( zErr ){
fossil_free(zErr);
}else{
char *zNewScript;
zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt);
if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt);
if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt);
zPathInfo += i;
cgi_replace_parameter("PATH_INFO", zPathInfo);
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
}
fossil_free(zAlt);
}
/* If the content type is application/x-fossil or
| > > | 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
int iSkin = zPathInfo[6] - '0';
char *zNewScript;
skin_use_draft(iSkin);
zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin);
if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin);
if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin);
zPathInfo += 7;
g.nExtraURL += 7;
cgi_replace_parameter("PATH_INFO", zPathInfo);
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
etag_cancel();
}else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
int i;
char *zAlt;
char *zErr;
char *z;
while( (z = strstr(zPathInfo+1,"/skn_"))!=0 ) zPathInfo = z;
for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
zAlt = mprintf("%.*s", i-5, zPathInfo+5);
zErr = skin_use_alternative(zAlt);
if( zErr ){
fossil_free(zErr);
}else{
char *zNewScript;
zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt);
if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt);
if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt);
zPathInfo += i;
g.nExtraURL += i;
cgi_replace_parameter("PATH_INFO", zPathInfo);
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
}
fossil_free(zAlt);
}
/* If the content type is application/x-fossil or
|
| ︙ | ︙ |