Fossil SCM

Alternative to [7063f8d4cc]. Skips initial directory portion of PATH_INFO when building the g.zBaseURL and g.zTop used with a directory of repositories.

mistachkin 2016-02-02 04:18 trunk
Commit 7d5307b44fb4a1193bb61c42d5cc01a9e730ea2f
1 file changed +16 -3
+16 -3
--- src/main.c
+++ src/main.c
@@ -1593,10 +1593,11 @@
15931593
const char *zNotFound, /* Redirect here on a 404 if not NULL */
15941594
Glob *pFileGlob, /* Deliver static files matching */
15951595
int allowRepoList /* Send repo list for "/" URL */
15961596
){
15971597
const char *zPathInfo;
1598
+ const char *zDirPathInfo;
15981599
char *zPath = NULL;
15991600
int idx;
16001601
int i;
16011602
16021603
/* Handle universal query parameters */
@@ -1607,11 +1608,21 @@
16071608
}
16081609
16091610
/* If the repository has not been opened already, then find the
16101611
** repository based on the first element of PATH_INFO and open it.
16111612
*/
1612
- zPathInfo = PD("PATH_INFO","");
1613
+ zDirPathInfo = zPathInfo = PD("PATH_INFO","");
1614
+ /* For the PATH_INFO that will be used to help build the final
1615
+ ** g.zBaseURL and g.zTop (only), skip over the initial directory
1616
+ ** portion of PATH_INFO; otherwise, it may be duplicated.
1617
+ */
1618
+ if( g.zTop ){
1619
+ int nTop = strlen(g.zTop);
1620
+ if ( strncmp(zDirPathInfo, g.zTop, nTop)==0 ){
1621
+ zDirPathInfo += nTop;
1622
+ }
1623
+ }
16131624
if( !g.repositoryOpen ){
16141625
char *zRepo, *zToFree;
16151626
const char *zOldScript = PD("SCRIPT_NAME", "");
16161627
char *zNewScript;
16171628
int j, k;
@@ -1645,12 +1656,14 @@
16451656
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
16461657
szFile = file_size(zRepo);
16471658
/* this should only be set from the --baseurl option, not CGI */
16481659
if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
16491660
file_isdir(g.zRepositoryName)==1 ){
1650
- g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1651
- g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1661
+ if( zPathInfo==zDirPathInfo ){
1662
+ g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1663
+ g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1664
+ }
16521665
}
16531666
}
16541667
if( szFile<0 && i>0 ){
16551668
const char *zMimetype;
16561669
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
16571670
--- src/main.c
+++ src/main.c
@@ -1593,10 +1593,11 @@
1593 const char *zNotFound, /* Redirect here on a 404 if not NULL */
1594 Glob *pFileGlob, /* Deliver static files matching */
1595 int allowRepoList /* Send repo list for "/" URL */
1596 ){
1597 const char *zPathInfo;
 
1598 char *zPath = NULL;
1599 int idx;
1600 int i;
1601
1602 /* Handle universal query parameters */
@@ -1607,11 +1608,21 @@
1607 }
1608
1609 /* If the repository has not been opened already, then find the
1610 ** repository based on the first element of PATH_INFO and open it.
1611 */
1612 zPathInfo = PD("PATH_INFO","");
 
 
 
 
 
 
 
 
 
 
1613 if( !g.repositoryOpen ){
1614 char *zRepo, *zToFree;
1615 const char *zOldScript = PD("SCRIPT_NAME", "");
1616 char *zNewScript;
1617 int j, k;
@@ -1645,12 +1656,14 @@
1645 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1646 szFile = file_size(zRepo);
1647 /* this should only be set from the --baseurl option, not CGI */
1648 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1649 file_isdir(g.zRepositoryName)==1 ){
1650 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1651 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
 
 
1652 }
1653 }
1654 if( szFile<0 && i>0 ){
1655 const char *zMimetype;
1656 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1657
--- src/main.c
+++ src/main.c
@@ -1593,10 +1593,11 @@
1593 const char *zNotFound, /* Redirect here on a 404 if not NULL */
1594 Glob *pFileGlob, /* Deliver static files matching */
1595 int allowRepoList /* Send repo list for "/" URL */
1596 ){
1597 const char *zPathInfo;
1598 const char *zDirPathInfo;
1599 char *zPath = NULL;
1600 int idx;
1601 int i;
1602
1603 /* Handle universal query parameters */
@@ -1607,11 +1608,21 @@
1608 }
1609
1610 /* If the repository has not been opened already, then find the
1611 ** repository based on the first element of PATH_INFO and open it.
1612 */
1613 zDirPathInfo = zPathInfo = PD("PATH_INFO","");
1614 /* For the PATH_INFO that will be used to help build the final
1615 ** g.zBaseURL and g.zTop (only), skip over the initial directory
1616 ** portion of PATH_INFO; otherwise, it may be duplicated.
1617 */
1618 if( g.zTop ){
1619 int nTop = strlen(g.zTop);
1620 if ( strncmp(zDirPathInfo, g.zTop, nTop)==0 ){
1621 zDirPathInfo += nTop;
1622 }
1623 }
1624 if( !g.repositoryOpen ){
1625 char *zRepo, *zToFree;
1626 const char *zOldScript = PD("SCRIPT_NAME", "");
1627 char *zNewScript;
1628 int j, k;
@@ -1645,12 +1656,14 @@
1656 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1657 szFile = file_size(zRepo);
1658 /* this should only be set from the --baseurl option, not CGI */
1659 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1660 file_isdir(g.zRepositoryName)==1 ){
1661 if( zPathInfo==zDirPathInfo ){
1662 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1663 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1664 }
1665 }
1666 }
1667 if( szFile<0 && i>0 ){
1668 const char *zMimetype;
1669 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1670

Keyboard Shortcuts

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