Fossil SCM

A cleaner way of dealing with the --baseurl problem.

drh 2016-12-01 15:40 UTC all-ui
Commit 8e4b8ba0e40416d54df024226c608f14c8d5929e
1 file changed +16 -32
+16 -32
--- src/main.c
+++ src/main.c
@@ -1288,11 +1288,10 @@
12881288
const char *zNotFound, /* Redirect here on a 404 if not NULL */
12891289
Glob *pFileGlob, /* Deliver static files matching */
12901290
int allowRepoList /* Send repo list for "/" URL */
12911291
){
12921292
const char *zPathInfo = PD("PATH_INFO", "");
1293
- /* const char *zDirPathInfo; **** refactor needed */
12941293
char *zPath = NULL;
12951294
int i;
12961295
const CmdOrPage *pCmd = 0;
12971296
const char *zBase = g.zRepositoryName;
12981297
@@ -1301,23 +1300,10 @@
13011300
g.fTimeFormat = 1;
13021301
}else if( PB("localtime") ){
13031302
g.fTimeFormat = 2;
13041303
}
13051304
1306
-#if 0 /* Refactor needed */
1307
- /* For the PATH_INFO that will be used to help build the final
1308
- ** g.zBaseURL and g.zTop (only), skip over the initial directory
1309
- ** portion of PATH_INFO; otherwise, it may be duplicated.
1310
- */
1311
- if( g.zTop ){
1312
- int nTop = strlen(g.zTop);
1313
- if ( strncmp(zDirPathInfo, g.zTop, nTop)==0 ){
1314
- zDirPathInfo += nTop;
1315
- }
1316
- }
1317
-#endif
1318
-
13191305
/* If the repository has not been opened already, then find the
13201306
** repository based on the first element of PATH_INFO and open it.
13211307
*/
13221308
if( !g.repositoryOpen ){
13231309
char *zRepo; /* Candidate repository name */
@@ -1393,22 +1379,10 @@
13931379
szFile = file_size(zCleanRepo);
13941380
if( g.fHttpTrace ){
13951381
@ <!-- file_size(%h(zCleanRepo)) is %lld(szFile) -->
13961382
fprintf(stderr, "# file_size(%s) = %lld\n", zCleanRepo, szFile);
13971383
}
1398
-
1399
-#if 0
1400
- /* This logic for handling --baseurl is confused and needs to be
1401
- ** completely rethought. */
1402
- if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1403
- file_isdir(g.zRepositoryName)==1 ){
1404
- if( zPathInfo==zDirPathInfo ){
1405
- g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1406
- g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1407
- }
1408
- }
1409
-#endif
14101384
}
14111385
14121386
/* If no file named by zRepo exists, remove the added ".fossil" suffix
14131387
** and check to see if there is a file or directory with the same
14141388
** name as the raw PATH_INFO text.
@@ -1482,27 +1456,37 @@
14821456
}
14831457
break;
14841458
}
14851459
14861460
/* Add the repository name (without the ".fossil" suffix) to the end
1487
- ** of SCRIPT_NAME and remove the repository name from the beginning
1488
- ** of PATH_INFO.
1461
+ ** of SCRIPT_NAME and g.zTop and g.zBaseURL and remove the repository
1462
+ ** name from the beginning of PATH_INFO.
14891463
*/
14901464
zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo);
1465
+ if( g.zTop ) g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1466
+ if( g.zBaseURL ) g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
14911467
cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]);
14921468
zPathInfo += i;
14931469
cgi_replace_parameter("SCRIPT_NAME", zNewScript);
14941470
db_open_repository(file_cleanup_fullpath(zRepo));
14951471
if( g.fHttpTrace ){
14961472
@ <!-- repository: "%h(zRepo)" -->
1497
- @ <!-- new PATH_INFO: "%h(zPathInfo)" -->
1498
- @ <!-- new SCRIPT_NAME: "%h(zNewScript)" -->
1473
+ @ <!-- translated PATH_INFO: "%h(zPathInfo)" -->
1474
+ @ <!-- translated SCRIPT_NAME: "%h(zNewScript)" -->
14991475
fprintf(stderr,
15001476
"# repository: [%s]\n"
1501
- "# new PATH_INFO = [%s]\n"
1502
- "# new SCRIPT_NAME = [%s]\n",
1477
+ "# translated PATH_INFO = [%s]\n"
1478
+ "# translated SCRIPT_NAME = [%s]\n",
15031479
zRepo, zPathInfo, zNewScript);
1480
+ if( g.zTop ){
1481
+ @ <!-- translated g.zTop: "%h(g.zTop)" -->
1482
+ fprintf(stderr, "# translated g.zTop = [%s]\n", g.zTop);
1483
+ }
1484
+ if( g.zBaseURL ){
1485
+ @ <!-- translated g.zBaseURL: "%h(g.zBaseURL)" -->
1486
+ fprintf(stderr, "# translated g.zBaseURL = [%s]\n", g.zBaseURL);
1487
+ }
15041488
}
15051489
}
15061490
15071491
/* At this point, the appropriate repository database file will have
15081492
** been opened. Use the first element of PATH_INFO as the page name
15091493
--- src/main.c
+++ src/main.c
@@ -1288,11 +1288,10 @@
1288 const char *zNotFound, /* Redirect here on a 404 if not NULL */
1289 Glob *pFileGlob, /* Deliver static files matching */
1290 int allowRepoList /* Send repo list for "/" URL */
1291 ){
1292 const char *zPathInfo = PD("PATH_INFO", "");
1293 /* const char *zDirPathInfo; **** refactor needed */
1294 char *zPath = NULL;
1295 int i;
1296 const CmdOrPage *pCmd = 0;
1297 const char *zBase = g.zRepositoryName;
1298
@@ -1301,23 +1300,10 @@
1301 g.fTimeFormat = 1;
1302 }else if( PB("localtime") ){
1303 g.fTimeFormat = 2;
1304 }
1305
1306 #if 0 /* Refactor needed */
1307 /* For the PATH_INFO that will be used to help build the final
1308 ** g.zBaseURL and g.zTop (only), skip over the initial directory
1309 ** portion of PATH_INFO; otherwise, it may be duplicated.
1310 */
1311 if( g.zTop ){
1312 int nTop = strlen(g.zTop);
1313 if ( strncmp(zDirPathInfo, g.zTop, nTop)==0 ){
1314 zDirPathInfo += nTop;
1315 }
1316 }
1317 #endif
1318
1319 /* If the repository has not been opened already, then find the
1320 ** repository based on the first element of PATH_INFO and open it.
1321 */
1322 if( !g.repositoryOpen ){
1323 char *zRepo; /* Candidate repository name */
@@ -1393,22 +1379,10 @@
1393 szFile = file_size(zCleanRepo);
1394 if( g.fHttpTrace ){
1395 @ <!-- file_size(%h(zCleanRepo)) is %lld(szFile) -->
1396 fprintf(stderr, "# file_size(%s) = %lld\n", zCleanRepo, szFile);
1397 }
1398
1399 #if 0
1400 /* This logic for handling --baseurl is confused and needs to be
1401 ** completely rethought. */
1402 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1403 file_isdir(g.zRepositoryName)==1 ){
1404 if( zPathInfo==zDirPathInfo ){
1405 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1406 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1407 }
1408 }
1409 #endif
1410 }
1411
1412 /* If no file named by zRepo exists, remove the added ".fossil" suffix
1413 ** and check to see if there is a file or directory with the same
1414 ** name as the raw PATH_INFO text.
@@ -1482,27 +1456,37 @@
1482 }
1483 break;
1484 }
1485
1486 /* Add the repository name (without the ".fossil" suffix) to the end
1487 ** of SCRIPT_NAME and remove the repository name from the beginning
1488 ** of PATH_INFO.
1489 */
1490 zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo);
 
 
1491 cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]);
1492 zPathInfo += i;
1493 cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1494 db_open_repository(file_cleanup_fullpath(zRepo));
1495 if( g.fHttpTrace ){
1496 @ <!-- repository: "%h(zRepo)" -->
1497 @ <!-- new PATH_INFO: "%h(zPathInfo)" -->
1498 @ <!-- new SCRIPT_NAME: "%h(zNewScript)" -->
1499 fprintf(stderr,
1500 "# repository: [%s]\n"
1501 "# new PATH_INFO = [%s]\n"
1502 "# new SCRIPT_NAME = [%s]\n",
1503 zRepo, zPathInfo, zNewScript);
 
 
 
 
 
 
 
 
1504 }
1505 }
1506
1507 /* At this point, the appropriate repository database file will have
1508 ** been opened. Use the first element of PATH_INFO as the page name
1509
--- src/main.c
+++ src/main.c
@@ -1288,11 +1288,10 @@
1288 const char *zNotFound, /* Redirect here on a 404 if not NULL */
1289 Glob *pFileGlob, /* Deliver static files matching */
1290 int allowRepoList /* Send repo list for "/" URL */
1291 ){
1292 const char *zPathInfo = PD("PATH_INFO", "");
 
1293 char *zPath = NULL;
1294 int i;
1295 const CmdOrPage *pCmd = 0;
1296 const char *zBase = g.zRepositoryName;
1297
@@ -1301,23 +1300,10 @@
1300 g.fTimeFormat = 1;
1301 }else if( PB("localtime") ){
1302 g.fTimeFormat = 2;
1303 }
1304
 
 
 
 
 
 
 
 
 
 
 
 
 
1305 /* If the repository has not been opened already, then find the
1306 ** repository based on the first element of PATH_INFO and open it.
1307 */
1308 if( !g.repositoryOpen ){
1309 char *zRepo; /* Candidate repository name */
@@ -1393,22 +1379,10 @@
1379 szFile = file_size(zCleanRepo);
1380 if( g.fHttpTrace ){
1381 @ <!-- file_size(%h(zCleanRepo)) is %lld(szFile) -->
1382 fprintf(stderr, "# file_size(%s) = %lld\n", zCleanRepo, szFile);
1383 }
 
 
 
 
 
 
 
 
 
 
 
 
1384 }
1385
1386 /* If no file named by zRepo exists, remove the added ".fossil" suffix
1387 ** and check to see if there is a file or directory with the same
1388 ** name as the raw PATH_INFO text.
@@ -1482,27 +1456,37 @@
1456 }
1457 break;
1458 }
1459
1460 /* Add the repository name (without the ".fossil" suffix) to the end
1461 ** of SCRIPT_NAME and g.zTop and g.zBaseURL and remove the repository
1462 ** name from the beginning of PATH_INFO.
1463 */
1464 zNewScript = mprintf("%s%.*s", zOldScript, i, zPathInfo);
1465 if( g.zTop ) g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1466 if( g.zBaseURL ) g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1467 cgi_replace_parameter("PATH_INFO", &zPathInfo[i+1]);
1468 zPathInfo += i;
1469 cgi_replace_parameter("SCRIPT_NAME", zNewScript);
1470 db_open_repository(file_cleanup_fullpath(zRepo));
1471 if( g.fHttpTrace ){
1472 @ <!-- repository: "%h(zRepo)" -->
1473 @ <!-- translated PATH_INFO: "%h(zPathInfo)" -->
1474 @ <!-- translated SCRIPT_NAME: "%h(zNewScript)" -->
1475 fprintf(stderr,
1476 "# repository: [%s]\n"
1477 "# translated PATH_INFO = [%s]\n"
1478 "# translated SCRIPT_NAME = [%s]\n",
1479 zRepo, zPathInfo, zNewScript);
1480 if( g.zTop ){
1481 @ <!-- translated g.zTop: "%h(g.zTop)" -->
1482 fprintf(stderr, "# translated g.zTop = [%s]\n", g.zTop);
1483 }
1484 if( g.zBaseURL ){
1485 @ <!-- translated g.zBaseURL: "%h(g.zBaseURL)" -->
1486 fprintf(stderr, "# translated g.zBaseURL = [%s]\n", g.zBaseURL);
1487 }
1488 }
1489 }
1490
1491 /* At this point, the appropriate repository database file will have
1492 ** been opened. Use the first element of PATH_INFO as the page name
1493

Keyboard Shortcuts

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