Fossil

Check-in [29cb8260]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the /doc webpage so that it does not call fossil_fatal() when it cannot find the requested document. It simply does a 404 routine. By not calling fossil_fatal(), it avoids unnecessary entries in the error log.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 29cb8260c0d62ec60ff098bbe99336eb2d46a2d53e39bcc2b8540a1aa0167242
User & Date: drh 2018-06-24 18:47:10.535
Context
2018-06-24
19:27
Do not report errors to the error log on a 304 reply. ... (check-in: 60c8eca3 user: drh tags: trunk)
18:47
Fix the /doc webpage so that it does not call fossil_fatal() when it cannot find the requested document. It simply does a 404 routine. By not calling fossil_fatal(), it avoids unnecessary entries in the error log. ... (check-in: 29cb8260 user: drh tags: trunk)
18:22
Only invoke the email alert sender after a successful HTTP request. Mark Not Found requests as 404, unsuccessful. ... (check-in: 4eb3e0f2 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/doc.c.
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
      zFullpath = mprintf("%s/%s", g.zLocalRoot, zName);
      if( file_isfile(zFullpath, RepoFILE)
       && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){
        rid = 1;  /* Fake RID just to get the loop to end */
      }
      fossil_free(zFullpath);
    }else{
      vid = name_to_typed_rid(zCheckin, "ci");
      rid = doc_load_content(vid, zName, &filebody);
    }
  }
  g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
  if( rid==0 ) goto doc_not_found;
  blob_to_utf8_no_bom(&filebody, 0);

  /* The file is now contained in the filebody blob.  Deliver the







|
|







662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
      zFullpath = mprintf("%s/%s", g.zLocalRoot, zName);
      if( file_isfile(zFullpath, RepoFILE)
       && blob_read_from_file(&filebody, zFullpath, RepoFILE)>0 ){
        rid = 1;  /* Fake RID just to get the loop to end */
      }
      fossil_free(zFullpath);
    }else{
      vid = symbolic_name_to_rid(zCheckin, "ci");
      rid = vid>0 ? doc_load_content(vid, zName, &filebody) : 0;
    }
  }
  g.zPath = mprintf("%s/%s", g.zPath, zPathSuffix);
  if( rid==0 ) goto doc_not_found;
  blob_to_utf8_no_bom(&filebody, 0);

  /* The file is now contained in the filebody blob.  Deliver the
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
  cgi_set_status(404, "Not Found");
  style_header("Not Found");
  @ <p>Document %h(zOrigName) not found
  if( fossil_strcmp(zCheckin,"ckout")!=0 ){
    @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
  }
  style_footer();
  db_end_transaction(0);
  return;
}

/*
** The default logo.
*/
static const unsigned char aLogo[] = {







<







762
763
764
765
766
767
768

769
770
771
772
773
774
775
  cgi_set_status(404, "Not Found");
  style_header("Not Found");
  @ <p>Document %h(zOrigName) not found
  if( fossil_strcmp(zCheckin,"ckout")!=0 ){
    @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
  }
  style_footer();

  return;
}

/*
** The default logo.
*/
static const unsigned char aLogo[] = {
Changes to src/name.c.
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
*/
int name_to_typed_rid(const char *zName, const char *zType){
  int rid;

  if( zName==0 || zName[0]==0 ) return 0;
  rid = symbolic_name_to_rid(zName, zType);
  if( rid<0 ){
    cgi_set_status(404, "Not Found");
    fossil_fatal("ambiguous name: %s", zName);
  }else if( rid==0 ){
    cgi_set_status(404, "Not Found");
    fossil_fatal("not found: %s", zName);
  }
  return rid;
}
int name_to_rid(const char *zName){
  return name_to_typed_rid(zName, "*");
}







<


<







421
422
423
424
425
426
427

428
429

430
431
432
433
434
435
436
*/
int name_to_typed_rid(const char *zName, const char *zType){
  int rid;

  if( zName==0 || zName[0]==0 ) return 0;
  rid = symbolic_name_to_rid(zName, zType);
  if( rid<0 ){

    fossil_fatal("ambiguous name: %s", zName);
  }else if( rid==0 ){

    fossil_fatal("not found: %s", zName);
  }
  return rid;
}
int name_to_rid(const char *zName){
  return name_to_typed_rid(zName, "*");
}