Fossil SCM
When accessing using /draftN or /skn_X URL extensions, omit those extensions from the zBaseURL that is recorded in the config table.
Commit
acb4397ee5d5dabde81c5782436ab59ee184ec4dca5ebb50c5ba8199cdf41b54
Parent
7b00defa9d7dd32…
1 file changed
+12
-3
+12
-3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -183,10 +183,11 @@ | ||
| 183 | 183 | char *zPath; /* Name of webpage being served */ |
| 184 | 184 | char *zExtra; /* Extra path information past the webpage name */ |
| 185 | 185 | char *zBaseURL; /* Full text of the URL being served */ |
| 186 | 186 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 187 | 187 | char *zTop; /* Parent directory of zPath */ |
| 188 | + int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ | |
| 188 | 189 | const char *zExtRoot; /* Document root for the /ext sub-website */ |
| 189 | 190 | const char *zContentType; /* The content type of the input HTTP request */ |
| 190 | 191 | int iErrPriority; /* Priority of current error message */ |
| 191 | 192 | char *zErrMsg; /* Text of an error message */ |
| 192 | 193 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1382,21 +1383,27 @@ | ||
| 1382 | 1383 | g.zTop = &g.zBaseURL[7+strlen(zHost)]; |
| 1383 | 1384 | g.zHttpsURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 1384 | 1385 | } |
| 1385 | 1386 | } |
| 1386 | 1387 | if( db_is_writeable("repository") ){ |
| 1388 | + int nBase = (int)strlen(g.zBaseURL); | |
| 1389 | + char *zBase = g.zBaseURL; | |
| 1390 | + if( g.nExtraURL>0 && g.nExtraURL<nBase-6 ){ | |
| 1391 | + zBase = fossil_strndup(g.zBaseURL, nBase - g.nExtraURL); | |
| 1392 | + } | |
| 1387 | 1393 | db_unprotect(PROTECT_CONFIG); |
| 1388 | - if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", g.zBaseURL)){ | |
| 1394 | + if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", zBase)){ | |
| 1389 | 1395 | db_multi_exec("INSERT INTO config(name,value,mtime)" |
| 1390 | - "VALUES('baseurl:%q',1,now())", g.zBaseURL); | |
| 1396 | + "VALUES('baseurl:%q',1,now())", zBase); | |
| 1391 | 1397 | }else{ |
| 1392 | 1398 | db_optional_sql("repository", |
| 1393 | 1399 | "REPLACE INTO config(name,value,mtime)" |
| 1394 | - "VALUES('baseurl:%q',1,now())", g.zBaseURL | |
| 1400 | + "VALUES('baseurl:%q',1,now())", zBase | |
| 1395 | 1401 | ); |
| 1396 | 1402 | } |
| 1397 | 1403 | db_protect_pop(); |
| 1404 | + if( zBase!=g.zBaseURL ) fossil_free(zBase); | |
| 1398 | 1405 | } |
| 1399 | 1406 | } |
| 1400 | 1407 | |
| 1401 | 1408 | /* |
| 1402 | 1409 | ** Send an HTTP redirect back to the designated Index Page. |
| @@ -1818,10 +1825,11 @@ | ||
| 1818 | 1825 | skin_use_draft(iSkin); |
| 1819 | 1826 | zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin); |
| 1820 | 1827 | if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin); |
| 1821 | 1828 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin); |
| 1822 | 1829 | zPathInfo += 7; |
| 1830 | + g.nExtraURL += 7; | |
| 1823 | 1831 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1824 | 1832 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1825 | 1833 | etag_cancel(); |
| 1826 | 1834 | }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){ |
| 1827 | 1835 | int i; |
| @@ -1838,10 +1846,11 @@ | ||
| 1838 | 1846 | char *zNewScript; |
| 1839 | 1847 | zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt); |
| 1840 | 1848 | if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt); |
| 1841 | 1849 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt); |
| 1842 | 1850 | zPathInfo += i; |
| 1851 | + g.nExtraURL += i; | |
| 1843 | 1852 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1844 | 1853 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1845 | 1854 | } |
| 1846 | 1855 | fossil_free(zAlt); |
| 1847 | 1856 | } |
| 1848 | 1857 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -183,10 +183,11 @@ | |
| 183 | char *zPath; /* Name of webpage being served */ |
| 184 | char *zExtra; /* Extra path information past the webpage name */ |
| 185 | char *zBaseURL; /* Full text of the URL being served */ |
| 186 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 187 | char *zTop; /* Parent directory of zPath */ |
| 188 | const char *zExtRoot; /* Document root for the /ext sub-website */ |
| 189 | const char *zContentType; /* The content type of the input HTTP request */ |
| 190 | int iErrPriority; /* Priority of current error message */ |
| 191 | char *zErrMsg; /* Text of an error message */ |
| 192 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1382,21 +1383,27 @@ | |
| 1382 | g.zTop = &g.zBaseURL[7+strlen(zHost)]; |
| 1383 | g.zHttpsURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 1384 | } |
| 1385 | } |
| 1386 | if( db_is_writeable("repository") ){ |
| 1387 | db_unprotect(PROTECT_CONFIG); |
| 1388 | if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", g.zBaseURL)){ |
| 1389 | db_multi_exec("INSERT INTO config(name,value,mtime)" |
| 1390 | "VALUES('baseurl:%q',1,now())", g.zBaseURL); |
| 1391 | }else{ |
| 1392 | db_optional_sql("repository", |
| 1393 | "REPLACE INTO config(name,value,mtime)" |
| 1394 | "VALUES('baseurl:%q',1,now())", g.zBaseURL |
| 1395 | ); |
| 1396 | } |
| 1397 | db_protect_pop(); |
| 1398 | } |
| 1399 | } |
| 1400 | |
| 1401 | /* |
| 1402 | ** Send an HTTP redirect back to the designated Index Page. |
| @@ -1818,10 +1825,11 @@ | |
| 1818 | skin_use_draft(iSkin); |
| 1819 | zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin); |
| 1820 | if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin); |
| 1821 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin); |
| 1822 | zPathInfo += 7; |
| 1823 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1824 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1825 | etag_cancel(); |
| 1826 | }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){ |
| 1827 | int i; |
| @@ -1838,10 +1846,11 @@ | |
| 1838 | char *zNewScript; |
| 1839 | zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt); |
| 1840 | if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt); |
| 1841 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt); |
| 1842 | zPathInfo += i; |
| 1843 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1844 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1845 | } |
| 1846 | fossil_free(zAlt); |
| 1847 | } |
| 1848 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -183,10 +183,11 @@ | |
| 183 | char *zPath; /* Name of webpage being served */ |
| 184 | char *zExtra; /* Extra path information past the webpage name */ |
| 185 | char *zBaseURL; /* Full text of the URL being served */ |
| 186 | char *zHttpsURL; /* zBaseURL translated to https: */ |
| 187 | char *zTop; /* Parent directory of zPath */ |
| 188 | int nExtraURL; /* Extra bytes added to SCRIPT_NAME */ |
| 189 | const char *zExtRoot; /* Document root for the /ext sub-website */ |
| 190 | const char *zContentType; /* The content type of the input HTTP request */ |
| 191 | int iErrPriority; /* Priority of current error message */ |
| 192 | char *zErrMsg; /* Text of an error message */ |
| 193 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1382,21 +1383,27 @@ | |
| 1383 | g.zTop = &g.zBaseURL[7+strlen(zHost)]; |
| 1384 | g.zHttpsURL = mprintf("https://%s%.*s", zHost, i, zCur); |
| 1385 | } |
| 1386 | } |
| 1387 | if( db_is_writeable("repository") ){ |
| 1388 | int nBase = (int)strlen(g.zBaseURL); |
| 1389 | char *zBase = g.zBaseURL; |
| 1390 | if( g.nExtraURL>0 && g.nExtraURL<nBase-6 ){ |
| 1391 | zBase = fossil_strndup(g.zBaseURL, nBase - g.nExtraURL); |
| 1392 | } |
| 1393 | db_unprotect(PROTECT_CONFIG); |
| 1394 | if( !db_exists("SELECT 1 FROM config WHERE name='baseurl:%q'", zBase)){ |
| 1395 | db_multi_exec("INSERT INTO config(name,value,mtime)" |
| 1396 | "VALUES('baseurl:%q',1,now())", zBase); |
| 1397 | }else{ |
| 1398 | db_optional_sql("repository", |
| 1399 | "REPLACE INTO config(name,value,mtime)" |
| 1400 | "VALUES('baseurl:%q',1,now())", zBase |
| 1401 | ); |
| 1402 | } |
| 1403 | db_protect_pop(); |
| 1404 | if( zBase!=g.zBaseURL ) fossil_free(zBase); |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | /* |
| 1409 | ** Send an HTTP redirect back to the designated Index Page. |
| @@ -1818,10 +1825,11 @@ | |
| 1825 | skin_use_draft(iSkin); |
| 1826 | zNewScript = mprintf("%T/draft%d", P("SCRIPT_NAME"), iSkin); |
| 1827 | if( g.zTop ) g.zTop = mprintf("%R/draft%d", iSkin); |
| 1828 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/draft%d", g.zBaseURL, iSkin); |
| 1829 | zPathInfo += 7; |
| 1830 | g.nExtraURL += 7; |
| 1831 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1832 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1833 | etag_cancel(); |
| 1834 | }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){ |
| 1835 | int i; |
| @@ -1838,10 +1846,11 @@ | |
| 1846 | char *zNewScript; |
| 1847 | zNewScript = mprintf("%T/skn_%s", P("SCRIPT_NAME"), zAlt); |
| 1848 | if( g.zTop ) g.zTop = mprintf("%R/skn_%s", zAlt); |
| 1849 | if( g.zBaseURL ) g.zBaseURL = mprintf("%s/skn_%s", g.zBaseURL, zAlt); |
| 1850 | zPathInfo += i; |
| 1851 | g.nExtraURL += i; |
| 1852 | cgi_replace_parameter("PATH_INFO", zPathInfo); |
| 1853 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1854 | } |
| 1855 | fossil_free(zAlt); |
| 1856 | } |
| 1857 |