Fossil SCM

Integrate the small-fixes branch. Change auto-shun setting's default from on to off to match what the code does.

stephan 2026-11-13 20:54 UTC trunk merge
Commit 0e1be49ef018af100323faf909618a8d0d76cc8ad87cc4219f1f5e72221c99d4
+27 -11
--- src/attach.c
+++ src/attach.c
@@ -177,11 +177,12 @@
177177
int attach_user_may(int rid, int eArtifactType){
178178
if( g.perm.Admin ) return 1;
179179
if( !login_is_individual() ) return 0;
180180
switch(eArtifactType){
181181
case CFTYPE_FORUM:
182
- return g.perm.AttachForum && forumpost_is_owner(rid, 0);
182
+ return (g.perm.AttachForum || g.perm.WrTForum)
183
+ && forumpost_is_owner(rid, 0);
183184
case CFTYPE_WIKI:
184185
return g.perm.ApndWiki && g.perm.Attach;
185186
case CFTYPE_TICKET:
186187
return g.perm.ApndTkt && g.perm.Attach;
187188
case CFTYPE_EVENT:
@@ -645,11 +646,11 @@
645646
char *zTargetType = 0;
646647
char *zExtraFree = 0;
647648
int szContent;
648649
int goodCaptcha = 1;
649650
int szLimit = 0;
650
-
651
+ int bNeedsModeration = -1; /* -1==don't yet know */
651652
if( P("target")!=0 ){
652653
attachaddV2_page();
653654
return;
654655
}
655656
zPage = P("page");
@@ -670,12 +671,16 @@
670671
}
671672
login_check_credentials();
672673
if( zForumPost ){
673674
int fpid;
674675
if( g.perm.AttachForum==0 ){
675
- login_needed(g.anon.AttachForum);
676
- return;
676
+ if( g.perm.WrTForum ){
677
+ bNeedsModeration = 1;
678
+ }else{
679
+ login_needed(g.anon.AttachForum);
680
+ return;
681
+ }
677682
}
678683
fpid = forumpost_head_rid2(zForumPost);
679684
if( fpid<=0 ){
680685
webpage_error("Invalid forum post ID: %h", zForumPost);
681686
}else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -737,14 +742,17 @@
737742
/* Fall through and render form. */
738743
}else if( P("ok")
739744
&& cgi_csrf_safe(2)
740745
&& szContent>0
741746
&& (goodCaptcha = captcha_is_correct(0)) ){
742
- int needModerator = (zForumPost!=0 && forum_need_moderation()) ||
743
- (zTkt!=0 && ticket_need_moderation(0)) ||
744
- (zPage!=0 && wiki_need_moderation(0));
745
- attach_commit(zName, zTarget, aContent, szContent, needModerator, zComment);
747
+ if( bNeedsModeration<0 ){
748
+ bNeedsModeration = (zForumPost!=0 && forum_need_moderation()) ||
749
+ (zTkt!=0 && ticket_need_moderation(0)) ||
750
+ (zPage!=0 && wiki_need_moderation(0));
751
+ }
752
+ attach_commit(zName, zTarget, aContent, szContent,
753
+ bNeedsModeration, zComment);
746754
cgi_redirect(zTo ? zTo : zFrom);
747755
}
748756
749757
style_set_current_feature("attach");
750758
style_header("Add Attachment");
@@ -804,11 +812,17 @@
804812
db_rollback_transaction();
805813
return;
806814
case CFTYPE_FORUM:{
807815
int fpid;
808816
if( g.perm.AttachForum==0 ){
809
- goto ajax_err_403;
817
+ if( g.perm.WrTForum ){
818
+ bNeedsModeration = 1;
819
+ }else{
820
+ goto ajax_err_403;
821
+ }
822
+ }else{
823
+ bNeedsModeration = -1;
810824
}
811825
fpid = forumpost_head_rid2(zTarget);
812826
if( fpid<=0 ){
813827
goto ajax_err_404;
814828
}else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -816,11 +830,13 @@
816830
"other users' forum posts.");
817831
db_rollback_transaction();
818832
return;
819833
}
820834
zTarget = zExtraFree = rid_to_uuid(fpid);
821
- bNeedsModeration = forum_need_moderation();
835
+ if( bNeedsModeration < 0 ){
836
+ bNeedsModeration = forum_need_moderation();
837
+ }
822838
break;
823839
}
824840
case CFTYPE_EVENT:{
825841
if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){
826842
goto ajax_err_403;
@@ -1006,11 +1022,11 @@
10061022
case 0:
10071023
webpage_error("Cannot resolve target=%h.", zTarget);
10081024
break;
10091025
case CFTYPE_FORUM:{
10101026
int fpid;
1011
- if( g.perm.AttachForum==0 ){
1027
+ if( 0==g.perm.AttachForum && 0==g.perm.WrTForum ){
10121028
login_needed(g.anon.AttachForum);
10131029
return;
10141030
}
10151031
fpid = forumpost_head_rid2(zTarget);
10161032
if( fpid<=0 ){
10171033
--- src/attach.c
+++ src/attach.c
@@ -177,11 +177,12 @@
177 int attach_user_may(int rid, int eArtifactType){
178 if( g.perm.Admin ) return 1;
179 if( !login_is_individual() ) return 0;
180 switch(eArtifactType){
181 case CFTYPE_FORUM:
182 return g.perm.AttachForum && forumpost_is_owner(rid, 0);
 
183 case CFTYPE_WIKI:
184 return g.perm.ApndWiki && g.perm.Attach;
185 case CFTYPE_TICKET:
186 return g.perm.ApndTkt && g.perm.Attach;
187 case CFTYPE_EVENT:
@@ -645,11 +646,11 @@
645 char *zTargetType = 0;
646 char *zExtraFree = 0;
647 int szContent;
648 int goodCaptcha = 1;
649 int szLimit = 0;
650
651 if( P("target")!=0 ){
652 attachaddV2_page();
653 return;
654 }
655 zPage = P("page");
@@ -670,12 +671,16 @@
670 }
671 login_check_credentials();
672 if( zForumPost ){
673 int fpid;
674 if( g.perm.AttachForum==0 ){
675 login_needed(g.anon.AttachForum);
676 return;
 
 
 
 
677 }
678 fpid = forumpost_head_rid2(zForumPost);
679 if( fpid<=0 ){
680 webpage_error("Invalid forum post ID: %h", zForumPost);
681 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -737,14 +742,17 @@
737 /* Fall through and render form. */
738 }else if( P("ok")
739 && cgi_csrf_safe(2)
740 && szContent>0
741 && (goodCaptcha = captcha_is_correct(0)) ){
742 int needModerator = (zForumPost!=0 && forum_need_moderation()) ||
743 (zTkt!=0 && ticket_need_moderation(0)) ||
744 (zPage!=0 && wiki_need_moderation(0));
745 attach_commit(zName, zTarget, aContent, szContent, needModerator, zComment);
 
 
 
746 cgi_redirect(zTo ? zTo : zFrom);
747 }
748
749 style_set_current_feature("attach");
750 style_header("Add Attachment");
@@ -804,11 +812,17 @@
804 db_rollback_transaction();
805 return;
806 case CFTYPE_FORUM:{
807 int fpid;
808 if( g.perm.AttachForum==0 ){
809 goto ajax_err_403;
 
 
 
 
 
 
810 }
811 fpid = forumpost_head_rid2(zTarget);
812 if( fpid<=0 ){
813 goto ajax_err_404;
814 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -816,11 +830,13 @@
816 "other users' forum posts.");
817 db_rollback_transaction();
818 return;
819 }
820 zTarget = zExtraFree = rid_to_uuid(fpid);
821 bNeedsModeration = forum_need_moderation();
 
 
822 break;
823 }
824 case CFTYPE_EVENT:{
825 if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){
826 goto ajax_err_403;
@@ -1006,11 +1022,11 @@
1006 case 0:
1007 webpage_error("Cannot resolve target=%h.", zTarget);
1008 break;
1009 case CFTYPE_FORUM:{
1010 int fpid;
1011 if( g.perm.AttachForum==0 ){
1012 login_needed(g.anon.AttachForum);
1013 return;
1014 }
1015 fpid = forumpost_head_rid2(zTarget);
1016 if( fpid<=0 ){
1017
--- src/attach.c
+++ src/attach.c
@@ -177,11 +177,12 @@
177 int attach_user_may(int rid, int eArtifactType){
178 if( g.perm.Admin ) return 1;
179 if( !login_is_individual() ) return 0;
180 switch(eArtifactType){
181 case CFTYPE_FORUM:
182 return (g.perm.AttachForum || g.perm.WrTForum)
183 && forumpost_is_owner(rid, 0);
184 case CFTYPE_WIKI:
185 return g.perm.ApndWiki && g.perm.Attach;
186 case CFTYPE_TICKET:
187 return g.perm.ApndTkt && g.perm.Attach;
188 case CFTYPE_EVENT:
@@ -645,11 +646,11 @@
646 char *zTargetType = 0;
647 char *zExtraFree = 0;
648 int szContent;
649 int goodCaptcha = 1;
650 int szLimit = 0;
651 int bNeedsModeration = -1; /* -1==don't yet know */
652 if( P("target")!=0 ){
653 attachaddV2_page();
654 return;
655 }
656 zPage = P("page");
@@ -670,12 +671,16 @@
671 }
672 login_check_credentials();
673 if( zForumPost ){
674 int fpid;
675 if( g.perm.AttachForum==0 ){
676 if( g.perm.WrTForum ){
677 bNeedsModeration = 1;
678 }else{
679 login_needed(g.anon.AttachForum);
680 return;
681 }
682 }
683 fpid = forumpost_head_rid2(zForumPost);
684 if( fpid<=0 ){
685 webpage_error("Invalid forum post ID: %h", zForumPost);
686 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -737,14 +742,17 @@
742 /* Fall through and render form. */
743 }else if( P("ok")
744 && cgi_csrf_safe(2)
745 && szContent>0
746 && (goodCaptcha = captcha_is_correct(0)) ){
747 if( bNeedsModeration<0 ){
748 bNeedsModeration = (zForumPost!=0 && forum_need_moderation()) ||
749 (zTkt!=0 && ticket_need_moderation(0)) ||
750 (zPage!=0 && wiki_need_moderation(0));
751 }
752 attach_commit(zName, zTarget, aContent, szContent,
753 bNeedsModeration, zComment);
754 cgi_redirect(zTo ? zTo : zFrom);
755 }
756
757 style_set_current_feature("attach");
758 style_header("Add Attachment");
@@ -804,11 +812,17 @@
812 db_rollback_transaction();
813 return;
814 case CFTYPE_FORUM:{
815 int fpid;
816 if( g.perm.AttachForum==0 ){
817 if( g.perm.WrTForum ){
818 bNeedsModeration = 1;
819 }else{
820 goto ajax_err_403;
821 }
822 }else{
823 bNeedsModeration = -1;
824 }
825 fpid = forumpost_head_rid2(zTarget);
826 if( fpid<=0 ){
827 goto ajax_err_404;
828 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
@@ -816,11 +830,13 @@
830 "other users' forum posts.");
831 db_rollback_transaction();
832 return;
833 }
834 zTarget = zExtraFree = rid_to_uuid(fpid);
835 if( bNeedsModeration < 0 ){
836 bNeedsModeration = forum_need_moderation();
837 }
838 break;
839 }
840 case CFTYPE_EVENT:{
841 if( g.perm.Write==0 || g.perm.ApndWiki==0 || g.perm.Attach==0 ){
842 goto ajax_err_403;
@@ -1006,11 +1022,11 @@
1022 case 0:
1023 webpage_error("Cannot resolve target=%h.", zTarget);
1024 break;
1025 case CFTYPE_FORUM:{
1026 int fpid;
1027 if( 0==g.perm.AttachForum && 0==g.perm.WrTForum ){
1028 login_needed(g.anon.AttachForum);
1029 return;
1030 }
1031 fpid = forumpost_head_rid2(zTarget);
1032 if( fpid<=0 ){
1033
+6 -1
--- src/builtin.c
+++ src/builtin.c
@@ -697,11 +697,16 @@
697697
CX("};\n"/*window.fossil.config.forum*/);
698698
#define JBOOL(COND) ((COND) ? "true" : "false")
699699
CX("window.fossil.user = {");
700700
CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest");
701701
CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup));
702
- CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum));
702
+ CX("mayAttachForum: %d,", g.perm.AttachForum
703
+ ? 1 : (g.perm.WrTForum
704
+ ? -1 : 0))
705
+ /* 0 = no, 1 = 'B' permissions,
706
+ ** -1 = moderated attachments. Potential TODO is a setting
707
+ ** to enable this. */;
703708
CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin));
704709
CX("isIndividual: %s", JBOOL(login_is_individual()));
705710
CX("};\n"/*fossil.user*/);
706711
{ /* Workaround for cases like:
707712
** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8
708713
--- src/builtin.c
+++ src/builtin.c
@@ -697,11 +697,16 @@
697 CX("};\n"/*window.fossil.config.forum*/);
698 #define JBOOL(COND) ((COND) ? "true" : "false")
699 CX("window.fossil.user = {");
700 CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest");
701 CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup));
702 CX("mayAttachForum: %s,", JBOOL(g.perm.AttachForum));
 
 
 
 
 
703 CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin));
704 CX("isIndividual: %s", JBOOL(login_is_individual()));
705 CX("};\n"/*fossil.user*/);
706 { /* Workaround for cases like:
707 ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8
708
--- src/builtin.c
+++ src/builtin.c
@@ -697,11 +697,16 @@
697 CX("};\n"/*window.fossil.config.forum*/);
698 #define JBOOL(COND) ((COND) ? "true" : "false")
699 CX("window.fossil.user = {");
700 CX("name: %!j,", (g.zLogin&&*g.zLogin) ? g.zLogin : "guest");
701 CX("isAdmin: %s,", JBOOL(g.perm.Admin || g.perm.Setup));
702 CX("mayAttachForum: %d,", g.perm.AttachForum
703 ? 1 : (g.perm.WrTForum
704 ? -1 : 0))
705 /* 0 = no, 1 = 'B' permissions,
706 ** -1 = moderated attachments. Potential TODO is a setting
707 ** to enable this. */;
708 CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin));
709 CX("isIndividual: %s", JBOOL(login_is_individual()));
710 CX("};\n"/*fossil.user*/);
711 { /* Workaround for cases like:
712 ** https://fossil-scm.org/forum/forumpost/31cc00b361496cb8
713
+19 -3
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989989
**
990990
** Verify that all content can be extracted from the BLOB table correctly.
991991
** If the BLOB table is correct, then the repository can always be
992992
** successfully reconstructed using "fossil rebuild".
993993
**
994
+** The exit status is 1 if any error is found.
995
+**
994996
** Options:
995997
** -d|--db-only Run "PRAGMA integrity_check" on the database only.
996998
** No other validation is performed.
997999
** --parse Parse all manifests, wikis, tickets, events, and
9981000
** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
10111013
int nPhantom = 0;
10121014
int anCA[10];
10131015
int bParse = find_option("parse",0,0)!=0;
10141016
int bDbOnly = find_option("db-only","d",0)!=0;
10151017
int bQuick = find_option("quick",0,0)!=0;
1018
+ char *zRes;
10161019
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
10171020
if( bDbOnly || bQuick ){
10181021
const char *zType = bQuick ? "quick" : "integrity";
1019
- char *zRes;
10201022
zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
10211023
if( fossil_strcmp(zRes,"ok")!=0 ){
10221024
fossil_print("%s_check failed!\n", zType);
10231025
exit(1);
10241026
}else{
@@ -1091,10 +1093,19 @@
10911093
p = manifest_parse(&content, 0, &err);
10921094
if( p==0 ){
10931095
fossil_print("\nmanifest_parse failed for %s:\n%s\n",
10941096
zUuid, blob_str(&err));
10951097
nParseErr++;
1098
+ /* An ordinary file can look like a control artifact and fail to
1099
+ ** parse. That is an error only if the repository has it down
1100
+ ** as a check-in, wiki page, ticket or the like, or as a cluster. */
1101
+ if( db_exists("SELECT 1 FROM event WHERE objid=%d"
1102
+ " UNION ALL"
1103
+ " SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1104
+ rid, rid, TAG_CLUSTER) ){
1105
+ nErr++;
1106
+ }
10961107
if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
10971108
fossil_print("\"%s\"\n", zFirstLine);
10981109
}
10991110
}else{
11001111
anCA[p->type]++;
@@ -1123,11 +1134,15 @@
11231134
for(i=1; i<count(azType); i++){
11241135
if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
11251136
}
11261137
}
11271138
fossil_print("low-level database integrity-check: ");
1128
- fossil_print("%s\n", db_text(0, "PRAGMA integrity_check(10)"));
1139
+ zRes = db_text(0, "PRAGMA repository.integrity_check(10)");
1140
+ fossil_print("%s\n", zRes);
1141
+ if( fossil_strcmp(zRes,"ok")!=0 ) nErr++;
1142
+ fossil_free(zRes);
1143
+ if( nErr ) fossil_exit(1);
11291144
}
11301145
11311146
/*
11321147
** COMMAND: test-orphans
11331148
**
@@ -1234,11 +1249,11 @@
12341249
**
12351250
** Usage: %fossil test-missing
12361251
**
12371252
** Look at every artifact in the repository and verify that
12381253
** all references are satisfied. Report any referenced artifacts
1239
-** that are missing or shunned.
1254
+** that are missing or shunned. The exit status is 1 if any are found.
12401255
**
12411256
** Options:
12421257
** --notshunned Do not report shunned artifacts
12431258
** -q|--quiet Only show output if there are errors
12441259
*/
@@ -1294,10 +1309,11 @@
12941309
db_finalize(&q);
12951310
if( nErr>0 || quietFlag==0 ){
12961311
fossil_print("%d missing or shunned references in %d control artifacts\n",
12971312
nErr, nArtifact);
12981313
}
1314
+ if( nErr ) fossil_exit(1);
12991315
}
13001316
13011317
/*
13021318
** COMMAND: test-content-erase
13031319
**
13041320
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989 **
990 ** Verify that all content can be extracted from the BLOB table correctly.
991 ** If the BLOB table is correct, then the repository can always be
992 ** successfully reconstructed using "fossil rebuild".
993 **
 
 
994 ** Options:
995 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
996 ** No other validation is performed.
997 ** --parse Parse all manifests, wikis, tickets, events, and
998 ** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
1011 int nPhantom = 0;
1012 int anCA[10];
1013 int bParse = find_option("parse",0,0)!=0;
1014 int bDbOnly = find_option("db-only","d",0)!=0;
1015 int bQuick = find_option("quick",0,0)!=0;
 
1016 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
1017 if( bDbOnly || bQuick ){
1018 const char *zType = bQuick ? "quick" : "integrity";
1019 char *zRes;
1020 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
1021 if( fossil_strcmp(zRes,"ok")!=0 ){
1022 fossil_print("%s_check failed!\n", zType);
1023 exit(1);
1024 }else{
@@ -1091,10 +1093,19 @@
1091 p = manifest_parse(&content, 0, &err);
1092 if( p==0 ){
1093 fossil_print("\nmanifest_parse failed for %s:\n%s\n",
1094 zUuid, blob_str(&err));
1095 nParseErr++;
 
 
 
 
 
 
 
 
 
1096 if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
1097 fossil_print("\"%s\"\n", zFirstLine);
1098 }
1099 }else{
1100 anCA[p->type]++;
@@ -1123,11 +1134,15 @@
1123 for(i=1; i<count(azType); i++){
1124 if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
1125 }
1126 }
1127 fossil_print("low-level database integrity-check: ");
1128 fossil_print("%s\n", db_text(0, "PRAGMA integrity_check(10)"));
 
 
 
 
1129 }
1130
1131 /*
1132 ** COMMAND: test-orphans
1133 **
@@ -1234,11 +1249,11 @@
1234 **
1235 ** Usage: %fossil test-missing
1236 **
1237 ** Look at every artifact in the repository and verify that
1238 ** all references are satisfied. Report any referenced artifacts
1239 ** that are missing or shunned.
1240 **
1241 ** Options:
1242 ** --notshunned Do not report shunned artifacts
1243 ** -q|--quiet Only show output if there are errors
1244 */
@@ -1294,10 +1309,11 @@
1294 db_finalize(&q);
1295 if( nErr>0 || quietFlag==0 ){
1296 fossil_print("%d missing or shunned references in %d control artifacts\n",
1297 nErr, nArtifact);
1298 }
 
1299 }
1300
1301 /*
1302 ** COMMAND: test-content-erase
1303 **
1304
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989 **
990 ** Verify that all content can be extracted from the BLOB table correctly.
991 ** If the BLOB table is correct, then the repository can always be
992 ** successfully reconstructed using "fossil rebuild".
993 **
994 ** The exit status is 1 if any error is found.
995 **
996 ** Options:
997 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
998 ** No other validation is performed.
999 ** --parse Parse all manifests, wikis, tickets, events, and
1000 ** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
1013 int nPhantom = 0;
1014 int anCA[10];
1015 int bParse = find_option("parse",0,0)!=0;
1016 int bDbOnly = find_option("db-only","d",0)!=0;
1017 int bQuick = find_option("quick",0,0)!=0;
1018 char *zRes;
1019 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
1020 if( bDbOnly || bQuick ){
1021 const char *zType = bQuick ? "quick" : "integrity";
 
1022 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
1023 if( fossil_strcmp(zRes,"ok")!=0 ){
1024 fossil_print("%s_check failed!\n", zType);
1025 exit(1);
1026 }else{
@@ -1091,10 +1093,19 @@
1093 p = manifest_parse(&content, 0, &err);
1094 if( p==0 ){
1095 fossil_print("\nmanifest_parse failed for %s:\n%s\n",
1096 zUuid, blob_str(&err));
1097 nParseErr++;
1098 /* An ordinary file can look like a control artifact and fail to
1099 ** parse. That is an error only if the repository has it down
1100 ** as a check-in, wiki page, ticket or the like, or as a cluster. */
1101 if( db_exists("SELECT 1 FROM event WHERE objid=%d"
1102 " UNION ALL"
1103 " SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1104 rid, rid, TAG_CLUSTER) ){
1105 nErr++;
1106 }
1107 if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
1108 fossil_print("\"%s\"\n", zFirstLine);
1109 }
1110 }else{
1111 anCA[p->type]++;
@@ -1123,11 +1134,15 @@
1134 for(i=1; i<count(azType); i++){
1135 if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
1136 }
1137 }
1138 fossil_print("low-level database integrity-check: ");
1139 zRes = db_text(0, "PRAGMA repository.integrity_check(10)");
1140 fossil_print("%s\n", zRes);
1141 if( fossil_strcmp(zRes,"ok")!=0 ) nErr++;
1142 fossil_free(zRes);
1143 if( nErr ) fossil_exit(1);
1144 }
1145
1146 /*
1147 ** COMMAND: test-orphans
1148 **
@@ -1234,11 +1249,11 @@
1249 **
1250 ** Usage: %fossil test-missing
1251 **
1252 ** Look at every artifact in the repository and verify that
1253 ** all references are satisfied. Report any referenced artifacts
1254 ** that are missing or shunned. The exit status is 1 if any are found.
1255 **
1256 ** Options:
1257 ** --notshunned Do not report shunned artifacts
1258 ** -q|--quiet Only show output if there are errors
1259 */
@@ -1294,10 +1309,11 @@
1309 db_finalize(&q);
1310 if( nErr>0 || quietFlag==0 ){
1311 fossil_print("%d missing or shunned references in %d control artifacts\n",
1312 nErr, nArtifact);
1313 }
1314 if( nErr ) fossil_exit(1);
1315 }
1316
1317 /*
1318 ** COMMAND: test-content-erase
1319 **
1320
+19 -3
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989989
**
990990
** Verify that all content can be extracted from the BLOB table correctly.
991991
** If the BLOB table is correct, then the repository can always be
992992
** successfully reconstructed using "fossil rebuild".
993993
**
994
+** The exit status is 1 if any error is found.
995
+**
994996
** Options:
995997
** -d|--db-only Run "PRAGMA integrity_check" on the database only.
996998
** No other validation is performed.
997999
** --parse Parse all manifests, wikis, tickets, events, and
9981000
** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
10111013
int nPhantom = 0;
10121014
int anCA[10];
10131015
int bParse = find_option("parse",0,0)!=0;
10141016
int bDbOnly = find_option("db-only","d",0)!=0;
10151017
int bQuick = find_option("quick",0,0)!=0;
1018
+ char *zRes;
10161019
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
10171020
if( bDbOnly || bQuick ){
10181021
const char *zType = bQuick ? "quick" : "integrity";
1019
- char *zRes;
10201022
zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
10211023
if( fossil_strcmp(zRes,"ok")!=0 ){
10221024
fossil_print("%s_check failed!\n", zType);
10231025
exit(1);
10241026
}else{
@@ -1091,10 +1093,19 @@
10911093
p = manifest_parse(&content, 0, &err);
10921094
if( p==0 ){
10931095
fossil_print("\nmanifest_parse failed for %s:\n%s\n",
10941096
zUuid, blob_str(&err));
10951097
nParseErr++;
1098
+ /* An ordinary file can look like a control artifact and fail to
1099
+ ** parse. That is an error only if the repository has it down
1100
+ ** as a check-in, wiki page, ticket or the like, or as a cluster. */
1101
+ if( db_exists("SELECT 1 FROM event WHERE objid=%d"
1102
+ " UNION ALL"
1103
+ " SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1104
+ rid, rid, TAG_CLUSTER) ){
1105
+ nErr++;
1106
+ }
10961107
if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
10971108
fossil_print("\"%s\"\n", zFirstLine);
10981109
}
10991110
}else{
11001111
anCA[p->type]++;
@@ -1123,11 +1134,15 @@
11231134
for(i=1; i<count(azType); i++){
11241135
if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
11251136
}
11261137
}
11271138
fossil_print("low-level database integrity-check: ");
1128
- fossil_print("%s\n", db_text(0, "PRAGMA integrity_check(10)"));
1139
+ zRes = db_text(0, "PRAGMA repository.integrity_check(10)");
1140
+ fossil_print("%s\n", zRes);
1141
+ if( fossil_strcmp(zRes,"ok")!=0 ) nErr++;
1142
+ fossil_free(zRes);
1143
+ if( nErr ) fossil_exit(1);
11291144
}
11301145
11311146
/*
11321147
** COMMAND: test-orphans
11331148
**
@@ -1234,11 +1249,11 @@
12341249
**
12351250
** Usage: %fossil test-missing
12361251
**
12371252
** Look at every artifact in the repository and verify that
12381253
** all references are satisfied. Report any referenced artifacts
1239
-** that are missing or shunned.
1254
+** that are missing or shunned. The exit status is 1 if any are found.
12401255
**
12411256
** Options:
12421257
** --notshunned Do not report shunned artifacts
12431258
** -q|--quiet Only show output if there are errors
12441259
*/
@@ -1294,10 +1309,11 @@
12941309
db_finalize(&q);
12951310
if( nErr>0 || quietFlag==0 ){
12961311
fossil_print("%d missing or shunned references in %d control artifacts\n",
12971312
nErr, nArtifact);
12981313
}
1314
+ if( nErr ) fossil_exit(1);
12991315
}
13001316
13011317
/*
13021318
** COMMAND: test-content-erase
13031319
**
13041320
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989 **
990 ** Verify that all content can be extracted from the BLOB table correctly.
991 ** If the BLOB table is correct, then the repository can always be
992 ** successfully reconstructed using "fossil rebuild".
993 **
 
 
994 ** Options:
995 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
996 ** No other validation is performed.
997 ** --parse Parse all manifests, wikis, tickets, events, and
998 ** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
1011 int nPhantom = 0;
1012 int anCA[10];
1013 int bParse = find_option("parse",0,0)!=0;
1014 int bDbOnly = find_option("db-only","d",0)!=0;
1015 int bQuick = find_option("quick",0,0)!=0;
 
1016 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
1017 if( bDbOnly || bQuick ){
1018 const char *zType = bQuick ? "quick" : "integrity";
1019 char *zRes;
1020 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
1021 if( fossil_strcmp(zRes,"ok")!=0 ){
1022 fossil_print("%s_check failed!\n", zType);
1023 exit(1);
1024 }else{
@@ -1091,10 +1093,19 @@
1091 p = manifest_parse(&content, 0, &err);
1092 if( p==0 ){
1093 fossil_print("\nmanifest_parse failed for %s:\n%s\n",
1094 zUuid, blob_str(&err));
1095 nParseErr++;
 
 
 
 
 
 
 
 
 
1096 if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
1097 fossil_print("\"%s\"\n", zFirstLine);
1098 }
1099 }else{
1100 anCA[p->type]++;
@@ -1123,11 +1134,15 @@
1123 for(i=1; i<count(azType); i++){
1124 if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
1125 }
1126 }
1127 fossil_print("low-level database integrity-check: ");
1128 fossil_print("%s\n", db_text(0, "PRAGMA integrity_check(10)"));
 
 
 
 
1129 }
1130
1131 /*
1132 ** COMMAND: test-orphans
1133 **
@@ -1234,11 +1249,11 @@
1234 **
1235 ** Usage: %fossil test-missing
1236 **
1237 ** Look at every artifact in the repository and verify that
1238 ** all references are satisfied. Report any referenced artifacts
1239 ** that are missing or shunned.
1240 **
1241 ** Options:
1242 ** --notshunned Do not report shunned artifacts
1243 ** -q|--quiet Only show output if there are errors
1244 */
@@ -1294,10 +1309,11 @@
1294 db_finalize(&q);
1295 if( nErr>0 || quietFlag==0 ){
1296 fossil_print("%d missing or shunned references in %d control artifacts\n",
1297 nErr, nArtifact);
1298 }
 
1299 }
1300
1301 /*
1302 ** COMMAND: test-content-erase
1303 **
1304
--- src/content.c
+++ src/content.c
@@ -989,10 +989,12 @@
989 **
990 ** Verify that all content can be extracted from the BLOB table correctly.
991 ** If the BLOB table is correct, then the repository can always be
992 ** successfully reconstructed using "fossil rebuild".
993 **
994 ** The exit status is 1 if any error is found.
995 **
996 ** Options:
997 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
998 ** No other validation is performed.
999 ** --parse Parse all manifests, wikis, tickets, events, and
1000 ** so forth, reporting any errors found.
@@ -1011,14 +1013,14 @@
1013 int nPhantom = 0;
1014 int anCA[10];
1015 int bParse = find_option("parse",0,0)!=0;
1016 int bDbOnly = find_option("db-only","d",0)!=0;
1017 int bQuick = find_option("quick",0,0)!=0;
1018 char *zRes;
1019 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
1020 if( bDbOnly || bQuick ){
1021 const char *zType = bQuick ? "quick" : "integrity";
 
1022 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
1023 if( fossil_strcmp(zRes,"ok")!=0 ){
1024 fossil_print("%s_check failed!\n", zType);
1025 exit(1);
1026 }else{
@@ -1091,10 +1093,19 @@
1093 p = manifest_parse(&content, 0, &err);
1094 if( p==0 ){
1095 fossil_print("\nmanifest_parse failed for %s:\n%s\n",
1096 zUuid, blob_str(&err));
1097 nParseErr++;
1098 /* An ordinary file can look like a control artifact and fail to
1099 ** parse. That is an error only if the repository has it down
1100 ** as a check-in, wiki page, ticket or the like, or as a cluster. */
1101 if( db_exists("SELECT 1 FROM event WHERE objid=%d"
1102 " UNION ALL"
1103 " SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1104 rid, rid, TAG_CLUSTER) ){
1105 nErr++;
1106 }
1107 if( strncmp(blob_str(&err), "line 1:", 7)==0 ){
1108 fossil_print("\"%s\"\n", zFirstLine);
1109 }
1110 }else{
1111 anCA[p->type]++;
@@ -1123,11 +1134,15 @@
1134 for(i=1; i<count(azType); i++){
1135 if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]);
1136 }
1137 }
1138 fossil_print("low-level database integrity-check: ");
1139 zRes = db_text(0, "PRAGMA repository.integrity_check(10)");
1140 fossil_print("%s\n", zRes);
1141 if( fossil_strcmp(zRes,"ok")!=0 ) nErr++;
1142 fossil_free(zRes);
1143 if( nErr ) fossil_exit(1);
1144 }
1145
1146 /*
1147 ** COMMAND: test-orphans
1148 **
@@ -1234,11 +1249,11 @@
1249 **
1250 ** Usage: %fossil test-missing
1251 **
1252 ** Look at every artifact in the repository and verify that
1253 ** all references are satisfied. Report any referenced artifacts
1254 ** that are missing or shunned. The exit status is 1 if any are found.
1255 **
1256 ** Options:
1257 ** --notshunned Do not report shunned artifacts
1258 ** -q|--quiet Only show output if there are errors
1259 */
@@ -1294,10 +1309,11 @@
1309 db_finalize(&q);
1310 if( nErr>0 || quietFlag==0 ){
1311 fossil_print("%d missing or shunned references in %d control artifacts\n",
1312 nErr, nArtifact);
1313 }
1314 if( nErr ) fossil_exit(1);
1315 }
1316
1317 /*
1318 ** COMMAND: test-content-erase
1319 **
1320
+10 -1
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
46764676
** until either a mousedown or mousemove event is seen. This helps
46774677
** to distinguish real users from robots. For maximum robot defense,
46784678
** the recommended setting is ON.
46794679
*/
46804680
/*
4681
-** SETTING: auto-shun boolean default=on
4681
+** SETTING: auto-shun boolean default=off
46824682
** If enabled, automatically pull the shunning list
46834683
** from a server to which the client autosyncs.
46844684
*/
46854685
/*
46864686
** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
49274927
/*
49284928
** SETTING: http-port width=16 default=8080
49294929
** The default TCP/IP port number to use by the "server"
49304930
** and "ui" commands.
49314931
*/
4932
+/*
4933
+** SETTING: hide-by-user width=40 block-text
4934
+** The VALUE of this setting is a list of GLOB patterns. On the /timeline
4935
+** page, any check-in whose user login name matches one of these patterns
4936
+** is treated as if it carried the "hidden" tag, and is omitted unless the
4937
+** "unhide=on" query parameter is used. Example: bot-*,*-robot
4938
+** The parsing rules are complex; see
4939
+** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4940
+*/
49324941
/*
49334942
** SETTING: https-login boolean default=off
49344943
** If true, then the Fossil web server will redirect unencrypted
49354944
** login screen requests to HTTPS.
49364945
*/
49374946
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
4676 ** until either a mousedown or mousemove event is seen. This helps
4677 ** to distinguish real users from robots. For maximum robot defense,
4678 ** the recommended setting is ON.
4679 */
4680 /*
4681 ** SETTING: auto-shun boolean default=on
4682 ** If enabled, automatically pull the shunning list
4683 ** from a server to which the client autosyncs.
4684 */
4685 /*
4686 ** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
4927 /*
4928 ** SETTING: http-port width=16 default=8080
4929 ** The default TCP/IP port number to use by the "server"
4930 ** and "ui" commands.
4931 */
 
 
 
 
 
 
 
 
 
4932 /*
4933 ** SETTING: https-login boolean default=off
4934 ** If true, then the Fossil web server will redirect unencrypted
4935 ** login screen requests to HTTPS.
4936 */
4937
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
4676 ** until either a mousedown or mousemove event is seen. This helps
4677 ** to distinguish real users from robots. For maximum robot defense,
4678 ** the recommended setting is ON.
4679 */
4680 /*
4681 ** SETTING: auto-shun boolean default=off
4682 ** If enabled, automatically pull the shunning list
4683 ** from a server to which the client autosyncs.
4684 */
4685 /*
4686 ** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
4927 /*
4928 ** SETTING: http-port width=16 default=8080
4929 ** The default TCP/IP port number to use by the "server"
4930 ** and "ui" commands.
4931 */
4932 /*
4933 ** SETTING: hide-by-user width=40 block-text
4934 ** The VALUE of this setting is a list of GLOB patterns. On the /timeline
4935 ** page, any check-in whose user login name matches one of these patterns
4936 ** is treated as if it carried the "hidden" tag, and is omitted unless the
4937 ** "unhide=on" query parameter is used. Example: bot-*,*-robot
4938 ** The parsing rules are complex; see
4939 ** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4940 */
4941 /*
4942 ** SETTING: https-login boolean default=off
4943 ** If true, then the Fossil web server will redirect unencrypted
4944 ** login screen requests to HTTPS.
4945 */
4946
+10 -1
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
46764676
** until either a mousedown or mousemove event is seen. This helps
46774677
** to distinguish real users from robots. For maximum robot defense,
46784678
** the recommended setting is ON.
46794679
*/
46804680
/*
4681
-** SETTING: auto-shun boolean default=on
4681
+** SETTING: auto-shun boolean default=off
46824682
** If enabled, automatically pull the shunning list
46834683
** from a server to which the client autosyncs.
46844684
*/
46854685
/*
46864686
** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
49274927
/*
49284928
** SETTING: http-port width=16 default=8080
49294929
** The default TCP/IP port number to use by the "server"
49304930
** and "ui" commands.
49314931
*/
4932
+/*
4933
+** SETTING: hide-by-user width=40 block-text
4934
+** The VALUE of this setting is a list of GLOB patterns. On the /timeline
4935
+** page, any check-in whose user login name matches one of these patterns
4936
+** is treated as if it carried the "hidden" tag, and is omitted unless the
4937
+** "unhide=on" query parameter is used. Example: bot-*,*-robot
4938
+** The parsing rules are complex; see
4939
+** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4940
+*/
49324941
/*
49334942
** SETTING: https-login boolean default=off
49344943
** If true, then the Fossil web server will redirect unencrypted
49354944
** login screen requests to HTTPS.
49364945
*/
49374946
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
4676 ** until either a mousedown or mousemove event is seen. This helps
4677 ** to distinguish real users from robots. For maximum robot defense,
4678 ** the recommended setting is ON.
4679 */
4680 /*
4681 ** SETTING: auto-shun boolean default=on
4682 ** If enabled, automatically pull the shunning list
4683 ** from a server to which the client autosyncs.
4684 */
4685 /*
4686 ** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
4927 /*
4928 ** SETTING: http-port width=16 default=8080
4929 ** The default TCP/IP port number to use by the "server"
4930 ** and "ui" commands.
4931 */
 
 
 
 
 
 
 
 
 
4932 /*
4933 ** SETTING: https-login boolean default=off
4934 ** If true, then the Fossil web server will redirect unencrypted
4935 ** login screen requests to HTTPS.
4936 */
4937
--- src/db.c
+++ src/db.c
@@ -4676,11 +4676,11 @@
4676 ** until either a mousedown or mousemove event is seen. This helps
4677 ** to distinguish real users from robots. For maximum robot defense,
4678 ** the recommended setting is ON.
4679 */
4680 /*
4681 ** SETTING: auto-shun boolean default=off
4682 ** If enabled, automatically pull the shunning list
4683 ** from a server to which the client autosyncs.
4684 */
4685 /*
4686 ** SETTING: autosync width=16 default=on
@@ -4927,10 +4927,19 @@
4927 /*
4928 ** SETTING: http-port width=16 default=8080
4929 ** The default TCP/IP port number to use by the "server"
4930 ** and "ui" commands.
4931 */
4932 /*
4933 ** SETTING: hide-by-user width=40 block-text
4934 ** The VALUE of this setting is a list of GLOB patterns. On the /timeline
4935 ** page, any check-in whose user login name matches one of these patterns
4936 ** is treated as if it carried the "hidden" tag, and is omitted unless the
4937 ** "unhide=on" query parameter is used. Example: bot-*,*-robot
4938 ** The parsing rules are complex; see
4939 ** https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4940 */
4941 /*
4942 ** SETTING: https-login boolean default=off
4943 ** If true, then the Fossil web server will redirect unencrypted
4944 ** login screen requests to HTTPS.
4945 */
4946
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
20192019
/* .attach* = styles for file attachments */
20202020
section.attachlist {}
20212021
details.attachlist > summary {
20222022
cursor: pointer;
20232023
}
2024
+div.forumpost > details.attachlist {
2025
+ margin-bottom: 0.5em/*else too cramped with the buttons*/;
2026
+}
20242027
/* .Attacher is the top container element used by the JS Attacher
20252028
class in fossil.attach.js. */
20262029
.Attacher {
20272030
margin-bottom: 1em;
20282031
display: flex;
20292032
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
2019 /* .attach* = styles for file attachments */
2020 section.attachlist {}
2021 details.attachlist > summary {
2022 cursor: pointer;
2023 }
 
 
 
2024 /* .Attacher is the top container element used by the JS Attacher
2025 class in fossil.attach.js. */
2026 .Attacher {
2027 margin-bottom: 1em;
2028 display: flex;
2029
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
2019 /* .attach* = styles for file attachments */
2020 section.attachlist {}
2021 details.attachlist > summary {
2022 cursor: pointer;
2023 }
2024 div.forumpost > details.attachlist {
2025 margin-bottom: 0.5em/*else too cramped with the buttons*/;
2026 }
2027 /* .Attacher is the top container element used by the JS Attacher
2028 class in fossil.attach.js. */
2029 .Attacher {
2030 margin-bottom: 1em;
2031 display: flex;
2032
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
20192019
/* .attach* = styles for file attachments */
20202020
section.attachlist {}
20212021
details.attachlist > summary {
20222022
cursor: pointer;
20232023
}
2024
+div.forumpost > details.attachlist {
2025
+ margin-bottom: 0.5em/*else too cramped with the buttons*/;
2026
+}
20242027
/* .Attacher is the top container element used by the JS Attacher
20252028
class in fossil.attach.js. */
20262029
.Attacher {
20272030
margin-bottom: 1em;
20282031
display: flex;
20292032
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
2019 /* .attach* = styles for file attachments */
2020 section.attachlist {}
2021 details.attachlist > summary {
2022 cursor: pointer;
2023 }
 
 
 
2024 /* .Attacher is the top container element used by the JS Attacher
2025 class in fossil.attach.js. */
2026 .Attacher {
2027 margin-bottom: 1em;
2028 display: flex;
2029
--- src/default.css
+++ src/default.css
@@ -2019,10 +2019,13 @@
2019 /* .attach* = styles for file attachments */
2020 section.attachlist {}
2021 details.attachlist > summary {
2022 cursor: pointer;
2023 }
2024 div.forumpost > details.attachlist {
2025 margin-bottom: 0.5em/*else too cramped with the buttons*/;
2026 }
2027 /* .Attacher is the top container element used by the JS Attacher
2028 class in fossil.attach.js. */
2029 .Attacher {
2030 margin-bottom: 1em;
2031 display: flex;
2032
+3 -3
--- src/delta.c
+++ src/delta.c
@@ -280,13 +280,13 @@
280280
}
281281
sum += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
282282
#endif
283283
}
284284
switch(N&3){
285
- case 3: sum += (z[2] << 8);
286
- case 2: sum += (z[1] << 16);
287
- case 1: sum += (z[0] << 24);
285
+ case 3: sum += ((unsigned)z[2] << 8);
286
+ case 2: sum += ((unsigned)z[1] << 16);
287
+ case 1: sum += ((unsigned)z[0] << 24);
288288
default: ;
289289
}
290290
}
291291
return sum;
292292
}
293293
--- src/delta.c
+++ src/delta.c
@@ -280,13 +280,13 @@
280 }
281 sum += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
282 #endif
283 }
284 switch(N&3){
285 case 3: sum += (z[2] << 8);
286 case 2: sum += (z[1] << 16);
287 case 1: sum += (z[0] << 24);
288 default: ;
289 }
290 }
291 return sum;
292 }
293
--- src/delta.c
+++ src/delta.c
@@ -280,13 +280,13 @@
280 }
281 sum += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);
282 #endif
283 }
284 switch(N&3){
285 case 3: sum += ((unsigned)z[2] << 8);
286 case 2: sum += ((unsigned)z[1] << 16);
287 case 1: sum += ((unsigned)z[0] << 24);
288 default: ;
289 }
290 }
291 return sum;
292 }
293
+1 -1
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -33,11 +33,11 @@
3333
blob_zero(pDelta);
3434
zOrig = blob_materialize(pOriginal);
3535
lenOrig = blob_size(pOriginal);
3636
zTarg = blob_materialize(pTarget);
3737
lenTarg = blob_size(pTarget);
38
- blob_resize(pDelta, lenTarg+16);
38
+ blob_resize(pDelta, lenTarg+60);
3939
zRes = blob_materialize(pDelta);
4040
len = delta_create(zOrig, lenOrig, zTarg, lenTarg, zRes);
4141
blob_resize(pDelta, len);
4242
return 0;
4343
}
4444
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -33,11 +33,11 @@
33 blob_zero(pDelta);
34 zOrig = blob_materialize(pOriginal);
35 lenOrig = blob_size(pOriginal);
36 zTarg = blob_materialize(pTarget);
37 lenTarg = blob_size(pTarget);
38 blob_resize(pDelta, lenTarg+16);
39 zRes = blob_materialize(pDelta);
40 len = delta_create(zOrig, lenOrig, zTarg, lenTarg, zRes);
41 blob_resize(pDelta, len);
42 return 0;
43 }
44
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -33,11 +33,11 @@
33 blob_zero(pDelta);
34 zOrig = blob_materialize(pOriginal);
35 lenOrig = blob_size(pOriginal);
36 zTarg = blob_materialize(pTarget);
37 lenTarg = blob_size(pTarget);
38 blob_resize(pDelta, lenTarg+60);
39 zRes = blob_materialize(pDelta);
40 len = delta_create(zOrig, lenOrig, zTarg, lenTarg, zRes);
41 blob_resize(pDelta, len);
42 return 0;
43 }
44
+2 -7
--- src/export.c
+++ src/export.c
@@ -1007,13 +1007,10 @@
10071007
db_reset(&sIns);
10081008
return mprintf(":%d", db_last_insert_rowid());
10091009
}
10101010
10111011
/* This is the SHA3-256 hash of an empty file */
1012
-static const char zEmptySha3[] =
1013
- "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a";
1014
-
10151012
/*
10161013
** Export a single file named by zUuid.
10171014
**
10181015
** Return 0 on success and non-zero on any failure.
10191016
**
@@ -1024,26 +1021,24 @@
10241021
*/
10251022
static int gitmirror_send_file(FILE *xCmd, const char *zUuid, int bPhantomOk){
10261023
char *zMark;
10271024
int rid;
10281025
int rc;
1029
- Blob data;
1026
+ Blob data = BLOB_INITIALIZER;
10301027
rid = fast_uuid_to_rid(zUuid);
1031
- if( rid<0 ){
1028
+ if( rid<=0 ){
10321029
if( bPhantomOk || uuid_is_shunned(zUuid) ){
10331030
gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
1034
- zUuid = zEmptySha3;
10351031
}else{
10361032
return 1;
10371033
}
10381034
}else{
10391035
rc = content_get(rid, &data);
10401036
if( rc==0 ){
10411037
if( bPhantomOk ){
10421038
blob_init(&data, 0, 0);
10431039
gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
1044
- zUuid = zEmptySha3;
10451040
}else{
10461041
return 1;
10471042
}
10481043
}
10491044
}
10501045
--- src/export.c
+++ src/export.c
@@ -1007,13 +1007,10 @@
1007 db_reset(&sIns);
1008 return mprintf(":%d", db_last_insert_rowid());
1009 }
1010
1011 /* This is the SHA3-256 hash of an empty file */
1012 static const char zEmptySha3[] =
1013 "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a";
1014
1015 /*
1016 ** Export a single file named by zUuid.
1017 **
1018 ** Return 0 on success and non-zero on any failure.
1019 **
@@ -1024,26 +1021,24 @@
1024 */
1025 static int gitmirror_send_file(FILE *xCmd, const char *zUuid, int bPhantomOk){
1026 char *zMark;
1027 int rid;
1028 int rc;
1029 Blob data;
1030 rid = fast_uuid_to_rid(zUuid);
1031 if( rid<0 ){
1032 if( bPhantomOk || uuid_is_shunned(zUuid) ){
1033 gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
1034 zUuid = zEmptySha3;
1035 }else{
1036 return 1;
1037 }
1038 }else{
1039 rc = content_get(rid, &data);
1040 if( rc==0 ){
1041 if( bPhantomOk ){
1042 blob_init(&data, 0, 0);
1043 gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
1044 zUuid = zEmptySha3;
1045 }else{
1046 return 1;
1047 }
1048 }
1049 }
1050
--- src/export.c
+++ src/export.c
@@ -1007,13 +1007,10 @@
1007 db_reset(&sIns);
1008 return mprintf(":%d", db_last_insert_rowid());
1009 }
1010
1011 /* This is the SHA3-256 hash of an empty file */
 
 
 
1012 /*
1013 ** Export a single file named by zUuid.
1014 **
1015 ** Return 0 on success and non-zero on any failure.
1016 **
@@ -1024,26 +1021,24 @@
1021 */
1022 static int gitmirror_send_file(FILE *xCmd, const char *zUuid, int bPhantomOk){
1023 char *zMark;
1024 int rid;
1025 int rc;
1026 Blob data = BLOB_INITIALIZER;
1027 rid = fast_uuid_to_rid(zUuid);
1028 if( rid<=0 ){
1029 if( bPhantomOk || uuid_is_shunned(zUuid) ){
1030 gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
 
1031 }else{
1032 return 1;
1033 }
1034 }else{
1035 rc = content_get(rid, &data);
1036 if( rc==0 ){
1037 if( bPhantomOk ){
1038 blob_init(&data, 0, 0);
1039 gitmirror_message(VERB_EXTRA, "missing file: %s\n", zUuid);
 
1040 }else{
1041 return 1;
1042 }
1043 }
1044 }
1045
+1 -1
--- src/file.c
+++ src/file.c
@@ -2613,11 +2613,11 @@
26132613
if( nLimit>0 && n>=nLimit ) break;
26142614
}
26152615
closedir(d);
26162616
}
26172617
fossil_path_free(zNative);
2618
- if( pazList ) (*pazList)[n] = 0;
2618
+ if( pazList && *pazList ) (*pazList)[n] = 0;
26192619
return n;
26202620
}
26212621
void file_directory_list_free(char **azList){
26222622
char **az;
26232623
if( azList==0 ) return;
26242624
--- src/file.c
+++ src/file.c
@@ -2613,11 +2613,11 @@
2613 if( nLimit>0 && n>=nLimit ) break;
2614 }
2615 closedir(d);
2616 }
2617 fossil_path_free(zNative);
2618 if( pazList ) (*pazList)[n] = 0;
2619 return n;
2620 }
2621 void file_directory_list_free(char **azList){
2622 char **az;
2623 if( azList==0 ) return;
2624
--- src/file.c
+++ src/file.c
@@ -2613,11 +2613,11 @@
2613 if( nLimit>0 && n>=nLimit ) break;
2614 }
2615 closedir(d);
2616 }
2617 fossil_path_free(zNative);
2618 if( pazList && *pazList ) (*pazList)[n] = 0;
2619 return n;
2620 }
2621 void file_directory_list_free(char **azList){
2622 char **az;
2623 if( azList==0 ) return;
2624
+25 -23
--- src/forum.c
+++ src/forum.c
@@ -2191,11 +2191,11 @@
21912191
** its list of attachments. We only emit this for No-JS environments,
21922192
** as in JS environments the interactive forum editor includes
21932193
** attachment support.
21942194
*/
21952195
static void forum_render_attachment_notice(void){
2196
- if( g.perm.AttachForum ){
2196
+ if( g.perm.AttachForum || g.perm.WrTForum ){
21972197
@ <noscript><div>You will be able to attach files to this post
21982198
@ after saving it.</div></noscript>
21992199
}
22002200
}
22012201
@@ -2238,12 +2238,12 @@
22382238
}
22392239
forum_render_debug_options();
22402240
login_insert_csrf_secret();
22412241
@ </form>
22422242
/* When JS is disabled the block above will work. When it's
2243
- enabled, the above will be removed and JS will render the editor
2244
- form in the next element. */
2243
+ ** enabled, the above will be removed and JS will render the editor
2244
+ ** form in the next element. */
22452245
@ <div hidden id='forumnew-placeholder'>
22462246
@ <input type='hidden' name='title' value='%h(zTitle)'>
22472247
login_insert_csrf_secret();
22482248
@ </div>
22492249
forum_render_attachment_notice();
@@ -3044,14 +3044,14 @@
30443044
** The caller must have started a transaction and must roll it back if
30453045
** this call returns <=0, noting that only the negative-value case is
30463046
** an error.
30473047
**
30483048
** This function does some work to try to ensure that duplicate
3049
-** entries are not save (this can happen as a side effect of the forum
3050
-** post editor added in 2026-06). If the given post will not have been
3051
-** materially edited by these changes, they are not applied and the
3052
-** rid of the existing entry is used.
3049
+** entries are not saved (this can happen as a side effect of the
3050
+** forum post editor added in 2026-06). If the given post will not
3051
+** have been materially edited by these changes, they are not applied
3052
+** and the rid of the existing entry is used.
30533053
**
30543054
** Maintenance reminders:
30553055
**
30563056
** - iInReplyTo==0 && iEdit==0: new thread
30573057
** - iInReplyTo==0 && iEdit>0 : edit top post or response
@@ -3243,15 +3243,15 @@
32433243
return rc;
32443244
}
32453245
/*
32463246
** WEBPAGE: forumajax_save hidden
32473247
**
3248
-** WIP
3248
+** Used by the forum JS pages to save a post.
32493249
**
32503250
** Response JSON:
32513251
**
3252
-** { uuid: hash, ...tbd }
3252
+** { uuid: hash, ...TO DOCUMENT }
32533253
*/
32543254
void forum_ajax_save_page(void){
32553255
const char *zFpid;
32563256
const char *zTitle;
32573257
const char *zIrt;
@@ -3267,15 +3267,17 @@
32673267
int nrid = 0; /* New artifact rid. */
32683268
int iPostFlags; /* forum_post_flags() (after perms check) */
32693269
int bRollback; /* True = roll back. */
32703270
int nAttach = 0; /* Number of attachments added */
32713271
int bStatusSet = 0; /* True if status tag set. */
3272
+ int bModPost = 0; /* Moderate post? */
3273
+ int bModAttach; /* Moderate attachment? */
32723274
32733275
if( !ajax_route_bootstrap(0, 1) ){
32743276
return;
3275
- }else if( !g.perm.WrForum
3276
- || (bHasAttachment && !g.perm.AttachForum) ){
3277
+ }else if( !g.perm.WrForum ||
3278
+ (bHasAttachment && !g.perm.WrTForum) ){
32773279
ajax_route_error_forbidden();
32783280
return;
32793281
}else if( !ajax_check_csrf(2) ){
32803282
ajax_route_error_csrf();
32813283
return;
@@ -3322,17 +3324,18 @@
33223324
rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID.");
33233325
goto ajax_save_end;
33243326
}
33253327
}
33263328
3327
- if( 0 ){
3328
- rc = -ajax_route_error(400, "Save is TODO. "
3329
- "iPostFlags=%d debug=%d",
3330
- iPostFlags, g.perm.Debug);
3331
- goto ajax_save_end;
3329
+ bModPost = forum_need_moderation();
3330
+ if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){
3331
+ /* A user with WrTForum but not AttachForum may attach but
3332
+ ** the attachments will be moderated. */
3333
+ bModAttach = 1;
3334
+ }else{
3335
+ bModAttach = bModPost;
33323336
}
3333
-
33343337
zTitle = firt ? 0 : P("title");
33353338
nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype,
33363339
zContent, iPostFlags);
33373340
if( nrid<0 ){
33383341
rc = nrid;
@@ -3345,24 +3348,23 @@
33453348
CX("{\"message\": \"Rolled back for dry-run.\","
33463349
"\"iPostFlags\":%d}\n", iPostFlags);
33473350
}
33483351
goto ajax_save_end;
33493352
}else{
3350
- const int bNeedsModeration = forum_need_moderation();
33513353
const int fpHead = forumpost_head_rid(nrid);
33523354
assert( nrid>0 );
33533355
assert( fpHead>0 );
33543356
zNewUuid = rid_to_uuid(nrid);
3355
- if( 0!=P("file1") ){
3357
+ if( bHasAttachment ){
33563358
/* Attachments */
3357
- if( !g.perm.Admin && !g.perm.AttachForum ){
3358
- rc = -ajax_route_error(403, "No permission no attach files.");
3359
+ if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){
3360
+ rc = -ajax_route_error(403, "No permission to attach files.");
33593361
goto ajax_save_end;
33603362
}else{
33613363
char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead);
33623364
nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid,
3363
- bNeedsModeration);
3365
+ bModAttach);
33643366
fossil_free(zRoot);
33653367
if( nAttach<0 ){
33663368
rc = nAttach;
33673369
goto ajax_save_end;
33683370
}
@@ -3385,11 +3387,11 @@
33853387
fpHead, fpHead
33863388
);
33873389
}
33883390
}
33893391
}
3390
- if( 0==bNeedsModeration
3392
+ if( 0==bModPost
33913393
/* ^^^ Do not allow a status tag on a pending-moderation post
33923394
** because it will introduce a reference to an artifact which
33933395
** will become a phantom if it is rejected by a moderator. */
33943396
&& zStatus!=0 && zStatus[0]!=0
33953397
&& forum_may_set_status(nrid)
33963398
--- src/forum.c
+++ src/forum.c
@@ -2191,11 +2191,11 @@
2191 ** its list of attachments. We only emit this for No-JS environments,
2192 ** as in JS environments the interactive forum editor includes
2193 ** attachment support.
2194 */
2195 static void forum_render_attachment_notice(void){
2196 if( g.perm.AttachForum ){
2197 @ <noscript><div>You will be able to attach files to this post
2198 @ after saving it.</div></noscript>
2199 }
2200 }
2201
@@ -2238,12 +2238,12 @@
2238 }
2239 forum_render_debug_options();
2240 login_insert_csrf_secret();
2241 @ </form>
2242 /* When JS is disabled the block above will work. When it's
2243 enabled, the above will be removed and JS will render the editor
2244 form in the next element. */
2245 @ <div hidden id='forumnew-placeholder'>
2246 @ <input type='hidden' name='title' value='%h(zTitle)'>
2247 login_insert_csrf_secret();
2248 @ </div>
2249 forum_render_attachment_notice();
@@ -3044,14 +3044,14 @@
3044 ** The caller must have started a transaction and must roll it back if
3045 ** this call returns <=0, noting that only the negative-value case is
3046 ** an error.
3047 **
3048 ** This function does some work to try to ensure that duplicate
3049 ** entries are not save (this can happen as a side effect of the forum
3050 ** post editor added in 2026-06). If the given post will not have been
3051 ** materially edited by these changes, they are not applied and the
3052 ** rid of the existing entry is used.
3053 **
3054 ** Maintenance reminders:
3055 **
3056 ** - iInReplyTo==0 && iEdit==0: new thread
3057 ** - iInReplyTo==0 && iEdit>0 : edit top post or response
@@ -3243,15 +3243,15 @@
3243 return rc;
3244 }
3245 /*
3246 ** WEBPAGE: forumajax_save hidden
3247 **
3248 ** WIP
3249 **
3250 ** Response JSON:
3251 **
3252 ** { uuid: hash, ...tbd }
3253 */
3254 void forum_ajax_save_page(void){
3255 const char *zFpid;
3256 const char *zTitle;
3257 const char *zIrt;
@@ -3267,15 +3267,17 @@
3267 int nrid = 0; /* New artifact rid. */
3268 int iPostFlags; /* forum_post_flags() (after perms check) */
3269 int bRollback; /* True = roll back. */
3270 int nAttach = 0; /* Number of attachments added */
3271 int bStatusSet = 0; /* True if status tag set. */
 
 
3272
3273 if( !ajax_route_bootstrap(0, 1) ){
3274 return;
3275 }else if( !g.perm.WrForum
3276 || (bHasAttachment && !g.perm.AttachForum) ){
3277 ajax_route_error_forbidden();
3278 return;
3279 }else if( !ajax_check_csrf(2) ){
3280 ajax_route_error_csrf();
3281 return;
@@ -3322,17 +3324,18 @@
3322 rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID.");
3323 goto ajax_save_end;
3324 }
3325 }
3326
3327 if( 0 ){
3328 rc = -ajax_route_error(400, "Save is TODO. "
3329 "iPostFlags=%d debug=%d",
3330 iPostFlags, g.perm.Debug);
3331 goto ajax_save_end;
 
 
3332 }
3333
3334 zTitle = firt ? 0 : P("title");
3335 nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype,
3336 zContent, iPostFlags);
3337 if( nrid<0 ){
3338 rc = nrid;
@@ -3345,24 +3348,23 @@
3345 CX("{\"message\": \"Rolled back for dry-run.\","
3346 "\"iPostFlags\":%d}\n", iPostFlags);
3347 }
3348 goto ajax_save_end;
3349 }else{
3350 const int bNeedsModeration = forum_need_moderation();
3351 const int fpHead = forumpost_head_rid(nrid);
3352 assert( nrid>0 );
3353 assert( fpHead>0 );
3354 zNewUuid = rid_to_uuid(nrid);
3355 if( 0!=P("file1") ){
3356 /* Attachments */
3357 if( !g.perm.Admin && !g.perm.AttachForum ){
3358 rc = -ajax_route_error(403, "No permission no attach files.");
3359 goto ajax_save_end;
3360 }else{
3361 char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead);
3362 nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid,
3363 bNeedsModeration);
3364 fossil_free(zRoot);
3365 if( nAttach<0 ){
3366 rc = nAttach;
3367 goto ajax_save_end;
3368 }
@@ -3385,11 +3387,11 @@
3385 fpHead, fpHead
3386 );
3387 }
3388 }
3389 }
3390 if( 0==bNeedsModeration
3391 /* ^^^ Do not allow a status tag on a pending-moderation post
3392 ** because it will introduce a reference to an artifact which
3393 ** will become a phantom if it is rejected by a moderator. */
3394 && zStatus!=0 && zStatus[0]!=0
3395 && forum_may_set_status(nrid)
3396
--- src/forum.c
+++ src/forum.c
@@ -2191,11 +2191,11 @@
2191 ** its list of attachments. We only emit this for No-JS environments,
2192 ** as in JS environments the interactive forum editor includes
2193 ** attachment support.
2194 */
2195 static void forum_render_attachment_notice(void){
2196 if( g.perm.AttachForum || g.perm.WrTForum ){
2197 @ <noscript><div>You will be able to attach files to this post
2198 @ after saving it.</div></noscript>
2199 }
2200 }
2201
@@ -2238,12 +2238,12 @@
2238 }
2239 forum_render_debug_options();
2240 login_insert_csrf_secret();
2241 @ </form>
2242 /* When JS is disabled the block above will work. When it's
2243 ** enabled, the above will be removed and JS will render the editor
2244 ** form in the next element. */
2245 @ <div hidden id='forumnew-placeholder'>
2246 @ <input type='hidden' name='title' value='%h(zTitle)'>
2247 login_insert_csrf_secret();
2248 @ </div>
2249 forum_render_attachment_notice();
@@ -3044,14 +3044,14 @@
3044 ** The caller must have started a transaction and must roll it back if
3045 ** this call returns <=0, noting that only the negative-value case is
3046 ** an error.
3047 **
3048 ** This function does some work to try to ensure that duplicate
3049 ** entries are not saved (this can happen as a side effect of the
3050 ** forum post editor added in 2026-06). If the given post will not
3051 ** have been materially edited by these changes, they are not applied
3052 ** and the rid of the existing entry is used.
3053 **
3054 ** Maintenance reminders:
3055 **
3056 ** - iInReplyTo==0 && iEdit==0: new thread
3057 ** - iInReplyTo==0 && iEdit>0 : edit top post or response
@@ -3243,15 +3243,15 @@
3243 return rc;
3244 }
3245 /*
3246 ** WEBPAGE: forumajax_save hidden
3247 **
3248 ** Used by the forum JS pages to save a post.
3249 **
3250 ** Response JSON:
3251 **
3252 ** { uuid: hash, ...TO DOCUMENT }
3253 */
3254 void forum_ajax_save_page(void){
3255 const char *zFpid;
3256 const char *zTitle;
3257 const char *zIrt;
@@ -3267,15 +3267,17 @@
3267 int nrid = 0; /* New artifact rid. */
3268 int iPostFlags; /* forum_post_flags() (after perms check) */
3269 int bRollback; /* True = roll back. */
3270 int nAttach = 0; /* Number of attachments added */
3271 int bStatusSet = 0; /* True if status tag set. */
3272 int bModPost = 0; /* Moderate post? */
3273 int bModAttach; /* Moderate attachment? */
3274
3275 if( !ajax_route_bootstrap(0, 1) ){
3276 return;
3277 }else if( !g.perm.WrForum ||
3278 (bHasAttachment && !g.perm.WrTForum) ){
3279 ajax_route_error_forbidden();
3280 return;
3281 }else if( !ajax_check_csrf(2) ){
3282 ajax_route_error_csrf();
3283 return;
@@ -3322,17 +3324,18 @@
3324 rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID.");
3325 goto ajax_save_end;
3326 }
3327 }
3328
3329 bModPost = forum_need_moderation();
3330 if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){
3331 /* A user with WrTForum but not AttachForum may attach but
3332 ** the attachments will be moderated. */
3333 bModAttach = 1;
3334 }else{
3335 bModAttach = bModPost;
3336 }
 
3337 zTitle = firt ? 0 : P("title");
3338 nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype,
3339 zContent, iPostFlags);
3340 if( nrid<0 ){
3341 rc = nrid;
@@ -3345,24 +3348,23 @@
3348 CX("{\"message\": \"Rolled back for dry-run.\","
3349 "\"iPostFlags\":%d}\n", iPostFlags);
3350 }
3351 goto ajax_save_end;
3352 }else{
 
3353 const int fpHead = forumpost_head_rid(nrid);
3354 assert( nrid>0 );
3355 assert( fpHead>0 );
3356 zNewUuid = rid_to_uuid(nrid);
3357 if( bHasAttachment ){
3358 /* Attachments */
3359 if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){
3360 rc = -ajax_route_error(403, "No permission to attach files.");
3361 goto ajax_save_end;
3362 }else{
3363 char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead);
3364 nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid,
3365 bModAttach);
3366 fossil_free(zRoot);
3367 if( nAttach<0 ){
3368 rc = nAttach;
3369 goto ajax_save_end;
3370 }
@@ -3385,11 +3387,11 @@
3387 fpHead, fpHead
3388 );
3389 }
3390 }
3391 }
3392 if( 0==bModPost
3393 /* ^^^ Do not allow a status tag on a pending-moderation post
3394 ** because it will introduce a reference to an artifact which
3395 ** will become a phantom if it is rejected by a moderator. */
3396 && zStatus!=0 && zStatus[0]!=0
3397 && forum_may_set_status(nrid)
3398
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -138,11 +138,10 @@
138138
}
139139
}else{
140140
this.#updateControls();
141141
}
142142
}
143
-
144143
145144
get widget(){
146145
return this.#e.body;
147146
}
148147
149148
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -138,11 +138,10 @@
138 }
139 }else{
140 this.#updateControls();
141 }
142 }
143
144
145 get widget(){
146 return this.#e.body;
147 }
148
149
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -138,11 +138,10 @@
138 }
139 }else{
140 this.#updateControls();
141 }
142 }
 
143
144 get widget(){
145 return this.#e.body;
146 }
147
148
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -337,11 +337,11 @@
337337
}
338338
});
339339
}
340340
}/*e.status*/
341341
342
- if( F.user.mayAttachForum ){
342
+ if( 0!==F.user.mayAttachForum ){
343343
//e.buttons.append( e.button.addAttach = this.#att.takeAddButton() );
344344
e.tabAttach = D.div();
345345
e.tabAttach.setAttribute('id', idPrefix+'-attach');
346346
e.tabAttach.dataset.tabLabel = 'Attachments';
347347
this.#tabs.addTab(e.tabAttach);
@@ -598,13 +598,23 @@
598598
D.attr(
599599
D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'),
600600
'target',
601601
'_new'
602602
),
603
- ".",
603
+ "."
604604
);
605605
this.#e.tabAttach.append(eNote);
606
+ }
607
+ if( F.user.mayAttachForum < 0 ){
608
+ /* Users with permission '4' (forum unmoderated) but not 'B'
609
+ ** (forum-attach) may attach files but they will undergo
610
+ ** moderation. */
611
+ const w = D.div();
612
+ w.append("Your attachments will be held "+
613
+ "for moderation.");
614
+ w.classList.add('warning');
615
+ this.#e.tabAttach.append(w);
606616
}
607617
this.#e.tabAttach.append(this.#att.widget);
608618
}
609619
610620
#newFormData(addThisContent){
611621
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -337,11 +337,11 @@
337 }
338 });
339 }
340 }/*e.status*/
341
342 if( F.user.mayAttachForum ){
343 //e.buttons.append( e.button.addAttach = this.#att.takeAddButton() );
344 e.tabAttach = D.div();
345 e.tabAttach.setAttribute('id', idPrefix+'-attach');
346 e.tabAttach.dataset.tabLabel = 'Attachments';
347 this.#tabs.addTab(e.tabAttach);
@@ -598,13 +598,23 @@
598 D.attr(
599 D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'),
600 'target',
601 '_new'
602 ),
603 ".",
604 );
605 this.#e.tabAttach.append(eNote);
 
 
 
 
 
 
 
 
 
 
606 }
607 this.#e.tabAttach.append(this.#att.widget);
608 }
609
610 #newFormData(addThisContent){
611
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -337,11 +337,11 @@
337 }
338 });
339 }
340 }/*e.status*/
341
342 if( 0!==F.user.mayAttachForum ){
343 //e.buttons.append( e.button.addAttach = this.#att.takeAddButton() );
344 e.tabAttach = D.div();
345 e.tabAttach.setAttribute('id', idPrefix+'-attach');
346 e.tabAttach.dataset.tabLabel = 'Attachments';
347 this.#tabs.addTab(e.tabAttach);
@@ -598,13 +598,23 @@
598 D.attr(
599 D.a(F.repoUrl('attachadd?target='+this.#opt.edit.uuid), '/attachadd'),
600 'target',
601 '_new'
602 ),
603 "."
604 );
605 this.#e.tabAttach.append(eNote);
606 }
607 if( F.user.mayAttachForum < 0 ){
608 /* Users with permission '4' (forum unmoderated) but not 'B'
609 ** (forum-attach) may attach files but they will undergo
610 ** moderation. */
611 const w = D.div();
612 w.append("Your attachments will be held "+
613 "for moderation.");
614 w.classList.add('warning');
615 this.#e.tabAttach.append(w);
616 }
617 this.#e.tabAttach.append(this.#att.widget);
618 }
619
620 #newFormData(addThisContent){
621
+3 -3
--- src/manifest.c
+++ src/manifest.c
@@ -2779,23 +2779,23 @@
27792779
blob_appendf(&comment, " Change user to \"%h\".", zValue);
27802780
continue;
27812781
}else if( strcmp(zName, "+date")==0 ){
27822782
blob_appendf(&comment, " Timestamp %h.", zValue);
27832783
continue;
2784
- }else if( memcmp(zName, "-sym-",5)==0 ){
2784
+ }else if( strncmp(zName, "-sym-",5)==0 ){
27852785
if( !branchMove ){
27862786
blob_appendf(&comment, " Cancel tag \"%h\"", &zName[5]);
27872787
}else{
27882788
continue;
27892789
}
2790
- }else if( memcmp(zName, "*sym-",5)==0 ){
2790
+ }else if( strncmp(zName, "*sym-",5)==0 ){
27912791
if( !branchMove ){
27922792
blob_appendf(&comment, " Add propagating tag \"%h\"", &zName[5]);
27932793
}else{
27942794
continue;
27952795
}
2796
- }else if( memcmp(zName, "+sym-",5)==0 ){
2796
+ }else if( strncmp(zName, "+sym-",5)==0 ){
27972797
blob_appendf(&comment, " Add tag \"%h\"", &zName[5]);
27982798
}else if( strcmp(zName, "+closed")==0 ){
27992799
blob_append(&comment, " Mark \"Closed\"", -1);
28002800
}else if( strcmp(zName, "-closed")==0 ){
28012801
blob_append(&comment, " Remove the \"Closed\" mark", -1);
28022802
--- src/manifest.c
+++ src/manifest.c
@@ -2779,23 +2779,23 @@
2779 blob_appendf(&comment, " Change user to \"%h\".", zValue);
2780 continue;
2781 }else if( strcmp(zName, "+date")==0 ){
2782 blob_appendf(&comment, " Timestamp %h.", zValue);
2783 continue;
2784 }else if( memcmp(zName, "-sym-",5)==0 ){
2785 if( !branchMove ){
2786 blob_appendf(&comment, " Cancel tag \"%h\"", &zName[5]);
2787 }else{
2788 continue;
2789 }
2790 }else if( memcmp(zName, "*sym-",5)==0 ){
2791 if( !branchMove ){
2792 blob_appendf(&comment, " Add propagating tag \"%h\"", &zName[5]);
2793 }else{
2794 continue;
2795 }
2796 }else if( memcmp(zName, "+sym-",5)==0 ){
2797 blob_appendf(&comment, " Add tag \"%h\"", &zName[5]);
2798 }else if( strcmp(zName, "+closed")==0 ){
2799 blob_append(&comment, " Mark \"Closed\"", -1);
2800 }else if( strcmp(zName, "-closed")==0 ){
2801 blob_append(&comment, " Remove the \"Closed\" mark", -1);
2802
--- src/manifest.c
+++ src/manifest.c
@@ -2779,23 +2779,23 @@
2779 blob_appendf(&comment, " Change user to \"%h\".", zValue);
2780 continue;
2781 }else if( strcmp(zName, "+date")==0 ){
2782 blob_appendf(&comment, " Timestamp %h.", zValue);
2783 continue;
2784 }else if( strncmp(zName, "-sym-",5)==0 ){
2785 if( !branchMove ){
2786 blob_appendf(&comment, " Cancel tag \"%h\"", &zName[5]);
2787 }else{
2788 continue;
2789 }
2790 }else if( strncmp(zName, "*sym-",5)==0 ){
2791 if( !branchMove ){
2792 blob_appendf(&comment, " Add propagating tag \"%h\"", &zName[5]);
2793 }else{
2794 continue;
2795 }
2796 }else if( strncmp(zName, "+sym-",5)==0 ){
2797 blob_appendf(&comment, " Add tag \"%h\"", &zName[5]);
2798 }else if( strcmp(zName, "+closed")==0 ){
2799 blob_append(&comment, " Mark \"Closed\"", -1);
2800 }else if( strcmp(zName, "-closed")==0 ){
2801 blob_append(&comment, " Remove the \"Closed\" mark", -1);
2802
+1 -1
--- src/markdown.c
+++ src/markdown.c
@@ -1803,11 +1803,11 @@
18031803
** If this is a quoted fenced block, then set endFence to be the
18041804
** offset of the end of the fenced block.
18051805
*/
18061806
pre = prefix_quote(data,size);
18071807
pre += is_empty(data+pre,size-pre);
1808
- nb = prefix_fencedcode(data+pre,size-pre);
1808
+ nb = pre<size ? prefix_fencedcode(data+pre,size-pre) : 0;
18091809
if( nb ){
18101810
size_t i = 0;
18111811
char delim = data[pre];
18121812
for(end=pre+nb; end<size && i<nb; end++){
18131813
if( data[end]==delim ) i++; else i = 0;
18141814
--- src/markdown.c
+++ src/markdown.c
@@ -1803,11 +1803,11 @@
1803 ** If this is a quoted fenced block, then set endFence to be the
1804 ** offset of the end of the fenced block.
1805 */
1806 pre = prefix_quote(data,size);
1807 pre += is_empty(data+pre,size-pre);
1808 nb = prefix_fencedcode(data+pre,size-pre);
1809 if( nb ){
1810 size_t i = 0;
1811 char delim = data[pre];
1812 for(end=pre+nb; end<size && i<nb; end++){
1813 if( data[end]==delim ) i++; else i = 0;
1814
--- src/markdown.c
+++ src/markdown.c
@@ -1803,11 +1803,11 @@
1803 ** If this is a quoted fenced block, then set endFence to be the
1804 ** offset of the end of the fenced block.
1805 */
1806 pre = prefix_quote(data,size);
1807 pre += is_empty(data+pre,size-pre);
1808 nb = pre<size ? prefix_fencedcode(data+pre,size-pre) : 0;
1809 if( nb ){
1810 size_t i = 0;
1811 char delim = data[pre];
1812 for(end=pre+nb; end<size && i<nb; end++){
1813 if( data[end]==delim ) i++; else i = 0;
1814
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -1027,20 +1027,20 @@
10271027
z[k++] = (char)x;
10281028
j += n;
10291029
}else{
10301030
z[k++] = c;
10311031
}
1032
- }else if( memcmp(&z[j],"&lt;",4)==0 ){
1032
+ }else if( p->nUsed-j>=4 && memcmp(&z[j],"&lt;",4)==0 ){
10331033
z[k++] = '<';
10341034
j += 3;
1035
- }else if( memcmp(&z[j],"&gt;",4)==0 ){
1035
+ }else if( p->nUsed-j>=4 && memcmp(&z[j],"&gt;",4)==0 ){
10361036
z[k++] = '>';
10371037
j += 3;
1038
- }else if( memcmp(&z[j],"&quot;",6)==0 ){
1038
+ }else if( p->nUsed-j>=6 && memcmp(&z[j],"&quot;",6)==0 ){
10391039
z[k++] = '"';
10401040
j += 5;
1041
- }else if( memcmp(&z[j],"&amp;",5)==0 ){
1041
+ }else if( p->nUsed-j>=5 && memcmp(&z[j],"&amp;",5)==0 ){
10421042
z[k++] = '&';
10431043
j += 4;
10441044
}else{
10451045
z[k++] = c;
10461046
}
10471047
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -1027,20 +1027,20 @@
1027 z[k++] = (char)x;
1028 j += n;
1029 }else{
1030 z[k++] = c;
1031 }
1032 }else if( memcmp(&z[j],"&lt;",4)==0 ){
1033 z[k++] = '<';
1034 j += 3;
1035 }else if( memcmp(&z[j],"&gt;",4)==0 ){
1036 z[k++] = '>';
1037 j += 3;
1038 }else if( memcmp(&z[j],"&quot;",6)==0 ){
1039 z[k++] = '"';
1040 j += 5;
1041 }else if( memcmp(&z[j],"&amp;",5)==0 ){
1042 z[k++] = '&';
1043 j += 4;
1044 }else{
1045 z[k++] = c;
1046 }
1047
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -1027,20 +1027,20 @@
1027 z[k++] = (char)x;
1028 j += n;
1029 }else{
1030 z[k++] = c;
1031 }
1032 }else if( p->nUsed-j>=4 && memcmp(&z[j],"&lt;",4)==0 ){
1033 z[k++] = '<';
1034 j += 3;
1035 }else if( p->nUsed-j>=4 && memcmp(&z[j],"&gt;",4)==0 ){
1036 z[k++] = '>';
1037 j += 3;
1038 }else if( p->nUsed-j>=6 && memcmp(&z[j],"&quot;",6)==0 ){
1039 z[k++] = '"';
1040 j += 5;
1041 }else if( p->nUsed-j>=5 && memcmp(&z[j],"&amp;",5)==0 ){
1042 z[k++] = '&';
1043 j += 4;
1044 }else{
1045 z[k++] = c;
1046 }
1047
+5 -5
--- src/name.c
+++ src/name.c
@@ -533,11 +533,11 @@
533533
}
534534
if( rid ) return rid;
535535
}
536536
537537
/* Date and times */
538
- if( memcmp(zTag, "date:", 5)==0 ){
538
+ if( strncmp(zTag, "date:", 5)==0 ){
539539
zDate = fossil_expand_datetime(&zTag[5],0,1);
540540
if( zDate==0 ) zDate = &zTag[5];
541541
rid = db_int(0,
542542
"SELECT objid FROM event"
543543
" WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
@@ -554,29 +554,29 @@
554554
if( rid) return rid;
555555
}
556556
557557
/* Deprecated date & time formats: "local:" + date-time and
558558
** "utc:" + date-time */
559
- if( memcmp(zTag, "local:", 6)==0 ){
559
+ if( strncmp(zTag, "local:", 6)==0 ){
560560
rid = db_int(0,
561561
"SELECT objid FROM event"
562562
" WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
563563
" ORDER BY mtime DESC LIMIT 1",
564564
&zTag[6], zType);
565565
return rid;
566566
}
567
- if( memcmp(zTag, "utc:", 4)==0 ){
567
+ if( strncmp(zTag, "utc:", 4)==0 ){
568568
rid = db_int(0,
569569
"SELECT objid FROM event"
570570
" WHERE mtime<=julianday('%qz') AND type GLOB '%q'"
571571
" ORDER BY mtime DESC LIMIT 1",
572572
fossil_roundup_date(&zTag[4]), zType);
573573
return rid;
574574
}
575575
576576
/* "tag:" + symbolic-name */
577
- if( memcmp(zTag, "tag:", 4)==0 ){
577
+ if( strncmp(zTag, "tag:", 4)==0 ){
578578
rid = most_recent_event_with_tag(&zTag[4], zType);
579579
if( startOfBranch ) rid = start_of_branch(rid,1);
580580
return rid;
581581
}
582582
@@ -698,11 +698,11 @@
698698
if( rid) return rid;
699699
}
700700
701701
702702
/* Undocumented: numeric tags get translated directly into the RID */
703
- if( memcmp(zTag, "rid:", 4)==0 ){
703
+ if( strncmp(zTag, "rid:", 4)==0 ){
704704
zTag += 4;
705705
for(i=0; fossil_isdigit(zTag[i]); i++){}
706706
if( zTag[i]==0 ){
707707
if( strcmp(zType,"*")==0 ){
708708
rid = atoi(zTag);
709709
--- src/name.c
+++ src/name.c
@@ -533,11 +533,11 @@
533 }
534 if( rid ) return rid;
535 }
536
537 /* Date and times */
538 if( memcmp(zTag, "date:", 5)==0 ){
539 zDate = fossil_expand_datetime(&zTag[5],0,1);
540 if( zDate==0 ) zDate = &zTag[5];
541 rid = db_int(0,
542 "SELECT objid FROM event"
543 " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
@@ -554,29 +554,29 @@
554 if( rid) return rid;
555 }
556
557 /* Deprecated date & time formats: "local:" + date-time and
558 ** "utc:" + date-time */
559 if( memcmp(zTag, "local:", 6)==0 ){
560 rid = db_int(0,
561 "SELECT objid FROM event"
562 " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
563 " ORDER BY mtime DESC LIMIT 1",
564 &zTag[6], zType);
565 return rid;
566 }
567 if( memcmp(zTag, "utc:", 4)==0 ){
568 rid = db_int(0,
569 "SELECT objid FROM event"
570 " WHERE mtime<=julianday('%qz') AND type GLOB '%q'"
571 " ORDER BY mtime DESC LIMIT 1",
572 fossil_roundup_date(&zTag[4]), zType);
573 return rid;
574 }
575
576 /* "tag:" + symbolic-name */
577 if( memcmp(zTag, "tag:", 4)==0 ){
578 rid = most_recent_event_with_tag(&zTag[4], zType);
579 if( startOfBranch ) rid = start_of_branch(rid,1);
580 return rid;
581 }
582
@@ -698,11 +698,11 @@
698 if( rid) return rid;
699 }
700
701
702 /* Undocumented: numeric tags get translated directly into the RID */
703 if( memcmp(zTag, "rid:", 4)==0 ){
704 zTag += 4;
705 for(i=0; fossil_isdigit(zTag[i]); i++){}
706 if( zTag[i]==0 ){
707 if( strcmp(zType,"*")==0 ){
708 rid = atoi(zTag);
709
--- src/name.c
+++ src/name.c
@@ -533,11 +533,11 @@
533 }
534 if( rid ) return rid;
535 }
536
537 /* Date and times */
538 if( strncmp(zTag, "date:", 5)==0 ){
539 zDate = fossil_expand_datetime(&zTag[5],0,1);
540 if( zDate==0 ) zDate = &zTag[5];
541 rid = db_int(0,
542 "SELECT objid FROM event"
543 " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
@@ -554,29 +554,29 @@
554 if( rid) return rid;
555 }
556
557 /* Deprecated date & time formats: "local:" + date-time and
558 ** "utc:" + date-time */
559 if( strncmp(zTag, "local:", 6)==0 ){
560 rid = db_int(0,
561 "SELECT objid FROM event"
562 " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
563 " ORDER BY mtime DESC LIMIT 1",
564 &zTag[6], zType);
565 return rid;
566 }
567 if( strncmp(zTag, "utc:", 4)==0 ){
568 rid = db_int(0,
569 "SELECT objid FROM event"
570 " WHERE mtime<=julianday('%qz') AND type GLOB '%q'"
571 " ORDER BY mtime DESC LIMIT 1",
572 fossil_roundup_date(&zTag[4]), zType);
573 return rid;
574 }
575
576 /* "tag:" + symbolic-name */
577 if( strncmp(zTag, "tag:", 4)==0 ){
578 rid = most_recent_event_with_tag(&zTag[4], zType);
579 if( startOfBranch ) rid = start_of_branch(rid,1);
580 return rid;
581 }
582
@@ -698,11 +698,11 @@
698 if( rid) return rid;
699 }
700
701
702 /* Undocumented: numeric tags get translated directly into the RID */
703 if( strncmp(zTag, "rid:", 4)==0 ){
704 zTag += 4;
705 for(i=0; fossil_isdigit(zTag[i]); i++){}
706 if( zTag[i]==0 ){
707 if( strcmp(zType,"*")==0 ){
708 rid = atoi(zTag);
709
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897897
no_error_log_available();
898898
style_finish_page();
899899
return;
900900
}
901901
if( P("truncate1") && cgi_csrf_safe(2) ){
902
- fclose(fopen(g.zErrlog,"w"));
902
+ FILE *pLog = fopen(g.zErrlog,"w");
903
+ if( pLog ) fclose(pLog);
903904
}
904905
if( P("download") ){
905906
Blob log;
906907
blob_read_from_file(&log, g.zErrlog, ExtFILE);
907908
cgi_set_content_type("text/plain");
908909
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897 no_error_log_available();
898 style_finish_page();
899 return;
900 }
901 if( P("truncate1") && cgi_csrf_safe(2) ){
902 fclose(fopen(g.zErrlog,"w"));
 
903 }
904 if( P("download") ){
905 Blob log;
906 blob_read_from_file(&log, g.zErrlog, ExtFILE);
907 cgi_set_content_type("text/plain");
908
--- src/security_audit.c
+++ src/security_audit.c
@@ -897,11 +897,12 @@
897 no_error_log_available();
898 style_finish_page();
899 return;
900 }
901 if( P("truncate1") && cgi_csrf_safe(2) ){
902 FILE *pLog = fopen(g.zErrlog,"w");
903 if( pLog ) fclose(pLog);
904 }
905 if( P("download") ){
906 Blob log;
907 blob_read_from_file(&log, g.zErrlog, ExtFILE);
908 cgi_set_content_type("text/plain");
909
+1 -1
--- src/style.c
+++ src/style.c
@@ -505,11 +505,11 @@
505505
** the ID of the <span> that surrounds the display text and the ID
506506
** of the <button> becomes "copy-%s" where %s is filled in by zTargetId.
507507
** If zTargetId is NULL (the usual case) then IDs are selected automatically.
508508
**
509509
** The bOutputCGI parameter is usually true, meaning that the output
510
-** is appended to the CGI result under construction. However, if
510
+** is appended to the CGI result under construction. However, if
511511
** bOutputCGI is false, the generated HTML is written into memory
512512
** obtained from fossil_malloc() and returned.
513513
**
514514
** If the bAfter argument is non-zero, the copy button is displayed
515515
** after the text. Normally the copy button comes before the text.
516516
--- src/style.c
+++ src/style.c
@@ -505,11 +505,11 @@
505 ** the ID of the <span> that surrounds the display text and the ID
506 ** of the <button> becomes "copy-%s" where %s is filled in by zTargetId.
507 ** If zTargetId is NULL (the usual case) then IDs are selected automatically.
508 **
509 ** The bOutputCGI parameter is usually true, meaning that the output
510 ** is appended to the CGI result under construction. However, if
511 ** bOutputCGI is false, the generated HTML is written into memory
512 ** obtained from fossil_malloc() and returned.
513 **
514 ** If the bAfter argument is non-zero, the copy button is displayed
515 ** after the text. Normally the copy button comes before the text.
516
--- src/style.c
+++ src/style.c
@@ -505,11 +505,11 @@
505 ** the ID of the <span> that surrounds the display text and the ID
506 ** of the <button> becomes "copy-%s" where %s is filled in by zTargetId.
507 ** If zTargetId is NULL (the usual case) then IDs are selected automatically.
508 **
509 ** The bOutputCGI parameter is usually true, meaning that the output
510 ** is appended to the CGI result under construction. However, if
511 ** bOutputCGI is false, the generated HTML is written into memory
512 ** obtained from fossil_malloc() and returned.
513 **
514 ** If the bAfter argument is non-zero, the copy button is displayed
515 ** after the text. Normally the copy button comes before the text.
516
--- src/timeline.c
+++ src/timeline.c
@@ -1237,10 +1237,46 @@
12371237
@ FROM event CROSS JOIN blob
12381238
@ WHERE blob.rid=event.objid
12391239
;
12401240
return zBase;
12411241
}
1242
+
1243
+/*
1244
+** SQL function: hidden_by_user(X)
1245
+**
1246
+** Return true if X matches one of the GLOB patterns in the "hide-by-user"
1247
+** setting.
1248
+*/
1249
+static void timeline_hidden_by_user_func(
1250
+ sqlite3_context *context,
1251
+ int argc,
1252
+ sqlite3_value **argv
1253
+){
1254
+ static Glob *pGlob = 0;
1255
+ static int isInit = 0;
1256
+ const char *zUser;
1257
+ if( !isInit ){
1258
+ const char *zPat = db_get("hide-by-user", 0);
1259
+ pGlob = zPat ? glob_create(zPat) : 0;
1260
+ isInit = 1;
1261
+ }
1262
+ zUser = (const char*)sqlite3_value_text(argv[0]);
1263
+ sqlite3_result_int(context,
1264
+ pGlob!=0 && zUser!=0 && glob_match(pGlob, zUser)!=0);
1265
+}
1266
+
1267
+/*
1268
+** Register hidden_by_user() and return true if the "hide-by-user"
1269
+** setting is non-empty.
1270
+*/
1271
+static int timeline_enable_hide_by_user(void){
1272
+ const char *zPat = db_get("hide-by-user", 0);
1273
+ if( zPat==0 || zPat[0]==0 ) return 0;
1274
+ sqlite3_create_function(g.db, "hidden_by_user", 1, SQLITE_UTF8, 0,
1275
+ timeline_hidden_by_user_func, 0, 0);
1276
+ return 1;
1277
+}
12421278
12431279
/*
12441280
** zDate is a localtime date. Insert records into the
12451281
** "timeline" table to cause <hr> to be inserted on zDate.
12461282
*/
@@ -2261,10 +2297,15 @@
22612297
blob_append_sql(&sql,
22622298
" AND NOT EXISTS(SELECT 1 FROM tagxref"
22632299
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n",
22642300
TAG_HIDDEN
22652301
);
2302
+ if( timeline_enable_hide_by_user() ){
2303
+ blob_append_sql(&sql,
2304
+ " AND NOT (event.type='ci' AND hidden_by_user(coalesce(euser,user)))\n"
2305
+ );
2306
+ }
22662307
}
22672308
if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){
22682309
const char *zTo = P("ft");
22692310
if( zTo ){
22702311
from_to_mode = 1;
@@ -3049,10 +3090,20 @@
30493090
" FROM related_nodes, tagxref\n"
30503091
" WHERE tagid=%d AND tagtype>0\n"
30513092
" AND tagxref.rid=related_nodes.rid)",
30523093
TAG_HIDDEN
30533094
);
3095
+ if( timeline_enable_hide_by_user() ){
3096
+ db_multi_exec(
3097
+ "DELETE FROM related_nodes\n"
3098
+ " WHERE rid IN (SELECT related_nodes.rid\n"
3099
+ " FROM related_nodes, event\n"
3100
+ " WHERE event.objid=related_nodes.rid\n"
3101
+ " AND event.type='ci'\n"
3102
+ " AND hidden_by_user(coalesce(euser,user)))"
3103
+ );
3104
+ }
30543105
}
30553106
}
30563107
}
30573108
if( (zType[0]=='w' && !g.perm.RdWiki)
30583109
|| (zType[0]=='t' && !g.perm.RdTkt)
30593110
--- src/timeline.c
+++ src/timeline.c
@@ -1237,10 +1237,46 @@
1237 @ FROM event CROSS JOIN blob
1238 @ WHERE blob.rid=event.objid
1239 ;
1240 return zBase;
1241 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1242
1243 /*
1244 ** zDate is a localtime date. Insert records into the
1245 ** "timeline" table to cause <hr> to be inserted on zDate.
1246 */
@@ -2261,10 +2297,15 @@
2261 blob_append_sql(&sql,
2262 " AND NOT EXISTS(SELECT 1 FROM tagxref"
2263 " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n",
2264 TAG_HIDDEN
2265 );
 
 
 
 
 
2266 }
2267 if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){
2268 const char *zTo = P("ft");
2269 if( zTo ){
2270 from_to_mode = 1;
@@ -3049,10 +3090,20 @@
3049 " FROM related_nodes, tagxref\n"
3050 " WHERE tagid=%d AND tagtype>0\n"
3051 " AND tagxref.rid=related_nodes.rid)",
3052 TAG_HIDDEN
3053 );
 
 
 
 
 
 
 
 
 
 
3054 }
3055 }
3056 }
3057 if( (zType[0]=='w' && !g.perm.RdWiki)
3058 || (zType[0]=='t' && !g.perm.RdTkt)
3059
--- src/timeline.c
+++ src/timeline.c
@@ -1237,10 +1237,46 @@
1237 @ FROM event CROSS JOIN blob
1238 @ WHERE blob.rid=event.objid
1239 ;
1240 return zBase;
1241 }
1242
1243 /*
1244 ** SQL function: hidden_by_user(X)
1245 **
1246 ** Return true if X matches one of the GLOB patterns in the "hide-by-user"
1247 ** setting.
1248 */
1249 static void timeline_hidden_by_user_func(
1250 sqlite3_context *context,
1251 int argc,
1252 sqlite3_value **argv
1253 ){
1254 static Glob *pGlob = 0;
1255 static int isInit = 0;
1256 const char *zUser;
1257 if( !isInit ){
1258 const char *zPat = db_get("hide-by-user", 0);
1259 pGlob = zPat ? glob_create(zPat) : 0;
1260 isInit = 1;
1261 }
1262 zUser = (const char*)sqlite3_value_text(argv[0]);
1263 sqlite3_result_int(context,
1264 pGlob!=0 && zUser!=0 && glob_match(pGlob, zUser)!=0);
1265 }
1266
1267 /*
1268 ** Register hidden_by_user() and return true if the "hide-by-user"
1269 ** setting is non-empty.
1270 */
1271 static int timeline_enable_hide_by_user(void){
1272 const char *zPat = db_get("hide-by-user", 0);
1273 if( zPat==0 || zPat[0]==0 ) return 0;
1274 sqlite3_create_function(g.db, "hidden_by_user", 1, SQLITE_UTF8, 0,
1275 timeline_hidden_by_user_func, 0, 0);
1276 return 1;
1277 }
1278
1279 /*
1280 ** zDate is a localtime date. Insert records into the
1281 ** "timeline" table to cause <hr> to be inserted on zDate.
1282 */
@@ -2261,10 +2297,15 @@
2297 blob_append_sql(&sql,
2298 " AND NOT EXISTS(SELECT 1 FROM tagxref"
2299 " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)\n",
2300 TAG_HIDDEN
2301 );
2302 if( timeline_enable_hide_by_user() ){
2303 blob_append_sql(&sql,
2304 " AND NOT (event.type='ci' AND hidden_by_user(coalesce(euser,user)))\n"
2305 );
2306 }
2307 }
2308 if( from_rid && !to_rid && (P("ft")!=0 || P("bt")!=0) ){
2309 const char *zTo = P("ft");
2310 if( zTo ){
2311 from_to_mode = 1;
@@ -3049,10 +3090,20 @@
3090 " FROM related_nodes, tagxref\n"
3091 " WHERE tagid=%d AND tagtype>0\n"
3092 " AND tagxref.rid=related_nodes.rid)",
3093 TAG_HIDDEN
3094 );
3095 if( timeline_enable_hide_by_user() ){
3096 db_multi_exec(
3097 "DELETE FROM related_nodes\n"
3098 " WHERE rid IN (SELECT related_nodes.rid\n"
3099 " FROM related_nodes, event\n"
3100 " WHERE event.objid=related_nodes.rid\n"
3101 " AND event.type='ci'\n"
3102 " AND hidden_by_user(coalesce(euser,user)))"
3103 );
3104 }
3105 }
3106 }
3107 }
3108 if( (zType[0]=='w' && !g.perm.RdWiki)
3109 || (zType[0]=='t' && !g.perm.RdTkt)
3110
+8 -8
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
8787
nBaselines = 0;
8888
db_prepare(&q, "PRAGMA table_info(ticket)");
8989
while( db_step(&q)==SQLITE_ROW ){
9090
const char *zFieldName = db_column_text(&q, 1);
9191
haveTicket = 1;
92
- if( memcmp(zFieldName,"tkt_",4)==0 ){
92
+ if( strncmp(zFieldName,"tkt_",4)==0 ){
9393
if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
9494
continue;
9595
}
96
- if( memcmp(zFieldName,"baseline for ",13)==0 ){
96
+ if( strncmp(zFieldName,"baseline for ",13)==0 ){
9797
if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
9898
nBaselines++;
9999
}
100100
continue;
101101
}
@@ -128,11 +128,11 @@
128128
}
129129
db_prepare(&q, "PRAGMA table_info(ticketchng)");
130130
while( db_step(&q)==SQLITE_ROW ){
131131
const char *zFieldName = db_column_text(&q, 1);
132132
haveTicketChng = 1;
133
- if( memcmp(zFieldName,"tkt_",4)==0 ){
133
+ if( strncmp(zFieldName,"tkt_",4)==0 ){
134134
if( strcmp(zFieldName+4,"rid")==0 ){
135135
haveTicketChngRid = 1; /* tkt_rid */
136136
}else if( strcmp(zFieldName+4,"user")==0 ){
137137
haveTicketChngUser = 1; /* tkt_user */
138138
}
@@ -211,11 +211,11 @@
211211
}else if( strncmp(zName, "private_", 8)==0 ){
212212
zVal = zRevealed = db_reveal(zVal);
213213
}
214214
if( (j = fieldId(zName))>=0 ){
215215
aField[j].zValue = fossil_strdup(zVal);
216
- }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
216
+ }else if( strncmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217217
/* TICKET table columns that begin with "tkt_" are always safe */
218218
Th_Store(zName, zVal);
219219
}
220220
free(zRevealed);
221221
}
@@ -843,11 +843,11 @@
843843
if( g.thTrace ){
844844
Th_Trace("append_field %#h {%#h}<br>\n",
845845
TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846846
}
847847
for(idx=0; idx<nField; idx++){
848
- if( memcmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
848
+ if( strncmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849849
&& aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850850
break;
851851
}
852852
}
853853
if( idx>=nField ){
@@ -963,14 +963,14 @@
963963
zValue = Th_Fetch(aField[i].zName, &nValue);
964964
if( zValue ){
965965
nValue = TH1_LEN(nValue);
966966
while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967967
if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
968
- || memcmp(zValue, aField[i].zValue, nValue)!=0
969968
||(int)strlen(aField[i].zValue)!=nValue
969
+ || memcmp(zValue, aField[i].zValue, nValue)!=0
970970
){
971
- if( memcmp(aField[i].zName, "private_", 8)==0 ){
971
+ if( strncmp(aField[i].zName, "private_", 8)==0 ){
972972
zValue = db_conceal(zValue, nValue);
973973
blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974974
aUsed[i] = JCARD_PRIVATE;
975975
}else{
976976
blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
18571857
zValue = aField[iF].zValue;
18581858
aUsed[iF] = JCARD_ASSIGN;
18591859
}else{
18601860
continue;
18611861
}
1862
- if( memcmp(aField[iF].zName, "private_", 8)==0 ){
1862
+ if( strncmp(aField[i].zName, "private_", 8)==0 ){
18631863
zValue = db_conceal(zValue, strlen(zValue));
18641864
blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
18651865
aUsed[iF] = JCARD_PRIVATE;
18661866
}else{
18671867
blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
18681868
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
87 nBaselines = 0;
88 db_prepare(&q, "PRAGMA table_info(ticket)");
89 while( db_step(&q)==SQLITE_ROW ){
90 const char *zFieldName = db_column_text(&q, 1);
91 haveTicket = 1;
92 if( memcmp(zFieldName,"tkt_",4)==0 ){
93 if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
94 continue;
95 }
96 if( memcmp(zFieldName,"baseline for ",13)==0 ){
97 if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
98 nBaselines++;
99 }
100 continue;
101 }
@@ -128,11 +128,11 @@
128 }
129 db_prepare(&q, "PRAGMA table_info(ticketchng)");
130 while( db_step(&q)==SQLITE_ROW ){
131 const char *zFieldName = db_column_text(&q, 1);
132 haveTicketChng = 1;
133 if( memcmp(zFieldName,"tkt_",4)==0 ){
134 if( strcmp(zFieldName+4,"rid")==0 ){
135 haveTicketChngRid = 1; /* tkt_rid */
136 }else if( strcmp(zFieldName+4,"user")==0 ){
137 haveTicketChngUser = 1; /* tkt_user */
138 }
@@ -211,11 +211,11 @@
211 }else if( strncmp(zName, "private_", 8)==0 ){
212 zVal = zRevealed = db_reveal(zVal);
213 }
214 if( (j = fieldId(zName))>=0 ){
215 aField[j].zValue = fossil_strdup(zVal);
216 }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217 /* TICKET table columns that begin with "tkt_" are always safe */
218 Th_Store(zName, zVal);
219 }
220 free(zRevealed);
221 }
@@ -843,11 +843,11 @@
843 if( g.thTrace ){
844 Th_Trace("append_field %#h {%#h}<br>\n",
845 TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846 }
847 for(idx=0; idx<nField; idx++){
848 if( memcmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849 && aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850 break;
851 }
852 }
853 if( idx>=nField ){
@@ -963,14 +963,14 @@
963 zValue = Th_Fetch(aField[i].zName, &nValue);
964 if( zValue ){
965 nValue = TH1_LEN(nValue);
966 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967 if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
968 || memcmp(zValue, aField[i].zValue, nValue)!=0
969 ||(int)strlen(aField[i].zValue)!=nValue
 
970 ){
971 if( memcmp(aField[i].zName, "private_", 8)==0 ){
972 zValue = db_conceal(zValue, nValue);
973 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974 aUsed[i] = JCARD_PRIVATE;
975 }else{
976 blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
1857 zValue = aField[iF].zValue;
1858 aUsed[iF] = JCARD_ASSIGN;
1859 }else{
1860 continue;
1861 }
1862 if( memcmp(aField[iF].zName, "private_", 8)==0 ){
1863 zValue = db_conceal(zValue, strlen(zValue));
1864 blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
1865 aUsed[iF] = JCARD_PRIVATE;
1866 }else{
1867 blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
1868
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
87 nBaselines = 0;
88 db_prepare(&q, "PRAGMA table_info(ticket)");
89 while( db_step(&q)==SQLITE_ROW ){
90 const char *zFieldName = db_column_text(&q, 1);
91 haveTicket = 1;
92 if( strncmp(zFieldName,"tkt_",4)==0 ){
93 if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
94 continue;
95 }
96 if( strncmp(zFieldName,"baseline for ",13)==0 ){
97 if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
98 nBaselines++;
99 }
100 continue;
101 }
@@ -128,11 +128,11 @@
128 }
129 db_prepare(&q, "PRAGMA table_info(ticketchng)");
130 while( db_step(&q)==SQLITE_ROW ){
131 const char *zFieldName = db_column_text(&q, 1);
132 haveTicketChng = 1;
133 if( strncmp(zFieldName,"tkt_",4)==0 ){
134 if( strcmp(zFieldName+4,"rid")==0 ){
135 haveTicketChngRid = 1; /* tkt_rid */
136 }else if( strcmp(zFieldName+4,"user")==0 ){
137 haveTicketChngUser = 1; /* tkt_user */
138 }
@@ -211,11 +211,11 @@
211 }else if( strncmp(zName, "private_", 8)==0 ){
212 zVal = zRevealed = db_reveal(zVal);
213 }
214 if( (j = fieldId(zName))>=0 ){
215 aField[j].zValue = fossil_strdup(zVal);
216 }else if( strncmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217 /* TICKET table columns that begin with "tkt_" are always safe */
218 Th_Store(zName, zVal);
219 }
220 free(zRevealed);
221 }
@@ -843,11 +843,11 @@
843 if( g.thTrace ){
844 Th_Trace("append_field %#h {%#h}<br>\n",
845 TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846 }
847 for(idx=0; idx<nField; idx++){
848 if( strncmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849 && aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850 break;
851 }
852 }
853 if( idx>=nField ){
@@ -963,14 +963,14 @@
963 zValue = Th_Fetch(aField[i].zName, &nValue);
964 if( zValue ){
965 nValue = TH1_LEN(nValue);
966 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967 if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
 
968 ||(int)strlen(aField[i].zValue)!=nValue
969 || memcmp(zValue, aField[i].zValue, nValue)!=0
970 ){
971 if( strncmp(aField[i].zName, "private_", 8)==0 ){
972 zValue = db_conceal(zValue, nValue);
973 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974 aUsed[i] = JCARD_PRIVATE;
975 }else{
976 blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
1857 zValue = aField[iF].zValue;
1858 aUsed[iF] = JCARD_ASSIGN;
1859 }else{
1860 continue;
1861 }
1862 if( strncmp(aField[i].zName, "private_", 8)==0 ){
1863 zValue = db_conceal(zValue, strlen(zValue));
1864 blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
1865 aUsed[iF] = JCARD_PRIVATE;
1866 }else{
1867 blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
1868
+8 -8
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
8787
nBaselines = 0;
8888
db_prepare(&q, "PRAGMA table_info(ticket)");
8989
while( db_step(&q)==SQLITE_ROW ){
9090
const char *zFieldName = db_column_text(&q, 1);
9191
haveTicket = 1;
92
- if( memcmp(zFieldName,"tkt_",4)==0 ){
92
+ if( strncmp(zFieldName,"tkt_",4)==0 ){
9393
if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
9494
continue;
9595
}
96
- if( memcmp(zFieldName,"baseline for ",13)==0 ){
96
+ if( strncmp(zFieldName,"baseline for ",13)==0 ){
9797
if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
9898
nBaselines++;
9999
}
100100
continue;
101101
}
@@ -128,11 +128,11 @@
128128
}
129129
db_prepare(&q, "PRAGMA table_info(ticketchng)");
130130
while( db_step(&q)==SQLITE_ROW ){
131131
const char *zFieldName = db_column_text(&q, 1);
132132
haveTicketChng = 1;
133
- if( memcmp(zFieldName,"tkt_",4)==0 ){
133
+ if( strncmp(zFieldName,"tkt_",4)==0 ){
134134
if( strcmp(zFieldName+4,"rid")==0 ){
135135
haveTicketChngRid = 1; /* tkt_rid */
136136
}else if( strcmp(zFieldName+4,"user")==0 ){
137137
haveTicketChngUser = 1; /* tkt_user */
138138
}
@@ -211,11 +211,11 @@
211211
}else if( strncmp(zName, "private_", 8)==0 ){
212212
zVal = zRevealed = db_reveal(zVal);
213213
}
214214
if( (j = fieldId(zName))>=0 ){
215215
aField[j].zValue = fossil_strdup(zVal);
216
- }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
216
+ }else if( strncmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217217
/* TICKET table columns that begin with "tkt_" are always safe */
218218
Th_Store(zName, zVal);
219219
}
220220
free(zRevealed);
221221
}
@@ -843,11 +843,11 @@
843843
if( g.thTrace ){
844844
Th_Trace("append_field %#h {%#h}<br>\n",
845845
TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846846
}
847847
for(idx=0; idx<nField; idx++){
848
- if( memcmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
848
+ if( strncmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849849
&& aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850850
break;
851851
}
852852
}
853853
if( idx>=nField ){
@@ -963,14 +963,14 @@
963963
zValue = Th_Fetch(aField[i].zName, &nValue);
964964
if( zValue ){
965965
nValue = TH1_LEN(nValue);
966966
while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967967
if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
968
- || memcmp(zValue, aField[i].zValue, nValue)!=0
969968
||(int)strlen(aField[i].zValue)!=nValue
969
+ || memcmp(zValue, aField[i].zValue, nValue)!=0
970970
){
971
- if( memcmp(aField[i].zName, "private_", 8)==0 ){
971
+ if( strncmp(aField[i].zName, "private_", 8)==0 ){
972972
zValue = db_conceal(zValue, nValue);
973973
blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974974
aUsed[i] = JCARD_PRIVATE;
975975
}else{
976976
blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
18571857
zValue = aField[iF].zValue;
18581858
aUsed[iF] = JCARD_ASSIGN;
18591859
}else{
18601860
continue;
18611861
}
1862
- if( memcmp(aField[iF].zName, "private_", 8)==0 ){
1862
+ if( strncmp(aField[i].zName, "private_", 8)==0 ){
18631863
zValue = db_conceal(zValue, strlen(zValue));
18641864
blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
18651865
aUsed[iF] = JCARD_PRIVATE;
18661866
}else{
18671867
blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
18681868
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
87 nBaselines = 0;
88 db_prepare(&q, "PRAGMA table_info(ticket)");
89 while( db_step(&q)==SQLITE_ROW ){
90 const char *zFieldName = db_column_text(&q, 1);
91 haveTicket = 1;
92 if( memcmp(zFieldName,"tkt_",4)==0 ){
93 if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
94 continue;
95 }
96 if( memcmp(zFieldName,"baseline for ",13)==0 ){
97 if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
98 nBaselines++;
99 }
100 continue;
101 }
@@ -128,11 +128,11 @@
128 }
129 db_prepare(&q, "PRAGMA table_info(ticketchng)");
130 while( db_step(&q)==SQLITE_ROW ){
131 const char *zFieldName = db_column_text(&q, 1);
132 haveTicketChng = 1;
133 if( memcmp(zFieldName,"tkt_",4)==0 ){
134 if( strcmp(zFieldName+4,"rid")==0 ){
135 haveTicketChngRid = 1; /* tkt_rid */
136 }else if( strcmp(zFieldName+4,"user")==0 ){
137 haveTicketChngUser = 1; /* tkt_user */
138 }
@@ -211,11 +211,11 @@
211 }else if( strncmp(zName, "private_", 8)==0 ){
212 zVal = zRevealed = db_reveal(zVal);
213 }
214 if( (j = fieldId(zName))>=0 ){
215 aField[j].zValue = fossil_strdup(zVal);
216 }else if( memcmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217 /* TICKET table columns that begin with "tkt_" are always safe */
218 Th_Store(zName, zVal);
219 }
220 free(zRevealed);
221 }
@@ -843,11 +843,11 @@
843 if( g.thTrace ){
844 Th_Trace("append_field %#h {%#h}<br>\n",
845 TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846 }
847 for(idx=0; idx<nField; idx++){
848 if( memcmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849 && aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850 break;
851 }
852 }
853 if( idx>=nField ){
@@ -963,14 +963,14 @@
963 zValue = Th_Fetch(aField[i].zName, &nValue);
964 if( zValue ){
965 nValue = TH1_LEN(nValue);
966 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967 if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
968 || memcmp(zValue, aField[i].zValue, nValue)!=0
969 ||(int)strlen(aField[i].zValue)!=nValue
 
970 ){
971 if( memcmp(aField[i].zName, "private_", 8)==0 ){
972 zValue = db_conceal(zValue, nValue);
973 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974 aUsed[i] = JCARD_PRIVATE;
975 }else{
976 blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
1857 zValue = aField[iF].zValue;
1858 aUsed[iF] = JCARD_ASSIGN;
1859 }else{
1860 continue;
1861 }
1862 if( memcmp(aField[iF].zName, "private_", 8)==0 ){
1863 zValue = db_conceal(zValue, strlen(zValue));
1864 blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
1865 aUsed[iF] = JCARD_PRIVATE;
1866 }else{
1867 blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
1868
--- src/tkt.c
+++ src/tkt.c
@@ -87,15 +87,15 @@
87 nBaselines = 0;
88 db_prepare(&q, "PRAGMA table_info(ticket)");
89 while( db_step(&q)==SQLITE_ROW ){
90 const char *zFieldName = db_column_text(&q, 1);
91 haveTicket = 1;
92 if( strncmp(zFieldName,"tkt_",4)==0 ){
93 if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
94 continue;
95 }
96 if( strncmp(zFieldName,"baseline for ",13)==0 ){
97 if( strcmp(db_column_text(&q,2),"INTEGER")==0 ){
98 nBaselines++;
99 }
100 continue;
101 }
@@ -128,11 +128,11 @@
128 }
129 db_prepare(&q, "PRAGMA table_info(ticketchng)");
130 while( db_step(&q)==SQLITE_ROW ){
131 const char *zFieldName = db_column_text(&q, 1);
132 haveTicketChng = 1;
133 if( strncmp(zFieldName,"tkt_",4)==0 ){
134 if( strcmp(zFieldName+4,"rid")==0 ){
135 haveTicketChngRid = 1; /* tkt_rid */
136 }else if( strcmp(zFieldName+4,"user")==0 ){
137 haveTicketChngUser = 1; /* tkt_user */
138 }
@@ -211,11 +211,11 @@
211 }else if( strncmp(zName, "private_", 8)==0 ){
212 zVal = zRevealed = db_reveal(zVal);
213 }
214 if( (j = fieldId(zName))>=0 ){
215 aField[j].zValue = fossil_strdup(zVal);
216 }else if( strncmp(zName, "tkt_", 4)==0 && Th_Fetch(zName, &size)==0 ){
217 /* TICKET table columns that begin with "tkt_" are always safe */
218 Th_Store(zName, zVal);
219 }
220 free(zRevealed);
221 }
@@ -843,11 +843,11 @@
843 if( g.thTrace ){
844 Th_Trace("append_field %#h {%#h}<br>\n",
845 TH1_LEN(argl[1]), argv[1], TH1_LEN(argl[2]), argv[2]);
846 }
847 for(idx=0; idx<nField; idx++){
848 if( strncmp(aField[idx].zName, argv[1], TH1_LEN(argl[1]))==0
849 && aField[idx].zName[TH1_LEN(argl[1])]==0 ){
850 break;
851 }
852 }
853 if( idx>=nField ){
@@ -963,14 +963,14 @@
963 zValue = Th_Fetch(aField[i].zName, &nValue);
964 if( zValue ){
965 nValue = TH1_LEN(nValue);
966 while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
967 if( ((aField[i].mUsed & USEDBY_TICKETCHNG)!=0 && nValue>0)
 
968 ||(int)strlen(aField[i].zValue)!=nValue
969 || memcmp(zValue, aField[i].zValue, nValue)!=0
970 ){
971 if( strncmp(aField[i].zName, "private_", 8)==0 ){
972 zValue = db_conceal(zValue, nValue);
973 blob_appendf(&tktchng, "J %s %s\n", aField[i].zName, zValue);
974 aUsed[i] = JCARD_PRIVATE;
975 }else{
976 blob_appendf(&tktchng, "J %s %#F\n", aField[i].zName, nValue, zValue);
@@ -1857,11 +1857,11 @@
1857 zValue = aField[iF].zValue;
1858 aUsed[iF] = JCARD_ASSIGN;
1859 }else{
1860 continue;
1861 }
1862 if( strncmp(aField[i].zName, "private_", 8)==0 ){
1863 zValue = db_conceal(zValue, strlen(zValue));
1864 blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[iF].zName, zValue);
1865 aUsed[iF] = JCARD_PRIVATE;
1866 }else{
1867 blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
1868
+1
--- src/user.c
+++ src/user.c
@@ -227,10 +227,11 @@
227227
if( z ) userDescramble(z);
228228
printf("\033[3A\033[J"); /* Erase previous three lines */
229229
fflush(stdout);
230230
}else{
231231
z = getpass(zPrompt);
232
+ if( z==0 ) fossil_fatal("unable to read a password");
232233
}
233234
strip_string(pPassphrase, z);
234235
}
235236
236237
/*
237238
--- src/user.c
+++ src/user.c
@@ -227,10 +227,11 @@
227 if( z ) userDescramble(z);
228 printf("\033[3A\033[J"); /* Erase previous three lines */
229 fflush(stdout);
230 }else{
231 z = getpass(zPrompt);
 
232 }
233 strip_string(pPassphrase, z);
234 }
235
236 /*
237
--- src/user.c
+++ src/user.c
@@ -227,10 +227,11 @@
227 if( z ) userDescramble(z);
228 printf("\033[3A\033[J"); /* Erase previous three lines */
229 fflush(stdout);
230 }else{
231 z = getpass(zPrompt);
232 if( z==0 ) fossil_fatal("unable to read a password");
233 }
234 strip_string(pPassphrase, z);
235 }
236
237 /*
238
+47 -9
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155155
){
156156
blob_appendf(&pXfer->err, "malformed file line");
157157
return;
158158
}
159159
blob_zero(&content);
160
- blob_extract(pXfer->pIn, n, &content);
160
+ if( blob_extract(pXfer->pIn, n, &content)!=n ){
161
+ /* The message ends before the content does. What there is must not
162
+ ** be stored: if it is a delta whose source has not arrived, nothing
163
+ ** would ever check it. */
164
+ blob_appendf(&pXfer->err, "truncated file card");
165
+ blob_reset(&content);
166
+ return;
167
+ }
161168
pUuid = &pXfer->aToken[1];
162169
if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
163170
/* Ignore files that have been shunned */
164171
blob_reset(&content);
165172
return;
@@ -277,11 +284,15 @@
277284
if( isPriv && !g.perm.Private ){
278285
/* Do not accept private files if not authorized */
279286
return;
280287
}
281288
blob_zero(&content);
282
- blob_extract(pXfer->pIn, szC, &content);
289
+ if( blob_extract(pXfer->pIn, szC, &content)!=szC ){
290
+ blob_appendf(&pXfer->err, "truncated cfile card");
291
+ blob_reset(&content);
292
+ return;
293
+ }
283294
if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
284295
/* Ignore files that have been shunned */
285296
blob_reset(&content);
286297
return;
287298
}
@@ -597,11 +608,17 @@
597608
if( size ){
598609
pXfer->nDeltaSent++;
599610
}
600611
}
601612
if( size==0 ){
602
- content_get(rid, &content);
613
+ if( content_get(rid, &content)==0 ){
614
+ /* A delta whose source has not arrived yet. The content cannot
615
+ ** be rebuilt, so there is nothing that can be sent. */
616
+ blob_reset(&content);
617
+ blob_reset(&uuid);
618
+ return;
619
+ }
603620
604621
if( !nativeDelta && blob_size(&content)>100 ){
605622
size = send_delta_parent(pXfer, rid, isPriv, &content, pUuid);
606623
}
607624
if( size==0 ){
@@ -699,19 +716,26 @@
699716
**
700717
** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
701718
**
702719
** If the noContent flag is set, omit the CONTENT and set the 0x0004
703720
** flag in FLAGS.
721
+**
722
+** A server that has already reached its send size limit sends a short
723
+** "uvigot" card in place of the file, and the client asks again. A
724
+** client must not do that, because a server does not accept "uvigot".
725
+** So the client sets isClient and always gets a "uvfile" card.
704726
*/
705727
static void send_unversioned_file(
706728
Xfer *pXfer, /* Transfer context */
707729
const char *zName, /* Name of unversioned file to be sent */
708
- int noContent /* True to omit the content */
730
+ int noContent, /* True to omit the content */
731
+ int isClient /* True if sending from client to server */
709732
){
710733
Stmt q1;
734
+ int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend;
711735
712
- if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ) noContent = 1;
736
+ if( isFull ) noContent = 1;
713737
if( noContent ){
714738
db_prepare(&q1,
715739
"SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q",
716740
zName
717741
);
@@ -728,11 +752,11 @@
728752
if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
729753
xfer_cannot_send_sha3_error(pXfer);
730754
db_reset(&q1);
731755
return;
732756
}
733
- if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ){
757
+ if( isFull ){
734758
/* If we have already reached the send size limit, send a (short)
735759
** uvigot card rather than a uvfile card. This only happens on the
736760
** server side. The uvigot card will provoke the client to resend
737761
** another uvgimme on the next cycle. */
738762
blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
@@ -1436,11 +1460,11 @@
14361460
if( blob_eq(&xfer.aToken[0], "uvgimme")
14371461
&& xfer.nToken==2
14381462
&& blob_is_filename(&xfer.aToken[1])
14391463
){
14401464
if( g.perm.Read ){
1441
- send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0);
1465
+ send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0, 0);
14421466
}
14431467
}else
14441468
14451469
/* igot HASH ?ISPRIVATE?
14461470
**
@@ -2019,10 +2043,12 @@
20192043
}
20202044
if( zHost==0 ) zHost = "localhost:8080";
20212045
g.zBaseURL = mprintf("http://%s", zHost);
20222046
g.zHttpsURL = mprintf("https://%s", zHost);
20232047
g.zTop = mprintf("");
2048
+ g.zPath = "xfer"; /* So that robot_restrict() sees this as a sync request */
2049
+ g.zContentType = "application/x-fossil-uncompressed";
20242050
blob_zero(&g.cgiIn);
20252051
blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE);
20262052
disableLogin = 1;
20272053
page_xfer();
20282054
fossil_print("%s", cgi_extract_content());
@@ -2367,11 +2393,11 @@
23672393
Stmt uvq;
23682394
int rc = SQLITE_OK;
23692395
db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend");
23702396
while( (rc = db_step(&uvq))==SQLITE_ROW ){
23712397
const char *zName = db_column_text(&uvq, 0);
2372
- send_unversioned_file(&xfer, zName, db_column_int(&uvq,1));
2398
+ send_unversioned_file(&xfer, zName, db_column_int(&uvq,1), 1);
23732399
nCardSent++;
23742400
nArtifactSent++;
23752401
db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName);
23762402
if( syncFlags & SYNC_VERBOSE ){
23772403
fossil_print("\rUnversioned-file sent: %s\n", zName);
@@ -2429,10 +2455,22 @@
24292455
if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
24302456
nErr++;
24312457
go = 2;
24322458
break;
24332459
}
2460
+
2461
+ /* Every reply from a Fossil server holds at least one card: the
2462
+ ** "# timestamp" line that ends a normal reply, or an "error" card.
2463
+ ** A reply with no content at all means that the request never reached
2464
+ ** a Fossil server, or that the reply was lost on the way back. Either
2465
+ ** way the round-trip failed. */
2466
+ if( blob_size(&recv)==0 ){
2467
+ fossil_warning("server sent an empty reply");
2468
+ nErr++;
2469
+ go = 2;
2470
+ break;
2471
+ }
24342472
24352473
/* Remember the URL of the sync target in the config file on the
24362474
** first successful round-trip */
24372475
if( nCycle==0 && db_is_writeable("repository") ){
24382476
xfer_syncwith(g.url.canonical, 0);
@@ -2494,11 +2532,11 @@
24942532
24952533
/* Process the reply that came back from the server */
24962534
while( blob_line(&recv, &xfer.line) ){
24972535
if( blob_buffer(&xfer.line)[0]=='#' ){
24982536
const char *zLine = blob_buffer(&xfer.line);
2499
- if( memcmp(zLine, "# timestamp ", 12)==0 ){
2537
+ if( strncmp(zLine, "# timestamp ", 12)==0 ){
25002538
char zTime[20];
25012539
double rDiff;
25022540
sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
25032541
rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
25042542
zTime, rArrivalTime);
25052543
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155 ){
156 blob_appendf(&pXfer->err, "malformed file line");
157 return;
158 }
159 blob_zero(&content);
160 blob_extract(pXfer->pIn, n, &content);
 
 
 
 
 
 
 
161 pUuid = &pXfer->aToken[1];
162 if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
163 /* Ignore files that have been shunned */
164 blob_reset(&content);
165 return;
@@ -277,11 +284,15 @@
277 if( isPriv && !g.perm.Private ){
278 /* Do not accept private files if not authorized */
279 return;
280 }
281 blob_zero(&content);
282 blob_extract(pXfer->pIn, szC, &content);
 
 
 
 
283 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
284 /* Ignore files that have been shunned */
285 blob_reset(&content);
286 return;
287 }
@@ -597,11 +608,17 @@
597 if( size ){
598 pXfer->nDeltaSent++;
599 }
600 }
601 if( size==0 ){
602 content_get(rid, &content);
 
 
 
 
 
 
603
604 if( !nativeDelta && blob_size(&content)>100 ){
605 size = send_delta_parent(pXfer, rid, isPriv, &content, pUuid);
606 }
607 if( size==0 ){
@@ -699,19 +716,26 @@
699 **
700 ** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
701 **
702 ** If the noContent flag is set, omit the CONTENT and set the 0x0004
703 ** flag in FLAGS.
 
 
 
 
 
704 */
705 static void send_unversioned_file(
706 Xfer *pXfer, /* Transfer context */
707 const char *zName, /* Name of unversioned file to be sent */
708 int noContent /* True to omit the content */
 
709 ){
710 Stmt q1;
 
711
712 if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ) noContent = 1;
713 if( noContent ){
714 db_prepare(&q1,
715 "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q",
716 zName
717 );
@@ -728,11 +752,11 @@
728 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
729 xfer_cannot_send_sha3_error(pXfer);
730 db_reset(&q1);
731 return;
732 }
733 if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ){
734 /* If we have already reached the send size limit, send a (short)
735 ** uvigot card rather than a uvfile card. This only happens on the
736 ** server side. The uvigot card will provoke the client to resend
737 ** another uvgimme on the next cycle. */
738 blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
@@ -1436,11 +1460,11 @@
1436 if( blob_eq(&xfer.aToken[0], "uvgimme")
1437 && xfer.nToken==2
1438 && blob_is_filename(&xfer.aToken[1])
1439 ){
1440 if( g.perm.Read ){
1441 send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0);
1442 }
1443 }else
1444
1445 /* igot HASH ?ISPRIVATE?
1446 **
@@ -2019,10 +2043,12 @@
2019 }
2020 if( zHost==0 ) zHost = "localhost:8080";
2021 g.zBaseURL = mprintf("http://%s", zHost);
2022 g.zHttpsURL = mprintf("https://%s", zHost);
2023 g.zTop = mprintf("");
 
 
2024 blob_zero(&g.cgiIn);
2025 blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE);
2026 disableLogin = 1;
2027 page_xfer();
2028 fossil_print("%s", cgi_extract_content());
@@ -2367,11 +2393,11 @@
2367 Stmt uvq;
2368 int rc = SQLITE_OK;
2369 db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend");
2370 while( (rc = db_step(&uvq))==SQLITE_ROW ){
2371 const char *zName = db_column_text(&uvq, 0);
2372 send_unversioned_file(&xfer, zName, db_column_int(&uvq,1));
2373 nCardSent++;
2374 nArtifactSent++;
2375 db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName);
2376 if( syncFlags & SYNC_VERBOSE ){
2377 fossil_print("\rUnversioned-file sent: %s\n", zName);
@@ -2429,10 +2455,22 @@
2429 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2430 nErr++;
2431 go = 2;
2432 break;
2433 }
 
 
 
 
 
 
 
 
 
 
 
 
2434
2435 /* Remember the URL of the sync target in the config file on the
2436 ** first successful round-trip */
2437 if( nCycle==0 && db_is_writeable("repository") ){
2438 xfer_syncwith(g.url.canonical, 0);
@@ -2494,11 +2532,11 @@
2494
2495 /* Process the reply that came back from the server */
2496 while( blob_line(&recv, &xfer.line) ){
2497 if( blob_buffer(&xfer.line)[0]=='#' ){
2498 const char *zLine = blob_buffer(&xfer.line);
2499 if( memcmp(zLine, "# timestamp ", 12)==0 ){
2500 char zTime[20];
2501 double rDiff;
2502 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
2503 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
2504 zTime, rArrivalTime);
2505
--- src/xfer.c
+++ src/xfer.c
@@ -155,11 +155,18 @@
155 ){
156 blob_appendf(&pXfer->err, "malformed file line");
157 return;
158 }
159 blob_zero(&content);
160 if( blob_extract(pXfer->pIn, n, &content)!=n ){
161 /* The message ends before the content does. What there is must not
162 ** be stored: if it is a delta whose source has not arrived, nothing
163 ** would ever check it. */
164 blob_appendf(&pXfer->err, "truncated file card");
165 blob_reset(&content);
166 return;
167 }
168 pUuid = &pXfer->aToken[1];
169 if( !cloneFlag && uuid_is_shunned(blob_str(pUuid)) ){
170 /* Ignore files that have been shunned */
171 blob_reset(&content);
172 return;
@@ -277,11 +284,15 @@
284 if( isPriv && !g.perm.Private ){
285 /* Do not accept private files if not authorized */
286 return;
287 }
288 blob_zero(&content);
289 if( blob_extract(pXfer->pIn, szC, &content)!=szC ){
290 blob_appendf(&pXfer->err, "truncated cfile card");
291 blob_reset(&content);
292 return;
293 }
294 if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){
295 /* Ignore files that have been shunned */
296 blob_reset(&content);
297 return;
298 }
@@ -597,11 +608,17 @@
608 if( size ){
609 pXfer->nDeltaSent++;
610 }
611 }
612 if( size==0 ){
613 if( content_get(rid, &content)==0 ){
614 /* A delta whose source has not arrived yet. The content cannot
615 ** be rebuilt, so there is nothing that can be sent. */
616 blob_reset(&content);
617 blob_reset(&uuid);
618 return;
619 }
620
621 if( !nativeDelta && blob_size(&content)>100 ){
622 size = send_delta_parent(pXfer, rid, isPriv, &content, pUuid);
623 }
624 if( size==0 ){
@@ -699,19 +716,26 @@
716 **
717 ** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
718 **
719 ** If the noContent flag is set, omit the CONTENT and set the 0x0004
720 ** flag in FLAGS.
721 **
722 ** A server that has already reached its send size limit sends a short
723 ** "uvigot" card in place of the file, and the client asks again. A
724 ** client must not do that, because a server does not accept "uvigot".
725 ** So the client sets isClient and always gets a "uvfile" card.
726 */
727 static void send_unversioned_file(
728 Xfer *pXfer, /* Transfer context */
729 const char *zName, /* Name of unversioned file to be sent */
730 int noContent, /* True to omit the content */
731 int isClient /* True if sending from client to server */
732 ){
733 Stmt q1;
734 int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend;
735
736 if( isFull ) noContent = 1;
737 if( noContent ){
738 db_prepare(&q1,
739 "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q",
740 zName
741 );
@@ -728,11 +752,11 @@
752 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753 xfer_cannot_send_sha3_error(pXfer);
754 db_reset(&q1);
755 return;
756 }
757 if( isFull ){
758 /* If we have already reached the send size limit, send a (short)
759 ** uvigot card rather than a uvfile card. This only happens on the
760 ** server side. The uvigot card will provoke the client to resend
761 ** another uvgimme on the next cycle. */
762 blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
@@ -1436,11 +1460,11 @@
1460 if( blob_eq(&xfer.aToken[0], "uvgimme")
1461 && xfer.nToken==2
1462 && blob_is_filename(&xfer.aToken[1])
1463 ){
1464 if( g.perm.Read ){
1465 send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0, 0);
1466 }
1467 }else
1468
1469 /* igot HASH ?ISPRIVATE?
1470 **
@@ -2019,10 +2043,12 @@
2043 }
2044 if( zHost==0 ) zHost = "localhost:8080";
2045 g.zBaseURL = mprintf("http://%s", zHost);
2046 g.zHttpsURL = mprintf("https://%s", zHost);
2047 g.zTop = mprintf("");
2048 g.zPath = "xfer"; /* So that robot_restrict() sees this as a sync request */
2049 g.zContentType = "application/x-fossil-uncompressed";
2050 blob_zero(&g.cgiIn);
2051 blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE);
2052 disableLogin = 1;
2053 page_xfer();
2054 fossil_print("%s", cgi_extract_content());
@@ -2367,11 +2393,11 @@
2393 Stmt uvq;
2394 int rc = SQLITE_OK;
2395 db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend");
2396 while( (rc = db_step(&uvq))==SQLITE_ROW ){
2397 const char *zName = db_column_text(&uvq, 0);
2398 send_unversioned_file(&xfer, zName, db_column_int(&uvq,1), 1);
2399 nCardSent++;
2400 nArtifactSent++;
2401 db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName);
2402 if( syncFlags & SYNC_VERBOSE ){
2403 fossil_print("\rUnversioned-file sent: %s\n", zName);
@@ -2429,10 +2455,22 @@
2455 if( http_exchange(&send, &recv, mHttpFlags, MAX_REDIRECTS, 0) ){
2456 nErr++;
2457 go = 2;
2458 break;
2459 }
2460
2461 /* Every reply from a Fossil server holds at least one card: the
2462 ** "# timestamp" line that ends a normal reply, or an "error" card.
2463 ** A reply with no content at all means that the request never reached
2464 ** a Fossil server, or that the reply was lost on the way back. Either
2465 ** way the round-trip failed. */
2466 if( blob_size(&recv)==0 ){
2467 fossil_warning("server sent an empty reply");
2468 nErr++;
2469 go = 2;
2470 break;
2471 }
2472
2473 /* Remember the URL of the sync target in the config file on the
2474 ** first successful round-trip */
2475 if( nCycle==0 && db_is_writeable("repository") ){
2476 xfer_syncwith(g.url.canonical, 0);
@@ -2494,11 +2532,11 @@
2532
2533 /* Process the reply that came back from the server */
2534 while( blob_line(&recv, &xfer.line) ){
2535 if( blob_buffer(&xfer.line)[0]=='#' ){
2536 const char *zLine = blob_buffer(&xfer.line);
2537 if( strncmp(zLine, "# timestamp ", 12)==0 ){
2538 char zTime[20];
2539 double rDiff;
2540 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
2541 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
2542 zTime, rArrivalTime);
2543
--- tools/translate.c
+++ tools/translate.c
@@ -110,17 +110,15 @@
110110
static void trans(FILE *in, FILE *out){
111111
int i, j, k; /* Loop counters */
112112
char c1, c2; /* Characters used to start a comment */
113113
int lastWasEq = 0; /* True if last non-whitespace character was "=" */
114114
int lastWasComma = 0; /* True if last non-whitespace character was "," */
115
- int lineNo = 0; /* Line number */
116115
char zLine[2000]; /* A single line of input */
117116
char zOut[4000]; /* The input line translated into appropriate output */
118117
119118
c1 = c2 = '-';
120119
while( fgets(zLine, sizeof(zLine), in) ){
121
- lineNo++;
122120
for(i=0; zLine[i] && fossil_isspace(zLine[i]); i++){}
123121
if( zLine[i]!='@' ){
124122
if( inPrint || inStr ) end_block(out);
125123
fprintf(out,"%s",zLine);
126124
/* 0123456789 12345 */
@@ -152,11 +150,10 @@
152150
}
153151
if( zLine[i]=='\\' && (zLine[i+1]==0 || zLine[i+1]=='\r'
154152
|| zLine[i+1]=='\n') ){
155153
zLine[i] = 0;
156154
zNewline = "";
157
- /* fprintf(stderr, "%s:%d: omit newline\n", zInFile, lineNo); */
158155
break;
159156
}
160157
if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
161158
zOut[j++] = zLine[i];
162159
}
163160
--- tools/translate.c
+++ tools/translate.c
@@ -110,17 +110,15 @@
110 static void trans(FILE *in, FILE *out){
111 int i, j, k; /* Loop counters */
112 char c1, c2; /* Characters used to start a comment */
113 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
114 int lastWasComma = 0; /* True if last non-whitespace character was "," */
115 int lineNo = 0; /* Line number */
116 char zLine[2000]; /* A single line of input */
117 char zOut[4000]; /* The input line translated into appropriate output */
118
119 c1 = c2 = '-';
120 while( fgets(zLine, sizeof(zLine), in) ){
121 lineNo++;
122 for(i=0; zLine[i] && fossil_isspace(zLine[i]); i++){}
123 if( zLine[i]!='@' ){
124 if( inPrint || inStr ) end_block(out);
125 fprintf(out,"%s",zLine);
126 /* 0123456789 12345 */
@@ -152,11 +150,10 @@
152 }
153 if( zLine[i]=='\\' && (zLine[i+1]==0 || zLine[i+1]=='\r'
154 || zLine[i+1]=='\n') ){
155 zLine[i] = 0;
156 zNewline = "";
157 /* fprintf(stderr, "%s:%d: omit newline\n", zInFile, lineNo); */
158 break;
159 }
160 if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
161 zOut[j++] = zLine[i];
162 }
163
--- tools/translate.c
+++ tools/translate.c
@@ -110,17 +110,15 @@
110 static void trans(FILE *in, FILE *out){
111 int i, j, k; /* Loop counters */
112 char c1, c2; /* Characters used to start a comment */
113 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
114 int lastWasComma = 0; /* True if last non-whitespace character was "," */
 
115 char zLine[2000]; /* A single line of input */
116 char zOut[4000]; /* The input line translated into appropriate output */
117
118 c1 = c2 = '-';
119 while( fgets(zLine, sizeof(zLine), in) ){
 
120 for(i=0; zLine[i] && fossil_isspace(zLine[i]); i++){}
121 if( zLine[i]!='@' ){
122 if( inPrint || inStr ) end_block(out);
123 fprintf(out,"%s",zLine);
124 /* 0123456789 12345 */
@@ -152,11 +150,10 @@
150 }
151 if( zLine[i]=='\\' && (zLine[i+1]==0 || zLine[i+1]=='\r'
152 || zLine[i+1]=='\n') ){
153 zLine[i] = 0;
154 zNewline = "";
 
155 break;
156 }
157 if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
158 zOut[j++] = zLine[i];
159 }
160

Keyboard Shortcuts

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