Fossil SCM

Merge in trunk for manifest_parse() output fix and "hidden" ajax routes.

stephan 2021-09-08 17:36 diff-js-refactoring merge
Commit f68b0b71872b974bef8add73a2a1794ae2451125ac045b5a495ca7d1dfea0c5b
+10 -4
--- src/blob.c
+++ src/blob.c
@@ -276,11 +276,12 @@
276276
pBlob->xRealloc = blobReallocStatic;
277277
}
278278
279279
/*
280280
** Append text or data to the end of a blob. Or, if pBlob==NULL, send
281
-** the text to standard output.
281
+** the text to standard output in terminal mode, or to standard CGI output
282
+** in CGI mode.
282283
**
283284
** If nData<0 then output all of aData up to the first 0x00 byte.
284285
**
285286
** Use the blob_append() routine in all application code. The blob_append()
286287
** routine is faster, but blob_append_full() handles all the corner cases.
@@ -292,12 +293,16 @@
292293
/* assert( aData!=0 || nData==0 ); // omitted for speed */
293294
/* blob_is_init(pBlob); // omitted for speed */
294295
if( nData<0 ) nData = strlen(aData);
295296
if( nData==0 ) return;
296297
if( pBlob==0 ){
297
- fossil_puts(aData, 0, nData);
298
- return;
298
+ if( g.cgiOutput ){
299
+ pBlob = cgi_output_blob();
300
+ }else{
301
+ fossil_puts(aData, 0, nData);
302
+ return;
303
+ }
299304
}
300305
nNew = pBlob->nUsed;
301306
nNew += nData;
302307
if( nNew >= pBlob->nAlloc ){
303308
nNew += pBlob->nAlloc;
@@ -356,11 +361,12 @@
356361
}
357362
358363
/*
359364
** Append the second blob onto the end of the first blob and reset the
360365
** second blob. If the first blob (pTo) is NULL, then the content
361
-** of the second blob is written to stdout.
366
+** of the second blob is written to stdout or to CGI depending on if the
367
+** Fossil is running in terminal or CGI mode.
362368
*/
363369
void blob_append_xfer(Blob *pTo, Blob *pFrom){
364370
blob_append(pTo, blob_buffer(pFrom), blob_size(pFrom));
365371
blob_reset(pFrom);
366372
}
367373
--- src/blob.c
+++ src/blob.c
@@ -276,11 +276,12 @@
276 pBlob->xRealloc = blobReallocStatic;
277 }
278
279 /*
280 ** Append text or data to the end of a blob. Or, if pBlob==NULL, send
281 ** the text to standard output.
 
282 **
283 ** If nData<0 then output all of aData up to the first 0x00 byte.
284 **
285 ** Use the blob_append() routine in all application code. The blob_append()
286 ** routine is faster, but blob_append_full() handles all the corner cases.
@@ -292,12 +293,16 @@
292 /* assert( aData!=0 || nData==0 ); // omitted for speed */
293 /* blob_is_init(pBlob); // omitted for speed */
294 if( nData<0 ) nData = strlen(aData);
295 if( nData==0 ) return;
296 if( pBlob==0 ){
297 fossil_puts(aData, 0, nData);
298 return;
 
 
 
 
299 }
300 nNew = pBlob->nUsed;
301 nNew += nData;
302 if( nNew >= pBlob->nAlloc ){
303 nNew += pBlob->nAlloc;
@@ -356,11 +361,12 @@
356 }
357
358 /*
359 ** Append the second blob onto the end of the first blob and reset the
360 ** second blob. If the first blob (pTo) is NULL, then the content
361 ** of the second blob is written to stdout.
 
362 */
363 void blob_append_xfer(Blob *pTo, Blob *pFrom){
364 blob_append(pTo, blob_buffer(pFrom), blob_size(pFrom));
365 blob_reset(pFrom);
366 }
367
--- src/blob.c
+++ src/blob.c
@@ -276,11 +276,12 @@
276 pBlob->xRealloc = blobReallocStatic;
277 }
278
279 /*
280 ** Append text or data to the end of a blob. Or, if pBlob==NULL, send
281 ** the text to standard output in terminal mode, or to standard CGI output
282 ** in CGI mode.
283 **
284 ** If nData<0 then output all of aData up to the first 0x00 byte.
285 **
286 ** Use the blob_append() routine in all application code. The blob_append()
287 ** routine is faster, but blob_append_full() handles all the corner cases.
@@ -292,12 +293,16 @@
293 /* assert( aData!=0 || nData==0 ); // omitted for speed */
294 /* blob_is_init(pBlob); // omitted for speed */
295 if( nData<0 ) nData = strlen(aData);
296 if( nData==0 ) return;
297 if( pBlob==0 ){
298 if( g.cgiOutput ){
299 pBlob = cgi_output_blob();
300 }else{
301 fossil_puts(aData, 0, nData);
302 return;
303 }
304 }
305 nNew = pBlob->nUsed;
306 nNew += nData;
307 if( nNew >= pBlob->nAlloc ){
308 nNew += pBlob->nAlloc;
@@ -356,11 +361,12 @@
361 }
362
363 /*
364 ** Append the second blob onto the end of the first blob and reset the
365 ** second blob. If the first blob (pTo) is NULL, then the content
366 ** of the second blob is written to stdout or to CGI depending on if the
367 ** Fossil is running in terminal or CGI mode.
368 */
369 void blob_append_xfer(Blob *pTo, Blob *pFrom){
370 blob_append(pTo, blob_buffer(pFrom), blob_size(pFrom));
371 blob_reset(pFrom);
372 }
373
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,12 @@
4848
#define CMDFLAG_SETTING 0x0020 /* A setting */
4949
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
5050
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
5151
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
5252
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
53
+/* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
54
+#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
5355
/**************************************************************************/
5456
5557
/* Values for the 2nd parameter to dispatch_name_search() */
5658
#define CMDFLAG_ANY 0x0038 /* Match anything */
5759
#define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -551,10 +553,11 @@
551553
}else{
552554
fossil_print("---\n");
553555
}
554556
for(i=0; i<MX_COMMAND; i++){
555557
if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
558
+ else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
556559
if( useHtml ){
557560
Blob html;
558561
blob_init(&html, 0, 0);
559562
help_to_html(aCommand[i].zHelp, &html);
560563
fossil_print("<h1>%h</h1>\n", aCommand[i].zName);
@@ -829,10 +832,11 @@
829832
const char *z = aCommand[i].zName;
830833
const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
831834
const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
832835
if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
833836
if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
837
+ else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
834838
@ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a></li>
835839
}
836840
@ </ul></div>
837841
838842
@ <a name='webpages'></a>
@@ -840,10 +844,11 @@
840844
@ <div class="columns" style="column-width: 18ex;">
841845
@ <ul>
842846
for(i=0; i<MX_COMMAND; i++){
843847
const char *z = aCommand[i].zName;
844848
if( '/'!=*z ) continue;
849
+ else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
845850
if( aCommand[i].zHelp[0] ){
846851
@ <li><a href="%R/help?cmd=%s(z)">%s(z+1)</a></li>
847852
}else{
848853
@ <li>%s(z+1)</li>
849854
}
@@ -855,10 +860,11 @@
855860
@ <div class="columns" style="column-width: 20ex;">
856861
@ <ul>
857862
for(i=0; i<MX_COMMAND; i++){
858863
const char *z = aCommand[i].zName;
859864
if( strncmp(z,"test",4)!=0 ) continue;
865
+ else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
860866
if( aCommand[i].zHelp[0] ){
861867
@ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
862868
}else{
863869
@ <li>%s(z)</li>
864870
}
@@ -870,10 +876,11 @@
870876
@ <div class="columns" style="column-width: 20ex;">
871877
@ <ul>
872878
for(i=0; i<MX_COMMAND; i++){
873879
const char *z = aCommand[i].zName;
874880
if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
881
+ else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
875882
if( aCommand[i].zHelp[0] ){
876883
@ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
877884
}else{
878885
@ <li>%s(z)</li>
879886
}
@@ -985,10 +992,11 @@
985992
}else{
986993
int i, nCmd;
987994
const char *aCmd[MX_COMMAND];
988995
for(i=nCmd=0; i<MX_COMMAND; i++){
989996
if( (aCommand[i].eCmdFlags & cmdMask)==0 ) continue;
997
+ else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
990998
aCmd[nCmd++] = aCommand[i].zName;
991999
}
9921000
multi_column_list(aCmd, nCmd);
9931001
}
9941002
}
9951003
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,12 @@
48 #define CMDFLAG_SETTING 0x0020 /* A setting */
49 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
50 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
51 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
52 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
 
 
53 /**************************************************************************/
54
55 /* Values for the 2nd parameter to dispatch_name_search() */
56 #define CMDFLAG_ANY 0x0038 /* Match anything */
57 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -551,10 +553,11 @@
551 }else{
552 fossil_print("---\n");
553 }
554 for(i=0; i<MX_COMMAND; i++){
555 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
 
556 if( useHtml ){
557 Blob html;
558 blob_init(&html, 0, 0);
559 help_to_html(aCommand[i].zHelp, &html);
560 fossil_print("<h1>%h</h1>\n", aCommand[i].zName);
@@ -829,10 +832,11 @@
829 const char *z = aCommand[i].zName;
830 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
831 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
832 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
833 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
 
834 @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a></li>
835 }
836 @ </ul></div>
837
838 @ <a name='webpages'></a>
@@ -840,10 +844,11 @@
840 @ <div class="columns" style="column-width: 18ex;">
841 @ <ul>
842 for(i=0; i<MX_COMMAND; i++){
843 const char *z = aCommand[i].zName;
844 if( '/'!=*z ) continue;
 
845 if( aCommand[i].zHelp[0] ){
846 @ <li><a href="%R/help?cmd=%s(z)">%s(z+1)</a></li>
847 }else{
848 @ <li>%s(z+1)</li>
849 }
@@ -855,10 +860,11 @@
855 @ <div class="columns" style="column-width: 20ex;">
856 @ <ul>
857 for(i=0; i<MX_COMMAND; i++){
858 const char *z = aCommand[i].zName;
859 if( strncmp(z,"test",4)!=0 ) continue;
 
860 if( aCommand[i].zHelp[0] ){
861 @ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
862 }else{
863 @ <li>%s(z)</li>
864 }
@@ -870,10 +876,11 @@
870 @ <div class="columns" style="column-width: 20ex;">
871 @ <ul>
872 for(i=0; i<MX_COMMAND; i++){
873 const char *z = aCommand[i].zName;
874 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
 
875 if( aCommand[i].zHelp[0] ){
876 @ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
877 }else{
878 @ <li>%s(z)</li>
879 }
@@ -985,10 +992,11 @@
985 }else{
986 int i, nCmd;
987 const char *aCmd[MX_COMMAND];
988 for(i=nCmd=0; i<MX_COMMAND; i++){
989 if( (aCommand[i].eCmdFlags & cmdMask)==0 ) continue;
 
990 aCmd[nCmd++] = aCommand[i].zName;
991 }
992 multi_column_list(aCmd, nCmd);
993 }
994 }
995
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,12 @@
48 #define CMDFLAG_SETTING 0x0020 /* A setting */
49 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
50 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
51 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
52 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
53 /* NOTE: 0x0400 = CMDFLAG_SENSITIVE in mkindex.c! */
54 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
55 /**************************************************************************/
56
57 /* Values for the 2nd parameter to dispatch_name_search() */
58 #define CMDFLAG_ANY 0x0038 /* Match anything */
59 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
@@ -551,10 +553,11 @@
553 }else{
554 fossil_print("---\n");
555 }
556 for(i=0; i<MX_COMMAND; i++){
557 if( (aCommand[i].eCmdFlags & mask)==0 ) continue;
558 else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
559 if( useHtml ){
560 Blob html;
561 blob_init(&html, 0, 0);
562 help_to_html(aCommand[i].zHelp, &html);
563 fossil_print("<h1>%h</h1>\n", aCommand[i].zName);
@@ -829,10 +832,11 @@
832 const char *z = aCommand[i].zName;
833 const char *zBoldOn = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"<b>" :"";
834 const char *zBoldOff = aCommand[i].eCmdFlags&CMDFLAG_1ST_TIER?"</b>":"";
835 if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
836 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)!=0 ) continue;
837 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
838 @ <li><a href="%R/help?cmd=%s(z)">%s(zBoldOn)%s(z)%s(zBoldOff)</a></li>
839 }
840 @ </ul></div>
841
842 @ <a name='webpages'></a>
@@ -840,10 +844,11 @@
844 @ <div class="columns" style="column-width: 18ex;">
845 @ <ul>
846 for(i=0; i<MX_COMMAND; i++){
847 const char *z = aCommand[i].zName;
848 if( '/'!=*z ) continue;
849 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
850 if( aCommand[i].zHelp[0] ){
851 @ <li><a href="%R/help?cmd=%s(z)">%s(z+1)</a></li>
852 }else{
853 @ <li>%s(z+1)</li>
854 }
@@ -855,10 +860,11 @@
860 @ <div class="columns" style="column-width: 20ex;">
861 @ <ul>
862 for(i=0; i<MX_COMMAND; i++){
863 const char *z = aCommand[i].zName;
864 if( strncmp(z,"test",4)!=0 ) continue;
865 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
866 if( aCommand[i].zHelp[0] ){
867 @ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
868 }else{
869 @ <li>%s(z)</li>
870 }
@@ -870,10 +876,11 @@
876 @ <div class="columns" style="column-width: 20ex;">
877 @ <ul>
878 for(i=0; i<MX_COMMAND; i++){
879 const char *z = aCommand[i].zName;
880 if( (aCommand[i].eCmdFlags & CMDFLAG_SETTING)==0 ) continue;
881 else if( (aCommand[i].eCmdFlags & CMDFLAG_HIDDEN)!=0 ) continue;
882 if( aCommand[i].zHelp[0] ){
883 @ <li><a href="%R/help?cmd=%s(z)">%s(z)</a></li>
884 }else{
885 @ <li>%s(z)</li>
886 }
@@ -985,10 +992,11 @@
992 }else{
993 int i, nCmd;
994 const char *aCmd[MX_COMMAND];
995 for(i=nCmd=0; i<MX_COMMAND; i++){
996 if( (aCommand[i].eCmdFlags & cmdMask)==0 ) continue;
997 else if(aCommand[i].eCmdFlags & CMDFLAG_HIDDEN) continue;
998 aCmd[nCmd++] = aCommand[i].zName;
999 }
1000 multi_column_list(aCmd, nCmd);
1001 }
1002 }
1003
+1 -1
--- src/login.c
+++ src/login.c
@@ -1022,11 +1022,11 @@
10221022
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin);
10231023
}else{
10241024
uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
10251025
}
10261026
g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
1027
- zCap = "sx";
1027
+ zCap = "sxy";
10281028
g.noPswd = 1;
10291029
g.isHuman = 1;
10301030
sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "localhost");
10311031
}
10321032
10331033
--- src/login.c
+++ src/login.c
@@ -1022,11 +1022,11 @@
1022 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin);
1023 }else{
1024 uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
1025 }
1026 g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
1027 zCap = "sx";
1028 g.noPswd = 1;
1029 g.isHuman = 1;
1030 sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "localhost");
1031 }
1032
1033
--- src/login.c
+++ src/login.c
@@ -1022,11 +1022,11 @@
1022 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zLogin);
1023 }else{
1024 uid = db_int(0, "SELECT uid FROM user WHERE cap LIKE '%%s%%'");
1025 }
1026 g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid);
1027 zCap = "sxy";
1028 g.noPswd = 1;
1029 g.isHuman = 1;
1030 sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "localhost");
1031 }
1032
1033
+24 -4
--- src/main.c
+++ src/main.c
@@ -2741,31 +2741,51 @@
27412741
} while ( g.fSshClient & CGI_SSH_FOSSIL ||
27422742
g.fSshClient & CGI_SSH_COMPAT );
27432743
}
27442744
27452745
/*
2746
-** Note that the following command is used by ssh:// processing.
2747
-**
27482746
** COMMAND: test-http
27492747
**
2750
-** Works like the [[http]] command but gives setup permission to all users.
2748
+** Works like the [[http]] command but gives setup permission to all users,
2749
+** or whatever permission is described by "--usercap CAP".
2750
+**
2751
+** This command can used for interactive debugging of web pages. For
2752
+** example, one can put a simple HTTP request in a file like this:
2753
+**
2754
+** echo 'GET /timeline' >request.txt
2755
+**
2756
+** Then run (in a debugger) a command like this:
2757
+**
2758
+** fossil test-http --debug <request.txt
2759
+**
2760
+** This command is also used internally by the "ssh" sync protocol. Some
2761
+** special processing to support sync happens when this command is run
2762
+** and the SSH_CONNECTION environment variable is set. Use the --test
2763
+** option on interactive sessions to avoid that special processing when
2764
+** using this command interactively over SSH. A better solution would be
2765
+** to use a different command for "ssh" sync, but we cannot do that without
2766
+** breaking legacy.
27512767
**
27522768
** Options:
2769
+** --test Do not do special "sync" processing when operating
2770
+** over an SSH link.
27532771
** --th-trace Trace TH1 execution (for debugging purposes)
27542772
** --usercap CAP User capability string (Default: "sxy")
27552773
**
27562774
*/
27572775
void cmd_test_http(void){
27582776
const char *zIpAddr; /* IP address of remote client */
27592777
const char *zUserCap;
2778
+ int bTest = 0;
27602779
27612780
Th_InitTraceLog();
27622781
zUserCap = find_option("usercap",0,1);
27632782
if( zUserCap==0 ){
27642783
g.useLocalauth = 1;
27652784
zUserCap = "sxy";
27662785
}
2786
+ bTest = find_option("test",0,0)!=0;
27672787
login_set_capabilities(zUserCap, 0);
27682788
g.httpIn = stdin;
27692789
g.httpOut = stdout;
27702790
fossil_binary_mode(g.httpOut);
27712791
fossil_binary_mode(g.httpIn);
@@ -2773,11 +2793,11 @@
27732793
find_server_repository(2, 0);
27742794
g.cgiOutput = 1;
27752795
g.fNoHttpCompress = 1;
27762796
g.fullHttpReply = 1;
27772797
g.sslNotAvailable = 1; /* Avoid attempts to redirect */
2778
- zIpAddr = cgi_ssh_remote_addr(0);
2798
+ zIpAddr = bTest ? 0 : cgi_ssh_remote_addr(0);
27792799
if( zIpAddr && zIpAddr[0] ){
27802800
g.fSshClient |= CGI_SSH_CLIENT;
27812801
ssh_request_loop(zIpAddr, 0);
27822802
}else{
27832803
cgi_set_parameter("REMOTE_ADDR", "127.0.0.1");
27842804
--- src/main.c
+++ src/main.c
@@ -2741,31 +2741,51 @@
2741 } while ( g.fSshClient & CGI_SSH_FOSSIL ||
2742 g.fSshClient & CGI_SSH_COMPAT );
2743 }
2744
2745 /*
2746 ** Note that the following command is used by ssh:// processing.
2747 **
2748 ** COMMAND: test-http
2749 **
2750 ** Works like the [[http]] command but gives setup permission to all users.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2751 **
2752 ** Options:
 
 
2753 ** --th-trace Trace TH1 execution (for debugging purposes)
2754 ** --usercap CAP User capability string (Default: "sxy")
2755 **
2756 */
2757 void cmd_test_http(void){
2758 const char *zIpAddr; /* IP address of remote client */
2759 const char *zUserCap;
 
2760
2761 Th_InitTraceLog();
2762 zUserCap = find_option("usercap",0,1);
2763 if( zUserCap==0 ){
2764 g.useLocalauth = 1;
2765 zUserCap = "sxy";
2766 }
 
2767 login_set_capabilities(zUserCap, 0);
2768 g.httpIn = stdin;
2769 g.httpOut = stdout;
2770 fossil_binary_mode(g.httpOut);
2771 fossil_binary_mode(g.httpIn);
@@ -2773,11 +2793,11 @@
2773 find_server_repository(2, 0);
2774 g.cgiOutput = 1;
2775 g.fNoHttpCompress = 1;
2776 g.fullHttpReply = 1;
2777 g.sslNotAvailable = 1; /* Avoid attempts to redirect */
2778 zIpAddr = cgi_ssh_remote_addr(0);
2779 if( zIpAddr && zIpAddr[0] ){
2780 g.fSshClient |= CGI_SSH_CLIENT;
2781 ssh_request_loop(zIpAddr, 0);
2782 }else{
2783 cgi_set_parameter("REMOTE_ADDR", "127.0.0.1");
2784
--- src/main.c
+++ src/main.c
@@ -2741,31 +2741,51 @@
2741 } while ( g.fSshClient & CGI_SSH_FOSSIL ||
2742 g.fSshClient & CGI_SSH_COMPAT );
2743 }
2744
2745 /*
 
 
2746 ** COMMAND: test-http
2747 **
2748 ** Works like the [[http]] command but gives setup permission to all users,
2749 ** or whatever permission is described by "--usercap CAP".
2750 **
2751 ** This command can used for interactive debugging of web pages. For
2752 ** example, one can put a simple HTTP request in a file like this:
2753 **
2754 ** echo 'GET /timeline' >request.txt
2755 **
2756 ** Then run (in a debugger) a command like this:
2757 **
2758 ** fossil test-http --debug <request.txt
2759 **
2760 ** This command is also used internally by the "ssh" sync protocol. Some
2761 ** special processing to support sync happens when this command is run
2762 ** and the SSH_CONNECTION environment variable is set. Use the --test
2763 ** option on interactive sessions to avoid that special processing when
2764 ** using this command interactively over SSH. A better solution would be
2765 ** to use a different command for "ssh" sync, but we cannot do that without
2766 ** breaking legacy.
2767 **
2768 ** Options:
2769 ** --test Do not do special "sync" processing when operating
2770 ** over an SSH link.
2771 ** --th-trace Trace TH1 execution (for debugging purposes)
2772 ** --usercap CAP User capability string (Default: "sxy")
2773 **
2774 */
2775 void cmd_test_http(void){
2776 const char *zIpAddr; /* IP address of remote client */
2777 const char *zUserCap;
2778 int bTest = 0;
2779
2780 Th_InitTraceLog();
2781 zUserCap = find_option("usercap",0,1);
2782 if( zUserCap==0 ){
2783 g.useLocalauth = 1;
2784 zUserCap = "sxy";
2785 }
2786 bTest = find_option("test",0,0)!=0;
2787 login_set_capabilities(zUserCap, 0);
2788 g.httpIn = stdin;
2789 g.httpOut = stdout;
2790 fossil_binary_mode(g.httpOut);
2791 fossil_binary_mode(g.httpIn);
@@ -2773,11 +2793,11 @@
2793 find_server_repository(2, 0);
2794 g.cgiOutput = 1;
2795 g.fNoHttpCompress = 1;
2796 g.fullHttpReply = 1;
2797 g.sslNotAvailable = 1; /* Avoid attempts to redirect */
2798 zIpAddr = bTest ? 0 : cgi_ssh_remote_addr(0);
2799 if( zIpAddr && zIpAddr[0] ){
2800 g.fSshClient |= CGI_SSH_CLIENT;
2801 ssh_request_loop(zIpAddr, 0);
2802 }else{
2803 cgi_set_parameter("REMOTE_ADDR", "127.0.0.1");
2804
+18 -8
--- src/manifest.c
+++ src/manifest.c
@@ -353,11 +353,13 @@
353353
md5sum_step_text(z, n-35);
354354
zHash = md5sum_finish(0);
355355
if( memcmp(&z[n-33], zHash, 32)==0 ){
356356
return 1;
357357
}else{
358
- blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash);
358
+ if(pErr!=0){
359
+ blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash);
360
+ }
359361
return 2;
360362
}
361363
}
362364
363365
/*
@@ -488,11 +490,13 @@
488490
if( !isRepeat ) g.parseCnt[0]++;
489491
z = blob_materialize(pContent);
490492
n = blob_size(pContent);
491493
if( n<=0 || z[n-1]!='\n' ){
492494
blob_reset(pContent);
493
- blob_appendf(pErr, "%s", n ? "not terminated with \\n" : "zero-length");
495
+ if(pErr!=0){
496
+ blob_appendf(pErr, "%s", n ? "not terminated with \\n" : "zero-length");
497
+ }
494498
return 0;
495499
}
496500
497501
/* Strip off the PGP signature if there is one.
498502
*/
@@ -501,11 +505,13 @@
501505
/* Verify that the first few characters of the artifact look like
502506
** a control artifact.
503507
*/
504508
if( n<10 || z[0]<'A' || z[0]>'Z' || z[1]!=' ' ){
505509
blob_reset(pContent);
506
- blob_appendf(pErr, "line 1 not recognized");
510
+ if(pErr!=0){
511
+ blob_appendf(pErr, "line 1 not recognized");
512
+ }
507513
return 0;
508514
}
509515
/* Then verify the Z-card.
510516
*/
511517
#if 1
@@ -1122,18 +1128,22 @@
11221128
11231129
manifest_syntax_error:
11241130
{
11251131
char *zUuid = rid_to_uuid(rid);
11261132
if( zUuid ){
1127
- blob_appendf(pErr, "artifact [%s] ", zUuid);
1133
+ if(pErr!=0){
1134
+ blob_appendf(pErr, "artifact [%s] ", zUuid);
1135
+ }
11281136
fossil_free(zUuid);
11291137
}
11301138
}
1131
- if( zErr ){
1132
- blob_appendf(pErr, "line %d: %s", lineNo, zErr);
1133
- }else{
1134
- blob_appendf(pErr, "unknown error on line %d", lineNo);
1139
+ if(pErr!=0){
1140
+ if( zErr ){
1141
+ blob_appendf(pErr, "line %d: %s", lineNo, zErr);
1142
+ }else{
1143
+ blob_appendf(pErr, "unknown error on line %d", lineNo);
1144
+ }
11351145
}
11361146
md5sum_init();
11371147
manifest_destroy(p);
11381148
return 0;
11391149
}
11401150
--- src/manifest.c
+++ src/manifest.c
@@ -353,11 +353,13 @@
353 md5sum_step_text(z, n-35);
354 zHash = md5sum_finish(0);
355 if( memcmp(&z[n-33], zHash, 32)==0 ){
356 return 1;
357 }else{
358 blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash);
 
 
359 return 2;
360 }
361 }
362
363 /*
@@ -488,11 +490,13 @@
488 if( !isRepeat ) g.parseCnt[0]++;
489 z = blob_materialize(pContent);
490 n = blob_size(pContent);
491 if( n<=0 || z[n-1]!='\n' ){
492 blob_reset(pContent);
493 blob_appendf(pErr, "%s", n ? "not terminated with \\n" : "zero-length");
 
 
494 return 0;
495 }
496
497 /* Strip off the PGP signature if there is one.
498 */
@@ -501,11 +505,13 @@
501 /* Verify that the first few characters of the artifact look like
502 ** a control artifact.
503 */
504 if( n<10 || z[0]<'A' || z[0]>'Z' || z[1]!=' ' ){
505 blob_reset(pContent);
506 blob_appendf(pErr, "line 1 not recognized");
 
 
507 return 0;
508 }
509 /* Then verify the Z-card.
510 */
511 #if 1
@@ -1122,18 +1128,22 @@
1122
1123 manifest_syntax_error:
1124 {
1125 char *zUuid = rid_to_uuid(rid);
1126 if( zUuid ){
1127 blob_appendf(pErr, "artifact [%s] ", zUuid);
 
 
1128 fossil_free(zUuid);
1129 }
1130 }
1131 if( zErr ){
1132 blob_appendf(pErr, "line %d: %s", lineNo, zErr);
1133 }else{
1134 blob_appendf(pErr, "unknown error on line %d", lineNo);
 
 
1135 }
1136 md5sum_init();
1137 manifest_destroy(p);
1138 return 0;
1139 }
1140
--- src/manifest.c
+++ src/manifest.c
@@ -353,11 +353,13 @@
353 md5sum_step_text(z, n-35);
354 zHash = md5sum_finish(0);
355 if( memcmp(&z[n-33], zHash, 32)==0 ){
356 return 1;
357 }else{
358 if(pErr!=0){
359 blob_appendf(pErr, "incorrect Z-card cksum: expected %.32s", zHash);
360 }
361 return 2;
362 }
363 }
364
365 /*
@@ -488,11 +490,13 @@
490 if( !isRepeat ) g.parseCnt[0]++;
491 z = blob_materialize(pContent);
492 n = blob_size(pContent);
493 if( n<=0 || z[n-1]!='\n' ){
494 blob_reset(pContent);
495 if(pErr!=0){
496 blob_appendf(pErr, "%s", n ? "not terminated with \\n" : "zero-length");
497 }
498 return 0;
499 }
500
501 /* Strip off the PGP signature if there is one.
502 */
@@ -501,11 +505,13 @@
505 /* Verify that the first few characters of the artifact look like
506 ** a control artifact.
507 */
508 if( n<10 || z[0]<'A' || z[0]>'Z' || z[1]!=' ' ){
509 blob_reset(pContent);
510 if(pErr!=0){
511 blob_appendf(pErr, "line 1 not recognized");
512 }
513 return 0;
514 }
515 /* Then verify the Z-card.
516 */
517 #if 1
@@ -1122,18 +1128,22 @@
1128
1129 manifest_syntax_error:
1130 {
1131 char *zUuid = rid_to_uuid(rid);
1132 if( zUuid ){
1133 if(pErr!=0){
1134 blob_appendf(pErr, "artifact [%s] ", zUuid);
1135 }
1136 fossil_free(zUuid);
1137 }
1138 }
1139 if(pErr!=0){
1140 if( zErr ){
1141 blob_appendf(pErr, "line %d: %s", lineNo, zErr);
1142 }else{
1143 blob_appendf(pErr, "unknown error on line %d", lineNo);
1144 }
1145 }
1146 md5sum_init();
1147 manifest_destroy(p);
1148 return 0;
1149 }
1150
--- src/mkindex.c
+++ src/mkindex.c
@@ -91,10 +91,11 @@
9191
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
9292
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
9393
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
9494
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
9595
#define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
96
+#define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
9697
/**************************************************************************/
9798
9899
/*
99100
** Each entry looks like this:
100101
*/
@@ -257,10 +258,12 @@
257258
aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
258259
}else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
259260
aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
260261
}else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
261262
aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
263
+ }else if( j==6 && strncmp(&zLine[i], "hidden", 6)==0 ){
264
+ aEntry[nUsed].eType |= CMDFLAG_HIDDEN;
262265
}else{
263266
fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
264267
zFile, nLine, j, &zLine[i]);
265268
nErr++;
266269
}
267270
--- src/mkindex.c
+++ src/mkindex.c
@@ -91,10 +91,11 @@
91 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
92 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
93 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
94 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
95 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
 
96 /**************************************************************************/
97
98 /*
99 ** Each entry looks like this:
100 */
@@ -257,10 +258,12 @@
257 aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
258 }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
259 aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
260 }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
261 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
 
 
262 }else{
263 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
264 zFile, nLine, j, &zLine[i]);
265 nErr++;
266 }
267
--- src/mkindex.c
+++ src/mkindex.c
@@ -91,10 +91,11 @@
91 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
92 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
93 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
94 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
95 #define CMDFLAG_SENSITIVE 0x0400 /* Security-sensitive setting */
96 #define CMDFLAG_HIDDEN 0x0800 /* Elide from most listings */
97 /**************************************************************************/
98
99 /*
100 ** Each entry looks like this:
101 */
@@ -257,10 +258,12 @@
258 aEntry[nUsed].iWidth = atoi(&zLine[i+6]);
259 }else if( j>8 && strncmp(&zLine[i], "default=", 8)==0 ){
260 aEntry[nUsed].zDflt = string_dup(&zLine[i+8], j-8);
261 }else if( j>9 && strncmp(&zLine[i], "variable=", 9)==0 ){
262 aEntry[nUsed].zVar = string_dup(&zLine[i+9], j-9);
263 }else if( j==6 && strncmp(&zLine[i], "hidden", 6)==0 ){
264 aEntry[nUsed].eType |= CMDFLAG_HIDDEN;
265 }else{
266 fprintf(stderr, "%s:%d: unknown option: '%.*s'\n",
267 zFile, nLine, j, &zLine[i]);
268 nErr++;
269 }
270
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
11891189
cgi_set_content_type("application/json");
11901190
wiki_render_page_list_json(verbose, includeContent);
11911191
}
11921192
11931193
/*
1194
-** WEBPAGE: wikiajax
1194
+** WEBPAGE: wikiajax hidden
11951195
**
11961196
** An internal dispatcher for wiki AJAX operations. Not for direct
11971197
** client use. All routes defined by this interface are app-internal,
11981198
** subject to change
11991199
*/
12001200
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
1189 cgi_set_content_type("application/json");
1190 wiki_render_page_list_json(verbose, includeContent);
1191 }
1192
1193 /*
1194 ** WEBPAGE: wikiajax
1195 **
1196 ** An internal dispatcher for wiki AJAX operations. Not for direct
1197 ** client use. All routes defined by this interface are app-internal,
1198 ** subject to change
1199 */
1200
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
1189 cgi_set_content_type("application/json");
1190 wiki_render_page_list_json(verbose, includeContent);
1191 }
1192
1193 /*
1194 ** WEBPAGE: wikiajax hidden
1195 **
1196 ** An internal dispatcher for wiki AJAX operations. Not for direct
1197 ** client use. All routes defined by this interface are app-internal,
1198 ** subject to change
1199 */
1200
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
11891189
cgi_set_content_type("application/json");
11901190
wiki_render_page_list_json(verbose, includeContent);
11911191
}
11921192
11931193
/*
1194
-** WEBPAGE: wikiajax
1194
+** WEBPAGE: wikiajax hidden
11951195
**
11961196
** An internal dispatcher for wiki AJAX operations. Not for direct
11971197
** client use. All routes defined by this interface are app-internal,
11981198
** subject to change
11991199
*/
12001200
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
1189 cgi_set_content_type("application/json");
1190 wiki_render_page_list_json(verbose, includeContent);
1191 }
1192
1193 /*
1194 ** WEBPAGE: wikiajax
1195 **
1196 ** An internal dispatcher for wiki AJAX operations. Not for direct
1197 ** client use. All routes defined by this interface are app-internal,
1198 ** subject to change
1199 */
1200
--- src/wiki.c
+++ src/wiki.c
@@ -1189,11 +1189,11 @@
1189 cgi_set_content_type("application/json");
1190 wiki_render_page_list_json(verbose, includeContent);
1191 }
1192
1193 /*
1194 ** WEBPAGE: wikiajax hidden
1195 **
1196 ** An internal dispatcher for wiki AJAX operations. Not for direct
1197 ** client use. All routes defined by this interface are app-internal,
1198 ** subject to change
1199 */
1200

Keyboard Shortcuts

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