Hello

Since fossil happily serves files not added to repository in
/doc/ckout I fixed the issue locally to make /doc/ckout match /doc/tip
after the changes are committed.

The issue is reported as 0e5d75657f

I do not understand the fossil source well enough to make changes with
confidence but since this is only for reading stuff it should not
break anything unrelated. Also it would be nice to add meaningful
messages for the other cases when fetching a doc page fails.

I tried the patch and it works for me.

Thanks

Michal
Index: src/doc.c
===================================================================
--- src/doc.c
+++ src/doc.c
@@ -330,10 +330,11 @@
   int vid = 0;                      /* Artifact of baseline */
   int rid = 0;                      /* Artifact of file */
   int i;                            /* Loop counter */
   Blob filebody;                    /* Content of the documentation file */
   char zBaseline[UUID_SIZE+1];      /* Baseline UUID */
+  char * reason = "document not present in the repository";
 
   login_check_credentials();
   if( !g.okRead ){ login_needed(); return; }
   zName = PD("name", "tip/index.wiki");
   for(i=0; zName[i] && zName[i]!='/'; i++){}
@@ -343,10 +344,11 @@
   memcpy(zBaseline, zName, i);
   zBaseline[i] = 0;
   zName += i;
   while( zName[0]=='/' ){ zName++; }
   if( !file_is_simple_pathname(zName) ){
+    reason = "filename contains illegal characters";
     goto doc_not_found;
   }
   if( strcmp(zBaseline,"ckout")==0 && db_open_local()==0 ){
     strcpy(zBaseline,"tip");
   }
@@ -353,14 +355,26 @@
   if( strcmp(zBaseline,"ckout")==0 ){
     /* Read from the local checkout */
     char *zFullpath;
     db_must_be_within_tree();
     zFullpath = mprintf("%s/%s", g.zLocalRoot, zName);
+    if( ! db_exists(
+          "SELECT 1 FROM vfile" " WHERE pathname=%Q AND deleted=0 "
+#ifdef __MINGW32__
+          "COLLATE nocase"
+#endif
+          , zName) ) {
+      reason = "file not added to the repository";
+      goto doc_not_found;
+    }
+
     if( !file_isfile(zFullpath) ){
+      reason = "file not found";
       goto doc_not_found;
     }
     if( blob_read_from_file(&filebody, zFullpath)<0 ){
+      reason = "cannot read file";
       goto doc_not_found;
     }
   }else{
     db_begin_transaction();
     if( strcmp(zBaseline,"tip")==0 ){
@@ -464,11 +478,11 @@
 
 doc_not_found:
   /* Jump here when unable to locate the document */
   db_end_transaction(0);
   style_header("Document Not Found");
-  @ <p>No such document: %h(PD("name","tip/index.wiki"))</p>
+  @ <p>Error: %h(reason): %h(zName)</p>
   style_footer();
   return;
 }
 
 /*

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to