Fossil SCM
Fix issue where the --baseurl was interacting with directory-full-of- repositories mode badly and producing incorrect URLs.
Commit
fb80037e2652626f44f41b70453d48f746294b35
Parent
3f43ab397e289dc…
1 file changed
+25
-16
+25
-16
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -135,10 +135,11 @@ | ||
| 135 | 135 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 136 | 136 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 137 | 137 | char *zPath; /* Name of webpage being served */ |
| 138 | 138 | char *zExtra; /* Extra path information past the webpage name */ |
| 139 | 139 | char *zBaseURL; /* Full text of the URL being served */ |
| 140 | + const char *zAltBase; /* Alternative URL root. --baseurl */ | |
| 140 | 141 | char *zTop; /* Parent directory of zPath */ |
| 141 | 142 | const char *zContentType; /* The content type of the input HTTP request */ |
| 142 | 143 | int iErrPriority; /* Priority of current error message */ |
| 143 | 144 | char *zErrMsg; /* Text of an error message */ |
| 144 | 145 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1116,24 +1117,30 @@ | ||
| 1116 | 1117 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 1117 | 1118 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 1118 | 1119 | ** leading "http://" and the host and port. |
| 1119 | 1120 | ** |
| 1120 | 1121 | ** The g.zBaseURL is normally set based on HTTP_HOST and SCRIPT_NAME |
| 1121 | -** environment variables. However, if zAltBase is not NULL then it | |
| 1122 | +** environment variables. However, if g.zAltBase is not NULL then it | |
| 1122 | 1123 | ** is the argument to the --baseurl option command-line option and |
| 1123 | 1124 | ** g.zBaseURL and g.zTop is set from that instead. |
| 1125 | +** | |
| 1126 | +** If g.zAltBase is set, then zRepoName may be a repository name (with a | |
| 1127 | +** leading slash ** but without the .fossil) with is concatenated to the | |
| 1128 | +** root. | |
| 1124 | 1129 | */ |
| 1125 | -static void set_base_url(const char *zAltBase){ | |
| 1130 | +static void set_base_url(const char* zRepoName){ | |
| 1126 | 1131 | int i; |
| 1127 | 1132 | const char *zHost; |
| 1128 | 1133 | const char *zMode; |
| 1129 | 1134 | const char *zCur; |
| 1130 | 1135 | |
| 1131 | - if( g.zBaseURL!=0 ) return; | |
| 1132 | - if( zAltBase ){ | |
| 1136 | + fossil_free(g.zBaseURL); | |
| 1137 | + if( g.zAltBase ){ | |
| 1133 | 1138 | int i, n, c; |
| 1134 | - g.zTop = g.zBaseURL = mprintf("%s", zAltBase); | |
| 1139 | + if (!zRepoName) zRepoName = ""; | |
| 1140 | + if (zRepoName[0] == '/') zRepoName++; | |
| 1141 | + g.zTop = g.zBaseURL = mprintf("%s%s", g.zAltBase, zRepoName); | |
| 1135 | 1142 | if( memcmp(g.zTop, "http://", 7)!=0 && memcmp(g.zTop,"https://",8)!=0 ){ |
| 1136 | 1143 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1137 | 1144 | " or 'https://host/path'"); |
| 1138 | 1145 | } |
| 1139 | 1146 | for(i=n=0; (c = g.zTop[i])!=0; i++){ |
| @@ -1273,10 +1280,11 @@ | ||
| 1273 | 1280 | zPathInfo = PD("PATH_INFO",""); |
| 1274 | 1281 | if( !g.repositoryOpen ){ |
| 1275 | 1282 | char *zRepo, *zToFree; |
| 1276 | 1283 | const char *zOldScript = PD("SCRIPT_NAME", ""); |
| 1277 | 1284 | char *zNewScript; |
| 1285 | + char *zRepoName; | |
| 1278 | 1286 | int j, k; |
| 1279 | 1287 | i64 szFile; |
| 1280 | 1288 | |
| 1281 | 1289 | i = zPathInfo[0]!=0; |
| 1282 | 1290 | while( 1 ){ |
| @@ -1349,10 +1357,14 @@ | ||
| 1349 | 1357 | } |
| 1350 | 1358 | return; |
| 1351 | 1359 | } |
| 1352 | 1360 | break; |
| 1353 | 1361 | } |
| 1362 | + /* Rebuild the base URL to add the repository name to the end. */ | |
| 1363 | + zRepoName = mprintf("%.*s", i, zPathInfo); | |
| 1364 | + set_base_url(zRepoName); | |
| 1365 | + fossil_free(zRepoName); | |
| 1354 | 1366 | zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo); |
| 1355 | 1367 | cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]); |
| 1356 | 1368 | zPathInfo += i; |
| 1357 | 1369 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1358 | 1370 | db_open_repository(zRepo); |
| @@ -1362,18 +1374,19 @@ | ||
| 1362 | 1374 | "# new PATH_INFO = [%s]\n" |
| 1363 | 1375 | "# new SCRIPT_NAME = [%s]\n", |
| 1364 | 1376 | zRepo, zPathInfo, zNewScript); |
| 1365 | 1377 | } |
| 1366 | 1378 | } |
| 1379 | + else | |
| 1380 | + set_base_url(0); | |
| 1367 | 1381 | |
| 1368 | 1382 | /* Find the page that the user has requested, construct and deliver that |
| 1369 | 1383 | ** page. |
| 1370 | 1384 | */ |
| 1371 | 1385 | if( g.zContentType && memcmp(g.zContentType, "application/x-fossil", 20)==0 ){ |
| 1372 | 1386 | zPathInfo = "/xfer"; |
| 1373 | 1387 | } |
| 1374 | - set_base_url(0); | |
| 1375 | 1388 | if( zPathInfo==0 || zPathInfo[0]==0 |
| 1376 | 1389 | || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){ |
| 1377 | 1390 | #ifdef FOSSIL_ENABLE_JSON |
| 1378 | 1391 | if(g.json.isJsonMode){ |
| 1379 | 1392 | json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1); |
| @@ -1740,11 +1753,10 @@ | ||
| 1740 | 1753 | */ |
| 1741 | 1754 | void cmd_http(void){ |
| 1742 | 1755 | const char *zIpAddr; |
| 1743 | 1756 | const char *zNotFound; |
| 1744 | 1757 | const char *zHost; |
| 1745 | - const char *zAltBase; | |
| 1746 | 1758 | const char *zFileGlob; |
| 1747 | 1759 | |
| 1748 | 1760 | /* The winhttp module passes the --files option as --files-urlenc with |
| 1749 | 1761 | ** the argument being URL encoded, to avoid wildcard expansion in the |
| 1750 | 1762 | ** shell. This option is for internal use and is undocumented. |
| @@ -1758,27 +1770,27 @@ | ||
| 1758 | 1770 | zFileGlob = find_option("files",0,1); |
| 1759 | 1771 | } |
| 1760 | 1772 | zNotFound = find_option("notfound", 0, 1); |
| 1761 | 1773 | g.useLocalauth = find_option("localauth", 0, 0)!=0; |
| 1762 | 1774 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0; |
| 1763 | - zAltBase = find_option("baseurl", 0, 1); | |
| 1764 | - if( zAltBase ) set_base_url(zAltBase); | |
| 1775 | + g.zAltBase = find_option("baseurl", 0, 1); | |
| 1776 | + set_base_url(0); | |
| 1765 | 1777 | if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on"); |
| 1766 | 1778 | zHost = find_option("host", 0, 1); |
| 1767 | 1779 | if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost); |
| 1768 | 1780 | g.cgiOutput = 1; |
| 1781 | + g.httpIn = stdin; | |
| 1782 | + g.httpOut = stdout; | |
| 1769 | 1783 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 1770 | 1784 | fossil_fatal("no repository specified"); |
| 1771 | 1785 | } |
| 1772 | 1786 | g.fullHttpReply = 1; |
| 1773 | 1787 | if( g.argc==6 ){ |
| 1774 | 1788 | g.httpIn = fossil_fopen(g.argv[3], "rb"); |
| 1775 | 1789 | g.httpOut = fossil_fopen(g.argv[4], "wb"); |
| 1776 | 1790 | zIpAddr = g.argv[5]; |
| 1777 | 1791 | }else{ |
| 1778 | - g.httpIn = stdin; | |
| 1779 | - g.httpOut = stdout; | |
| 1780 | 1792 | zIpAddr = 0; |
| 1781 | 1793 | } |
| 1782 | 1794 | find_server_repository(0); |
| 1783 | 1795 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1784 | 1796 | cgi_handle_http_request(zIpAddr); |
| @@ -1888,11 +1900,10 @@ | ||
| 1888 | 1900 | const char *zBrowser; /* Name of web browser program */ |
| 1889 | 1901 | char *zBrowserCmd = 0; /* Command to launch the web browser */ |
| 1890 | 1902 | int isUiCmd; /* True if command is "ui", not "server' */ |
| 1891 | 1903 | const char *zNotFound; /* The --notfound option or NULL */ |
| 1892 | 1904 | int flags = 0; /* Server flags */ |
| 1893 | - const char *zAltBase; /* Argument to the --baseurl option */ | |
| 1894 | 1905 | const char *zFileGlob; /* Static content must match this */ |
| 1895 | 1906 | |
| 1896 | 1907 | #if defined(_WIN32) |
| 1897 | 1908 | const char *zStopperFile; /* Name of file used to terminate server */ |
| 1898 | 1909 | zStopperFile = find_option("stopper", 0, 1); |
| @@ -1904,14 +1915,12 @@ | ||
| 1904 | 1915 | if( g.thTrace ){ |
| 1905 | 1916 | blob_zero(&g.thLog); |
| 1906 | 1917 | } |
| 1907 | 1918 | zPort = find_option("port", "P", 1); |
| 1908 | 1919 | zNotFound = find_option("notfound", 0, 1); |
| 1909 | - zAltBase = find_option("baseurl", 0, 1); | |
| 1910 | - if( zAltBase ){ | |
| 1911 | - set_base_url(zAltBase); | |
| 1912 | - } | |
| 1920 | + g.zAltBase = find_option("baseurl", 0, 1); | |
| 1921 | + set_base_url(0); | |
| 1913 | 1922 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 1914 | 1923 | isUiCmd = g.argv[1][0]=='u'; |
| 1915 | 1924 | if( isUiCmd ){ |
| 1916 | 1925 | flags |= HTTP_SERVER_LOCALHOST; |
| 1917 | 1926 | g.useLocalauth = 1; |
| 1918 | 1927 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -135,10 +135,11 @@ | |
| 135 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 136 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 137 | char *zPath; /* Name of webpage being served */ |
| 138 | char *zExtra; /* Extra path information past the webpage name */ |
| 139 | char *zBaseURL; /* Full text of the URL being served */ |
| 140 | char *zTop; /* Parent directory of zPath */ |
| 141 | const char *zContentType; /* The content type of the input HTTP request */ |
| 142 | int iErrPriority; /* Priority of current error message */ |
| 143 | char *zErrMsg; /* Text of an error message */ |
| 144 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1116,24 +1117,30 @@ | |
| 1116 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 1117 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 1118 | ** leading "http://" and the host and port. |
| 1119 | ** |
| 1120 | ** The g.zBaseURL is normally set based on HTTP_HOST and SCRIPT_NAME |
| 1121 | ** environment variables. However, if zAltBase is not NULL then it |
| 1122 | ** is the argument to the --baseurl option command-line option and |
| 1123 | ** g.zBaseURL and g.zTop is set from that instead. |
| 1124 | */ |
| 1125 | static void set_base_url(const char *zAltBase){ |
| 1126 | int i; |
| 1127 | const char *zHost; |
| 1128 | const char *zMode; |
| 1129 | const char *zCur; |
| 1130 | |
| 1131 | if( g.zBaseURL!=0 ) return; |
| 1132 | if( zAltBase ){ |
| 1133 | int i, n, c; |
| 1134 | g.zTop = g.zBaseURL = mprintf("%s", zAltBase); |
| 1135 | if( memcmp(g.zTop, "http://", 7)!=0 && memcmp(g.zTop,"https://",8)!=0 ){ |
| 1136 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1137 | " or 'https://host/path'"); |
| 1138 | } |
| 1139 | for(i=n=0; (c = g.zTop[i])!=0; i++){ |
| @@ -1273,10 +1280,11 @@ | |
| 1273 | zPathInfo = PD("PATH_INFO",""); |
| 1274 | if( !g.repositoryOpen ){ |
| 1275 | char *zRepo, *zToFree; |
| 1276 | const char *zOldScript = PD("SCRIPT_NAME", ""); |
| 1277 | char *zNewScript; |
| 1278 | int j, k; |
| 1279 | i64 szFile; |
| 1280 | |
| 1281 | i = zPathInfo[0]!=0; |
| 1282 | while( 1 ){ |
| @@ -1349,10 +1357,14 @@ | |
| 1349 | } |
| 1350 | return; |
| 1351 | } |
| 1352 | break; |
| 1353 | } |
| 1354 | zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo); |
| 1355 | cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]); |
| 1356 | zPathInfo += i; |
| 1357 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1358 | db_open_repository(zRepo); |
| @@ -1362,18 +1374,19 @@ | |
| 1362 | "# new PATH_INFO = [%s]\n" |
| 1363 | "# new SCRIPT_NAME = [%s]\n", |
| 1364 | zRepo, zPathInfo, zNewScript); |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | /* Find the page that the user has requested, construct and deliver that |
| 1369 | ** page. |
| 1370 | */ |
| 1371 | if( g.zContentType && memcmp(g.zContentType, "application/x-fossil", 20)==0 ){ |
| 1372 | zPathInfo = "/xfer"; |
| 1373 | } |
| 1374 | set_base_url(0); |
| 1375 | if( zPathInfo==0 || zPathInfo[0]==0 |
| 1376 | || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){ |
| 1377 | #ifdef FOSSIL_ENABLE_JSON |
| 1378 | if(g.json.isJsonMode){ |
| 1379 | json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1); |
| @@ -1740,11 +1753,10 @@ | |
| 1740 | */ |
| 1741 | void cmd_http(void){ |
| 1742 | const char *zIpAddr; |
| 1743 | const char *zNotFound; |
| 1744 | const char *zHost; |
| 1745 | const char *zAltBase; |
| 1746 | const char *zFileGlob; |
| 1747 | |
| 1748 | /* The winhttp module passes the --files option as --files-urlenc with |
| 1749 | ** the argument being URL encoded, to avoid wildcard expansion in the |
| 1750 | ** shell. This option is for internal use and is undocumented. |
| @@ -1758,27 +1770,27 @@ | |
| 1758 | zFileGlob = find_option("files",0,1); |
| 1759 | } |
| 1760 | zNotFound = find_option("notfound", 0, 1); |
| 1761 | g.useLocalauth = find_option("localauth", 0, 0)!=0; |
| 1762 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0; |
| 1763 | zAltBase = find_option("baseurl", 0, 1); |
| 1764 | if( zAltBase ) set_base_url(zAltBase); |
| 1765 | if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on"); |
| 1766 | zHost = find_option("host", 0, 1); |
| 1767 | if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost); |
| 1768 | g.cgiOutput = 1; |
| 1769 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 1770 | fossil_fatal("no repository specified"); |
| 1771 | } |
| 1772 | g.fullHttpReply = 1; |
| 1773 | if( g.argc==6 ){ |
| 1774 | g.httpIn = fossil_fopen(g.argv[3], "rb"); |
| 1775 | g.httpOut = fossil_fopen(g.argv[4], "wb"); |
| 1776 | zIpAddr = g.argv[5]; |
| 1777 | }else{ |
| 1778 | g.httpIn = stdin; |
| 1779 | g.httpOut = stdout; |
| 1780 | zIpAddr = 0; |
| 1781 | } |
| 1782 | find_server_repository(0); |
| 1783 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1784 | cgi_handle_http_request(zIpAddr); |
| @@ -1888,11 +1900,10 @@ | |
| 1888 | const char *zBrowser; /* Name of web browser program */ |
| 1889 | char *zBrowserCmd = 0; /* Command to launch the web browser */ |
| 1890 | int isUiCmd; /* True if command is "ui", not "server' */ |
| 1891 | const char *zNotFound; /* The --notfound option or NULL */ |
| 1892 | int flags = 0; /* Server flags */ |
| 1893 | const char *zAltBase; /* Argument to the --baseurl option */ |
| 1894 | const char *zFileGlob; /* Static content must match this */ |
| 1895 | |
| 1896 | #if defined(_WIN32) |
| 1897 | const char *zStopperFile; /* Name of file used to terminate server */ |
| 1898 | zStopperFile = find_option("stopper", 0, 1); |
| @@ -1904,14 +1915,12 @@ | |
| 1904 | if( g.thTrace ){ |
| 1905 | blob_zero(&g.thLog); |
| 1906 | } |
| 1907 | zPort = find_option("port", "P", 1); |
| 1908 | zNotFound = find_option("notfound", 0, 1); |
| 1909 | zAltBase = find_option("baseurl", 0, 1); |
| 1910 | if( zAltBase ){ |
| 1911 | set_base_url(zAltBase); |
| 1912 | } |
| 1913 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 1914 | isUiCmd = g.argv[1][0]=='u'; |
| 1915 | if( isUiCmd ){ |
| 1916 | flags |= HTTP_SERVER_LOCALHOST; |
| 1917 | g.useLocalauth = 1; |
| 1918 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -135,10 +135,11 @@ | |
| 135 | int fSshTrace; /* Trace the SSH setup traffic */ |
| 136 | int fNoSync; /* Do not do an autosync ever. --nosync */ |
| 137 | char *zPath; /* Name of webpage being served */ |
| 138 | char *zExtra; /* Extra path information past the webpage name */ |
| 139 | char *zBaseURL; /* Full text of the URL being served */ |
| 140 | const char *zAltBase; /* Alternative URL root. --baseurl */ |
| 141 | char *zTop; /* Parent directory of zPath */ |
| 142 | const char *zContentType; /* The content type of the input HTTP request */ |
| 143 | int iErrPriority; /* Priority of current error message */ |
| 144 | char *zErrMsg; /* Text of an error message */ |
| 145 | int sslNotAvailable; /* SSL is not available. Do not redirect to https: */ |
| @@ -1116,24 +1117,30 @@ | |
| 1117 | ** Set the g.zBaseURL value to the full URL for the toplevel of |
| 1118 | ** the fossil tree. Set g.zTop to g.zBaseURL without the |
| 1119 | ** leading "http://" and the host and port. |
| 1120 | ** |
| 1121 | ** The g.zBaseURL is normally set based on HTTP_HOST and SCRIPT_NAME |
| 1122 | ** environment variables. However, if g.zAltBase is not NULL then it |
| 1123 | ** is the argument to the --baseurl option command-line option and |
| 1124 | ** g.zBaseURL and g.zTop is set from that instead. |
| 1125 | ** |
| 1126 | ** If g.zAltBase is set, then zRepoName may be a repository name (with a |
| 1127 | ** leading slash ** but without the .fossil) with is concatenated to the |
| 1128 | ** root. |
| 1129 | */ |
| 1130 | static void set_base_url(const char* zRepoName){ |
| 1131 | int i; |
| 1132 | const char *zHost; |
| 1133 | const char *zMode; |
| 1134 | const char *zCur; |
| 1135 | |
| 1136 | fossil_free(g.zBaseURL); |
| 1137 | if( g.zAltBase ){ |
| 1138 | int i, n, c; |
| 1139 | if (!zRepoName) zRepoName = ""; |
| 1140 | if (zRepoName[0] == '/') zRepoName++; |
| 1141 | g.zTop = g.zBaseURL = mprintf("%s%s", g.zAltBase, zRepoName); |
| 1142 | if( memcmp(g.zTop, "http://", 7)!=0 && memcmp(g.zTop,"https://",8)!=0 ){ |
| 1143 | fossil_fatal("argument to --baseurl should be 'http://host/path'" |
| 1144 | " or 'https://host/path'"); |
| 1145 | } |
| 1146 | for(i=n=0; (c = g.zTop[i])!=0; i++){ |
| @@ -1273,10 +1280,11 @@ | |
| 1280 | zPathInfo = PD("PATH_INFO",""); |
| 1281 | if( !g.repositoryOpen ){ |
| 1282 | char *zRepo, *zToFree; |
| 1283 | const char *zOldScript = PD("SCRIPT_NAME", ""); |
| 1284 | char *zNewScript; |
| 1285 | char *zRepoName; |
| 1286 | int j, k; |
| 1287 | i64 szFile; |
| 1288 | |
| 1289 | i = zPathInfo[0]!=0; |
| 1290 | while( 1 ){ |
| @@ -1349,10 +1357,14 @@ | |
| 1357 | } |
| 1358 | return; |
| 1359 | } |
| 1360 | break; |
| 1361 | } |
| 1362 | /* Rebuild the base URL to add the repository name to the end. */ |
| 1363 | zRepoName = mprintf("%.*s", i, zPathInfo); |
| 1364 | set_base_url(zRepoName); |
| 1365 | fossil_free(zRepoName); |
| 1366 | zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo); |
| 1367 | cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]); |
| 1368 | zPathInfo += i; |
| 1369 | cgi_replace_parameter("SCRIPT_NAME", zNewScript); |
| 1370 | db_open_repository(zRepo); |
| @@ -1362,18 +1374,19 @@ | |
| 1374 | "# new PATH_INFO = [%s]\n" |
| 1375 | "# new SCRIPT_NAME = [%s]\n", |
| 1376 | zRepo, zPathInfo, zNewScript); |
| 1377 | } |
| 1378 | } |
| 1379 | else |
| 1380 | set_base_url(0); |
| 1381 | |
| 1382 | /* Find the page that the user has requested, construct and deliver that |
| 1383 | ** page. |
| 1384 | */ |
| 1385 | if( g.zContentType && memcmp(g.zContentType, "application/x-fossil", 20)==0 ){ |
| 1386 | zPathInfo = "/xfer"; |
| 1387 | } |
| 1388 | if( zPathInfo==0 || zPathInfo[0]==0 |
| 1389 | || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){ |
| 1390 | #ifdef FOSSIL_ENABLE_JSON |
| 1391 | if(g.json.isJsonMode){ |
| 1392 | json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1); |
| @@ -1740,11 +1753,10 @@ | |
| 1753 | */ |
| 1754 | void cmd_http(void){ |
| 1755 | const char *zIpAddr; |
| 1756 | const char *zNotFound; |
| 1757 | const char *zHost; |
| 1758 | const char *zFileGlob; |
| 1759 | |
| 1760 | /* The winhttp module passes the --files option as --files-urlenc with |
| 1761 | ** the argument being URL encoded, to avoid wildcard expansion in the |
| 1762 | ** shell. This option is for internal use and is undocumented. |
| @@ -1758,27 +1770,27 @@ | |
| 1770 | zFileGlob = find_option("files",0,1); |
| 1771 | } |
| 1772 | zNotFound = find_option("notfound", 0, 1); |
| 1773 | g.useLocalauth = find_option("localauth", 0, 0)!=0; |
| 1774 | g.sslNotAvailable = find_option("nossl", 0, 0)!=0; |
| 1775 | g.zAltBase = find_option("baseurl", 0, 1); |
| 1776 | set_base_url(0); |
| 1777 | if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on"); |
| 1778 | zHost = find_option("host", 0, 1); |
| 1779 | if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost); |
| 1780 | g.cgiOutput = 1; |
| 1781 | g.httpIn = stdin; |
| 1782 | g.httpOut = stdout; |
| 1783 | if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){ |
| 1784 | fossil_fatal("no repository specified"); |
| 1785 | } |
| 1786 | g.fullHttpReply = 1; |
| 1787 | if( g.argc==6 ){ |
| 1788 | g.httpIn = fossil_fopen(g.argv[3], "rb"); |
| 1789 | g.httpOut = fossil_fopen(g.argv[4], "wb"); |
| 1790 | zIpAddr = g.argv[5]; |
| 1791 | }else{ |
| 1792 | zIpAddr = 0; |
| 1793 | } |
| 1794 | find_server_repository(0); |
| 1795 | g.zRepositoryName = enter_chroot_jail(g.zRepositoryName); |
| 1796 | cgi_handle_http_request(zIpAddr); |
| @@ -1888,11 +1900,10 @@ | |
| 1900 | const char *zBrowser; /* Name of web browser program */ |
| 1901 | char *zBrowserCmd = 0; /* Command to launch the web browser */ |
| 1902 | int isUiCmd; /* True if command is "ui", not "server' */ |
| 1903 | const char *zNotFound; /* The --notfound option or NULL */ |
| 1904 | int flags = 0; /* Server flags */ |
| 1905 | const char *zFileGlob; /* Static content must match this */ |
| 1906 | |
| 1907 | #if defined(_WIN32) |
| 1908 | const char *zStopperFile; /* Name of file used to terminate server */ |
| 1909 | zStopperFile = find_option("stopper", 0, 1); |
| @@ -1904,14 +1915,12 @@ | |
| 1915 | if( g.thTrace ){ |
| 1916 | blob_zero(&g.thLog); |
| 1917 | } |
| 1918 | zPort = find_option("port", "P", 1); |
| 1919 | zNotFound = find_option("notfound", 0, 1); |
| 1920 | g.zAltBase = find_option("baseurl", 0, 1); |
| 1921 | set_base_url(0); |
| 1922 | if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?"); |
| 1923 | isUiCmd = g.argv[1][0]=='u'; |
| 1924 | if( isUiCmd ){ |
| 1925 | flags |= HTTP_SERVER_LOCALHOST; |
| 1926 | g.useLocalauth = 1; |
| 1927 |