Fossil SCM

Forum save: fix swapped use of WrForum/WrTForum in the JS-side config. Fail earlier for WrForum users who manage to attach a file to their post. Use separate criteria for post moderation vs attachment moderation to avoid an ambiguity which caused a status tag saved with the post to be elided. Update the no-JS post editor to tell WrTForum users that they can attach after the initial forum save.

stephan 2026-11-09 16:36 UTC forum-attach-moderated
Commit 61ef6678cc023fe80922b2cde7c9cd951b8b96d8b345e5624a1f190dab5bd366
+1 -1
--- src/builtin.c
+++ src/builtin.c
@@ -698,11 +698,11 @@
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));
702702
CX("mayAttachForum: %d,", g.perm.AttachForum
703
- ? 1 : (g.perm.WrForum
703
+ ? 1 : (g.perm.WrTForum
704704
? -1 : 0))
705705
/* 0 = no, 1 = 'B' permissions,
706706
** -1 = moderated attachments. Potential TODO is a setting
707707
** to enable this. */;
708708
CX("enableDebug: %s,", JBOOL(g.perm.Debug || g.perm.Admin));
709709
--- src/builtin.c
+++ src/builtin.c
@@ -698,11 +698,11 @@
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.WrForum
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
--- src/builtin.c
+++ src/builtin.c
@@ -698,11 +698,11 @@
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
--- src/default.css
+++ src/default.css
@@ -2016,10 +2016,13 @@
20162016
/* .attach* = styles for file attachments */
20172017
section.attachlist {}
20182018
details.attachlist > summary {
20192019
cursor: pointer;
20202020
}
2021
+div.forumpost > details.attachlist {
2022
+ margin-bottom: 0.5em/*else too cramped with the buttons*/;
2023
+}
20212024
/* .Attacher is the top container element used by the JS Attacher
20222025
class in fossil.attach.js. */
20232026
.Attacher {
20242027
margin-bottom: 1em;
20252028
display: flex;
20262029
--- src/default.css
+++ src/default.css
@@ -2016,10 +2016,13 @@
2016 /* .attach* = styles for file attachments */
2017 section.attachlist {}
2018 details.attachlist > summary {
2019 cursor: pointer;
2020 }
 
 
 
2021 /* .Attacher is the top container element used by the JS Attacher
2022 class in fossil.attach.js. */
2023 .Attacher {
2024 margin-bottom: 1em;
2025 display: flex;
2026
--- src/default.css
+++ src/default.css
@@ -2016,10 +2016,13 @@
2016 /* .attach* = styles for file attachments */
2017 section.attachlist {}
2018 details.attachlist > summary {
2019 cursor: pointer;
2020 }
2021 div.forumpost > details.attachlist {
2022 margin-bottom: 0.5em/*else too cramped with the buttons*/;
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
+19 -24
--- 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
@@ -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
@@ -3267,27 +3267,24 @@
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 bNeedsModeration = -1; /* -1 = we don't yet know */
3272
+ int bModPost = 0; /* Moderate post? */
3273
+ int bModAttach; /* Moderate attachment? */
32733274
32743275
if( !ajax_route_bootstrap(0, 1) ){
32753276
return;
3276
- }else if( !g.perm.WrForum ){
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;
32823284
}
32833285
3284
- if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){
3285
- /* 2026-11-09: a user with WrForum but not AttachForum may attach
3286
- ** but they'll be moderated. */
3287
- bNeedsModeration = 1;
3288
- }
32893286
iPostFlags = forum_post_flags(/*must come after permissions init*/);
32903287
bRollback = (FPOST_DRYRUN & iPostFlags);
32913288
zFpid = P("fpid");
32923289
zIrt = P("firt");
32933290
zMimetype = P("mimetype");
@@ -3327,17 +3324,18 @@
33273324
rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID.");
33283325
goto ajax_save_end;
33293326
}
33303327
}
33313328
3332
- if( 0 ){
3333
- rc = -ajax_route_error(400, "Save is TODO. "
3334
- "iPostFlags=%d debug=%d",
3335
- iPostFlags, g.perm.Debug);
3336
- 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;
33373336
}
3338
-
33393337
zTitle = firt ? 0 : P("title");
33403338
nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype,
33413339
zContent, iPostFlags);
33423340
if( nrid<0 ){
33433341
rc = nrid;
@@ -3353,23 +3351,20 @@
33533351
goto ajax_save_end;
33543352
}else{
33553353
const int fpHead = forumpost_head_rid(nrid);
33563354
assert( nrid>0 );
33573355
assert( fpHead>0 );
3358
- if( bNeedsModeration<0 ){
3359
- bNeedsModeration = forum_need_moderation();
3360
- }
33613356
zNewUuid = rid_to_uuid(nrid);
33623357
if( bHasAttachment ){
33633358
/* Attachments */
33643359
if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){
3365
- rc = -ajax_route_error(403, "No permission no attach files.");
3360
+ rc = -ajax_route_error(403, "No permission to attach files.");
33663361
goto ajax_save_end;
33673362
}else{
33683363
char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead);
33693364
nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid,
3370
- bNeedsModeration);
3365
+ bModAttach);
33713366
fossil_free(zRoot);
33723367
if( nAttach<0 ){
33733368
rc = nAttach;
33743369
goto ajax_save_end;
33753370
}
@@ -3392,11 +3387,11 @@
33923387
fpHead, fpHead
33933388
);
33943389
}
33953390
}
33963391
}
3397
- if( 0==bNeedsModeration
3392
+ if( 0==bModPost
33983393
/* ^^^ Do not allow a status tag on a pending-moderation post
33993394
** because it will introduce a reference to an artifact which
34003395
** will become a phantom if it is rejected by a moderator. */
34013396
&& zStatus!=0 && zStatus[0]!=0
34023397
&& forum_may_set_status(nrid)
34033398
--- 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
@@ -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
@@ -3267,27 +3267,24 @@
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 bNeedsModeration = -1; /* -1 = we don't yet know */
 
3273
3274 if( !ajax_route_bootstrap(0, 1) ){
3275 return;
3276 }else if( !g.perm.WrForum ){
 
3277 ajax_route_error_forbidden();
3278 return;
3279 }else if( !ajax_check_csrf(2) ){
3280 ajax_route_error_csrf();
3281 return;
3282 }
3283
3284 if( bHasAttachment && !g.perm.AttachForum && g.perm.WrTForum ){
3285 /* 2026-11-09: a user with WrForum but not AttachForum may attach
3286 ** but they'll be moderated. */
3287 bNeedsModeration = 1;
3288 }
3289 iPostFlags = forum_post_flags(/*must come after permissions init*/);
3290 bRollback = (FPOST_DRYRUN & iPostFlags);
3291 zFpid = P("fpid");
3292 zIrt = P("firt");
3293 zMimetype = P("mimetype");
@@ -3327,17 +3324,18 @@
3327 rc = -ajax_route_error(404, "Cannot resolve in-reply-do ID.");
3328 goto ajax_save_end;
3329 }
3330 }
3331
3332 if( 0 ){
3333 rc = -ajax_route_error(400, "Save is TODO. "
3334 "iPostFlags=%d debug=%d",
3335 iPostFlags, g.perm.Debug);
3336 goto ajax_save_end;
 
 
3337 }
3338
3339 zTitle = firt ? 0 : P("title");
3340 nrid = forum_post_ajax(zTitle, firt, fpid, 0, zMimetype,
3341 zContent, iPostFlags);
3342 if( nrid<0 ){
3343 rc = nrid;
@@ -3353,23 +3351,20 @@
3353 goto ajax_save_end;
3354 }else{
3355 const int fpHead = forumpost_head_rid(nrid);
3356 assert( nrid>0 );
3357 assert( fpHead>0 );
3358 if( bNeedsModeration<0 ){
3359 bNeedsModeration = forum_need_moderation();
3360 }
3361 zNewUuid = rid_to_uuid(nrid);
3362 if( bHasAttachment ){
3363 /* Attachments */
3364 if( !g.perm.Admin && !(g.perm.AttachForum ||g.perm.WrTForum) ){
3365 rc = -ajax_route_error(403, "No permission no attach files.");
3366 goto ajax_save_end;
3367 }else{
3368 char *zRoot = (nrid==fpHead) ? 0 : rid_to_uuid(fpHead);
3369 nAttach = attachments_ajax_from_POST(zRoot ? zRoot : zNewUuid,
3370 bNeedsModeration);
3371 fossil_free(zRoot);
3372 if( nAttach<0 ){
3373 rc = nAttach;
3374 goto ajax_save_end;
3375 }
@@ -3392,11 +3387,11 @@
3392 fpHead, fpHead
3393 );
3394 }
3395 }
3396 }
3397 if( 0==bNeedsModeration
3398 /* ^^^ Do not allow a status tag on a pending-moderation post
3399 ** because it will introduce a reference to an artifact which
3400 ** will become a phantom if it is rejected by a moderator. */
3401 && zStatus!=0 && zStatus[0]!=0
3402 && forum_may_set_status(nrid)
3403
--- 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
@@ -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
@@ -3267,27 +3267,24 @@
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;
3284 }
3285
 
 
 
 
 
3286 iPostFlags = forum_post_flags(/*must come after permissions init*/);
3287 bRollback = (FPOST_DRYRUN & iPostFlags);
3288 zFpid = P("fpid");
3289 zIrt = P("firt");
3290 zMimetype = P("mimetype");
@@ -3327,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;
@@ -3353,23 +3351,20 @@
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 }
@@ -3392,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

Keyboard Shortcuts

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