Fossil SCM

Allow multiple layers of /skn_X skin specifications at the beginning of the PATH_INFO. Use the last one. Skip over and discard all the others.

drh 2021-01-28 01:01 trunk
Commit 5af8a1a937393c81f2b7d276fcc4264f050db69d97b95fe83910452ad3f40f6f
1 file changed +8 -1
+8 -1
--- src/main.c
+++ src/main.c
@@ -1798,11 +1798,16 @@
17981798
/*
17991799
** Check to see if the first term of PATH_INFO specifies an alternative
18001800
** skin. This will be the case if the first term of PATH_INFO
18011801
** begins with "draftN/" where N is an integer between 1 and 9 or
18021802
** if it is "skn_X/" where X is one of the built-in skin names.
1803
- ** If either is true, then activate the alternative skin.
1803
+ ** If either is true, then activate the alternative skin.a
1804
+ **
1805
+ ** If there are multiple skn_X entries (ex: /skn_default/skn_ardoise/...)
1806
+ ** then skip over all but the last. This allows one to link to an
1807
+ ** alternative skin in hyperlinks even if you are already in an alternative
1808
+ ** skin.
18041809
*/
18051810
if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
18061811
&& zPathInfo[6]>='1' && zPathInfo[6]<='9'
18071812
&& (zPathInfo[7]=='/' || zPathInfo[7]==0)
18081813
){
@@ -1818,10 +1823,12 @@
18181823
etag_cancel();
18191824
}else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
18201825
int i;
18211826
char *zAlt;
18221827
char *zErr;
1828
+ char *z;
1829
+ while( (z = strstr(zPathInfo+1,"/skn_"))!=0 ) zPathInfo = z;
18231830
for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
18241831
zAlt = mprintf("%.*s", i-5, zPathInfo+5);
18251832
zErr = skin_use_alternative(zAlt);
18261833
if( zErr ){
18271834
fossil_free(zErr);
18281835
--- src/main.c
+++ src/main.c
@@ -1798,11 +1798,16 @@
1798 /*
1799 ** Check to see if the first term of PATH_INFO specifies an alternative
1800 ** skin. This will be the case if the first term of PATH_INFO
1801 ** begins with "draftN/" where N is an integer between 1 and 9 or
1802 ** if it is "skn_X/" where X is one of the built-in skin names.
1803 ** If either is true, then activate the alternative skin.
 
 
 
 
 
1804 */
1805 if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
1806 && zPathInfo[6]>='1' && zPathInfo[6]<='9'
1807 && (zPathInfo[7]=='/' || zPathInfo[7]==0)
1808 ){
@@ -1818,10 +1823,12 @@
1818 etag_cancel();
1819 }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
1820 int i;
1821 char *zAlt;
1822 char *zErr;
 
 
1823 for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
1824 zAlt = mprintf("%.*s", i-5, zPathInfo+5);
1825 zErr = skin_use_alternative(zAlt);
1826 if( zErr ){
1827 fossil_free(zErr);
1828
--- src/main.c
+++ src/main.c
@@ -1798,11 +1798,16 @@
1798 /*
1799 ** Check to see if the first term of PATH_INFO specifies an alternative
1800 ** skin. This will be the case if the first term of PATH_INFO
1801 ** begins with "draftN/" where N is an integer between 1 and 9 or
1802 ** if it is "skn_X/" where X is one of the built-in skin names.
1803 ** If either is true, then activate the alternative skin.a
1804 **
1805 ** If there are multiple skn_X entries (ex: /skn_default/skn_ardoise/...)
1806 ** then skip over all but the last. This allows one to link to an
1807 ** alternative skin in hyperlinks even if you are already in an alternative
1808 ** skin.
1809 */
1810 if( zPathInfo && strncmp(zPathInfo,"/draft",6)==0
1811 && zPathInfo[6]>='1' && zPathInfo[6]<='9'
1812 && (zPathInfo[7]=='/' || zPathInfo[7]==0)
1813 ){
@@ -1818,10 +1823,12 @@
1823 etag_cancel();
1824 }else if( zPathInfo && strncmp(zPathInfo, "/skn_", 5)==0 ){
1825 int i;
1826 char *zAlt;
1827 char *zErr;
1828 char *z;
1829 while( (z = strstr(zPathInfo+1,"/skn_"))!=0 ) zPathInfo = z;
1830 for(i=5; zPathInfo[i] && zPathInfo[i]!='/'; i++){}
1831 zAlt = mprintf("%.*s", i-5, zPathInfo+5);
1832 zErr = skin_use_alternative(zAlt);
1833 if( zErr ){
1834 fossil_free(zErr);
1835

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button