Fossil SCM

Use webpage_error() instead of fossil_fatal() in some new error cases.

stephan 2026-05-23 14:09 UTC forum-attachments
Commit 9692f7ba547fdf99e95fa78c05c0d093773a7d5939c0a77e32a678a78c2b3995
1 file changed +7 -7
+7 -7
--- src/attach.c
+++ src/attach.c
@@ -98,11 +98,11 @@
9898
char *zUuid;
9999
if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100100
style_header("Attachments To %h", zForumPost);
101101
fnid = forumpost_head_rid2(zForumPost);
102102
if( fnid<=0 ){
103
- fossil_fatal("Invalid forum post ID: %h", zForumPost);
103
+ webpage_error("Invalid forum post ID: %h", zForumPost);
104104
}
105105
zUuid = rid_to_uuid(fnid);
106106
blob_append_sql(&sql, " WHERE target=%Q", zUuid);
107107
fossil_free(zUuid);
108108
}else if( zPage ){
@@ -409,16 +409,16 @@
409409
int szLimit = 0;
410410
411411
if( zFrom==0 ) zFrom = mprintf("%R/home");
412412
if( P("cancel") ) cgi_redirect(zFrom);
413413
if( (!!zPage + !!zTkt + !!zTechNote + !!zForumPost)!=1 ){
414
- fossil_fatal("Requires exactly one one: page=X, tkt=X, forumpost=X, or technote=X");
414
+ webpage_error("Requires exactly one one: page=X, tkt=X, forumpost=X, or technote=X");
415415
}
416416
login_check_credentials();
417417
szLimit = db_get_int("attachment-size-limit", 0);
418418
if( szContent<0 || (szLimit && szContent>szLimit) ){
419
- fossil_fatal("Attachment %s is too large. Limit is %d bytes.", zName,
419
+ webpage_error("Attachment %s is too large. Limit is %d bytes.", zName,
420420
szLimit ? szLimit : 0x7fffffff);
421421
}
422422
if( zForumPost ){
423423
int fpid;
424424
if( g.perm.AttachForum==0 ){
@@ -425,13 +425,13 @@
425425
login_needed(g.anon.AttachForum);
426426
return;
427427
}
428428
fpid = forumpost_head_rid2(zForumPost);
429429
if( fpid<=0 ){
430
- fossil_fatal("Invalid forum post ID: %h", zForumPost);
430
+ webpage_error("Invalid forum post ID: %h", zForumPost);
431431
}else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
432
- fossil_fatal("Only admins can attach files to other users' "
432
+ webpage_error("Only admins can attach files to other users' "
433433
"forum posts.");
434434
}
435435
zTarget = zExtraFree = rid_to_uuid(fpid);
436436
zTargetType = mprintf("Forum post <a href=\"%R/forumpost/%S\">%h</a>",
437437
zTarget, zForumPost);
@@ -604,12 +604,12 @@
604604
Blob manifest;
605605
Blob cksum;
606606
const char *zFile = zName;
607607
608608
if( !g.perm.Admin && !bUserIsOwner ){
609
- fossil_fatal("Only admins can delete other users' attachments from "
610
- "forum posts.");
609
+ webpage_error("Only admins can delete other users' attachments from "
610
+ "forum posts.");
611611
}
612612
db_begin_transaction();
613613
blob_zero(&manifest);
614614
for(i=n=0; zFile[i]; i++){
615615
if( zFile[i]=='/' || zFile[i]=='\\' ) n = i;
616616
--- src/attach.c
+++ src/attach.c
@@ -98,11 +98,11 @@
98 char *zUuid;
99 if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100 style_header("Attachments To %h", zForumPost);
101 fnid = forumpost_head_rid2(zForumPost);
102 if( fnid<=0 ){
103 fossil_fatal("Invalid forum post ID: %h", zForumPost);
104 }
105 zUuid = rid_to_uuid(fnid);
106 blob_append_sql(&sql, " WHERE target=%Q", zUuid);
107 fossil_free(zUuid);
108 }else if( zPage ){
@@ -409,16 +409,16 @@
409 int szLimit = 0;
410
411 if( zFrom==0 ) zFrom = mprintf("%R/home");
412 if( P("cancel") ) cgi_redirect(zFrom);
413 if( (!!zPage + !!zTkt + !!zTechNote + !!zForumPost)!=1 ){
414 fossil_fatal("Requires exactly one one: page=X, tkt=X, forumpost=X, or technote=X");
415 }
416 login_check_credentials();
417 szLimit = db_get_int("attachment-size-limit", 0);
418 if( szContent<0 || (szLimit && szContent>szLimit) ){
419 fossil_fatal("Attachment %s is too large. Limit is %d bytes.", zName,
420 szLimit ? szLimit : 0x7fffffff);
421 }
422 if( zForumPost ){
423 int fpid;
424 if( g.perm.AttachForum==0 ){
@@ -425,13 +425,13 @@
425 login_needed(g.anon.AttachForum);
426 return;
427 }
428 fpid = forumpost_head_rid2(zForumPost);
429 if( fpid<=0 ){
430 fossil_fatal("Invalid forum post ID: %h", zForumPost);
431 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
432 fossil_fatal("Only admins can attach files to other users' "
433 "forum posts.");
434 }
435 zTarget = zExtraFree = rid_to_uuid(fpid);
436 zTargetType = mprintf("Forum post <a href=\"%R/forumpost/%S\">%h</a>",
437 zTarget, zForumPost);
@@ -604,12 +604,12 @@
604 Blob manifest;
605 Blob cksum;
606 const char *zFile = zName;
607
608 if( !g.perm.Admin && !bUserIsOwner ){
609 fossil_fatal("Only admins can delete other users' attachments from "
610 "forum posts.");
611 }
612 db_begin_transaction();
613 blob_zero(&manifest);
614 for(i=n=0; zFile[i]; i++){
615 if( zFile[i]=='/' || zFile[i]=='\\' ) n = i;
616
--- src/attach.c
+++ src/attach.c
@@ -98,11 +98,11 @@
98 char *zUuid;
99 if( g.perm.RdForum==0 ){ login_needed(g.anon.RdForum); return; }
100 style_header("Attachments To %h", zForumPost);
101 fnid = forumpost_head_rid2(zForumPost);
102 if( fnid<=0 ){
103 webpage_error("Invalid forum post ID: %h", zForumPost);
104 }
105 zUuid = rid_to_uuid(fnid);
106 blob_append_sql(&sql, " WHERE target=%Q", zUuid);
107 fossil_free(zUuid);
108 }else if( zPage ){
@@ -409,16 +409,16 @@
409 int szLimit = 0;
410
411 if( zFrom==0 ) zFrom = mprintf("%R/home");
412 if( P("cancel") ) cgi_redirect(zFrom);
413 if( (!!zPage + !!zTkt + !!zTechNote + !!zForumPost)!=1 ){
414 webpage_error("Requires exactly one one: page=X, tkt=X, forumpost=X, or technote=X");
415 }
416 login_check_credentials();
417 szLimit = db_get_int("attachment-size-limit", 0);
418 if( szContent<0 || (szLimit && szContent>szLimit) ){
419 webpage_error("Attachment %s is too large. Limit is %d bytes.", zName,
420 szLimit ? szLimit : 0x7fffffff);
421 }
422 if( zForumPost ){
423 int fpid;
424 if( g.perm.AttachForum==0 ){
@@ -425,13 +425,13 @@
425 login_needed(g.anon.AttachForum);
426 return;
427 }
428 fpid = forumpost_head_rid2(zForumPost);
429 if( fpid<=0 ){
430 webpage_error("Invalid forum post ID: %h", zForumPost);
431 }else if( !g.perm.Admin && !forumpost_is_owner(fpid, 0) ){
432 webpage_error("Only admins can attach files to other users' "
433 "forum posts.");
434 }
435 zTarget = zExtraFree = rid_to_uuid(fpid);
436 zTargetType = mprintf("Forum post <a href=\"%R/forumpost/%S\">%h</a>",
437 zTarget, zForumPost);
@@ -604,12 +604,12 @@
604 Blob manifest;
605 Blob cksum;
606 const char *zFile = zName;
607
608 if( !g.perm.Admin && !bUserIsOwner ){
609 webpage_error("Only admins can delete other users' attachments from "
610 "forum posts.");
611 }
612 db_begin_transaction();
613 blob_zero(&manifest);
614 for(i=n=0; zFile[i]; i++){
615 if( zFile[i]=='/' || zFile[i]=='\\' ) n = i;
616

Keyboard Shortcuts

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