Fossil SCM

For the /doc web method, append "index.html" if the path ends with "/".

drh 2011-10-29 17:22 trunk
Commit 49a015ef79c62105d84dd540090b19053a960b4c
1 file changed +13 -2
+13 -2
--- src/doc.c
+++ src/doc.c
@@ -367,18 +367,27 @@
367367
login_check_credentials();
368368
if( !g.perm.Read ){ login_needed(); return; }
369369
zName = PD("name", "tip/index.wiki");
370370
for(i=0; zName[i] && zName[i]!='/'; i++){}
371371
if( zName[i]==0 || i>UUID_SIZE ){
372
+ zName = "index.html";
372373
goto doc_not_found;
373374
}
374375
memcpy(zBaseline, zName, i);
375376
zBaseline[i] = 0;
376377
zName += i;
377378
while( zName[0]=='/' ){ zName++; }
378379
if( !file_is_simple_pathname(zName) ){
379
- goto doc_not_found;
380
+ int n = strlen(zName);
381
+ if( n>0 && zName[n-1]=='/' ){
382
+ zName = mprintf("%sindex.html", zName);
383
+ if( !file_is_simple_pathname(zName) ){
384
+ goto doc_not_found;
385
+ }
386
+ }else{
387
+ goto doc_not_found;
388
+ }
380389
}
381390
if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
382391
sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
383392
}
384393
if( fossil_strcmp(zBaseline,"ckout")==0 ){
@@ -408,10 +417,12 @@
408417
" fname TEXT, -- filename\n"
409418
" rid INTEGER, -- artifact ID\n"
410419
" UNIQUE(vid,fname,rid)\n"
411420
")"
412421
);
422
+
423
+
413424
414425
/* Check to see if the documentation file artifact ID is contained
415426
** in the baseline cache */
416427
rid = db_int(0, "SELECT rid FROM vcache"
417428
" WHERE vid=%d AND fname=%Q", vid, zName);
@@ -499,11 +510,11 @@
499510
500511
doc_not_found:
501512
/* Jump here when unable to locate the document */
502513
db_end_transaction(0);
503514
style_header("Document Not Found");
504
- @ <p>No such document: %h(PD("name","tip/index.wiki"))</p>
515
+ @ <p>No such document: %h(zName)</p>
505516
style_footer();
506517
return;
507518
}
508519
509520
/*
510521
--- src/doc.c
+++ src/doc.c
@@ -367,18 +367,27 @@
367 login_check_credentials();
368 if( !g.perm.Read ){ login_needed(); return; }
369 zName = PD("name", "tip/index.wiki");
370 for(i=0; zName[i] && zName[i]!='/'; i++){}
371 if( zName[i]==0 || i>UUID_SIZE ){
 
372 goto doc_not_found;
373 }
374 memcpy(zBaseline, zName, i);
375 zBaseline[i] = 0;
376 zName += i;
377 while( zName[0]=='/' ){ zName++; }
378 if( !file_is_simple_pathname(zName) ){
379 goto doc_not_found;
 
 
 
 
 
 
 
 
380 }
381 if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
382 sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
383 }
384 if( fossil_strcmp(zBaseline,"ckout")==0 ){
@@ -408,10 +417,12 @@
408 " fname TEXT, -- filename\n"
409 " rid INTEGER, -- artifact ID\n"
410 " UNIQUE(vid,fname,rid)\n"
411 ")"
412 );
 
 
413
414 /* Check to see if the documentation file artifact ID is contained
415 ** in the baseline cache */
416 rid = db_int(0, "SELECT rid FROM vcache"
417 " WHERE vid=%d AND fname=%Q", vid, zName);
@@ -499,11 +510,11 @@
499
500 doc_not_found:
501 /* Jump here when unable to locate the document */
502 db_end_transaction(0);
503 style_header("Document Not Found");
504 @ <p>No such document: %h(PD("name","tip/index.wiki"))</p>
505 style_footer();
506 return;
507 }
508
509 /*
510
--- src/doc.c
+++ src/doc.c
@@ -367,18 +367,27 @@
367 login_check_credentials();
368 if( !g.perm.Read ){ login_needed(); return; }
369 zName = PD("name", "tip/index.wiki");
370 for(i=0; zName[i] && zName[i]!='/'; i++){}
371 if( zName[i]==0 || i>UUID_SIZE ){
372 zName = "index.html";
373 goto doc_not_found;
374 }
375 memcpy(zBaseline, zName, i);
376 zBaseline[i] = 0;
377 zName += i;
378 while( zName[0]=='/' ){ zName++; }
379 if( !file_is_simple_pathname(zName) ){
380 int n = strlen(zName);
381 if( n>0 && zName[n-1]=='/' ){
382 zName = mprintf("%sindex.html", zName);
383 if( !file_is_simple_pathname(zName) ){
384 goto doc_not_found;
385 }
386 }else{
387 goto doc_not_found;
388 }
389 }
390 if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
391 sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip");
392 }
393 if( fossil_strcmp(zBaseline,"ckout")==0 ){
@@ -408,10 +417,12 @@
417 " fname TEXT, -- filename\n"
418 " rid INTEGER, -- artifact ID\n"
419 " UNIQUE(vid,fname,rid)\n"
420 ")"
421 );
422
423
424
425 /* Check to see if the documentation file artifact ID is contained
426 ** in the baseline cache */
427 rid = db_int(0, "SELECT rid FROM vcache"
428 " WHERE vid=%d AND fname=%Q", vid, zName);
@@ -499,11 +510,11 @@
510
511 doc_not_found:
512 /* Jump here when unable to locate the document */
513 db_end_transaction(0);
514 style_header("Document Not Found");
515 @ <p>No such document: %h(zName)</p>
516 style_footer();
517 return;
518 }
519
520 /*
521

Keyboard Shortcuts

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