Fossil SCM
For the /doc web method, append "index.html" if the path ends with "/".
Commit
49a015ef79c62105d84dd540090b19053a960b4c
Parent
5da9a8c824146e9…
1 file changed
+13
-2
+13
-2
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -367,18 +367,27 @@ | ||
| 367 | 367 | login_check_credentials(); |
| 368 | 368 | if( !g.perm.Read ){ login_needed(); return; } |
| 369 | 369 | zName = PD("name", "tip/index.wiki"); |
| 370 | 370 | for(i=0; zName[i] && zName[i]!='/'; i++){} |
| 371 | 371 | if( zName[i]==0 || i>UUID_SIZE ){ |
| 372 | + zName = "index.html"; | |
| 372 | 373 | goto doc_not_found; |
| 373 | 374 | } |
| 374 | 375 | memcpy(zBaseline, zName, i); |
| 375 | 376 | zBaseline[i] = 0; |
| 376 | 377 | zName += i; |
| 377 | 378 | while( zName[0]=='/' ){ zName++; } |
| 378 | 379 | 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 | + } | |
| 380 | 389 | } |
| 381 | 390 | if( fossil_strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){ |
| 382 | 391 | sqlite3_snprintf(sizeof(zBaseline), zBaseline, "tip"); |
| 383 | 392 | } |
| 384 | 393 | if( fossil_strcmp(zBaseline,"ckout")==0 ){ |
| @@ -408,10 +417,12 @@ | ||
| 408 | 417 | " fname TEXT, -- filename\n" |
| 409 | 418 | " rid INTEGER, -- artifact ID\n" |
| 410 | 419 | " UNIQUE(vid,fname,rid)\n" |
| 411 | 420 | ")" |
| 412 | 421 | ); |
| 422 | + | |
| 423 | + | |
| 413 | 424 | |
| 414 | 425 | /* Check to see if the documentation file artifact ID is contained |
| 415 | 426 | ** in the baseline cache */ |
| 416 | 427 | rid = db_int(0, "SELECT rid FROM vcache" |
| 417 | 428 | " WHERE vid=%d AND fname=%Q", vid, zName); |
| @@ -499,11 +510,11 @@ | ||
| 499 | 510 | |
| 500 | 511 | doc_not_found: |
| 501 | 512 | /* Jump here when unable to locate the document */ |
| 502 | 513 | db_end_transaction(0); |
| 503 | 514 | 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> | |
| 505 | 516 | style_footer(); |
| 506 | 517 | return; |
| 507 | 518 | } |
| 508 | 519 | |
| 509 | 520 | /* |
| 510 | 521 |
| --- 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 |