Fossil SCM

Correct new-post for anonymous users. Remove the captcha support from the forum pieces - it was introduced inadvertently, is not part of trunk's forum, and supporting it for anonymous users with inline responses would require more surgery.

stephan 2026-06-08 16:13 UTC forum-editor-2026
Commit 0896ceb7954df7f5024ea017bfb96c7bb3c7dc6d4b4aaeab2fea9a99484be723
--- src/captcha.c
+++ src/captcha.c
@@ -712,28 +712,10 @@
712712
}
713713
@ <br/>\
714714
captcha_speakit_button(uSeed, 0);
715715
@ </td></tr></table></div>
716716
}
717
-
718
-/*
719
-** Like captcha_generate() but emits it in a different form, intended
720
-** for consumption by JS.
721
-*/
722
-void captcha_generate_for_js(int mFlags){
723
- unsigned int uSeed;
724
- const char *zDecoded;
725
- char *zCaptcha;
726
-
727
- if( !captcha_needed() && (mFlags & 0x02)==0 ) return;
728
- uSeed = captcha_seed();
729
- zDecoded = captcha_decode(uSeed, 0);
730
- zCaptcha = captcha_render(zDecoded);
731
- @ <div class='hidden captcha-for-js'>%h(zCaptcha)</div>
732
- @ <input type="hidden" name="captchaseed" value="%u(uSeed)">
733
-}
734
-
735717
736718
/*
737719
** Add a "Speak the captcha" button.
738720
*/
739721
void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
740722
--- src/captcha.c
+++ src/captcha.c
@@ -712,28 +712,10 @@
712 }
713 @ <br/>\
714 captcha_speakit_button(uSeed, 0);
715 @ </td></tr></table></div>
716 }
717
718 /*
719 ** Like captcha_generate() but emits it in a different form, intended
720 ** for consumption by JS.
721 */
722 void captcha_generate_for_js(int mFlags){
723 unsigned int uSeed;
724 const char *zDecoded;
725 char *zCaptcha;
726
727 if( !captcha_needed() && (mFlags & 0x02)==0 ) return;
728 uSeed = captcha_seed();
729 zDecoded = captcha_decode(uSeed, 0);
730 zCaptcha = captcha_render(zDecoded);
731 @ <div class='hidden captcha-for-js'>%h(zCaptcha)</div>
732 @ <input type="hidden" name="captchaseed" value="%u(uSeed)">
733 }
734
735
736 /*
737 ** Add a "Speak the captcha" button.
738 */
739 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
740
--- src/captcha.c
+++ src/captcha.c
@@ -712,28 +712,10 @@
712 }
713 @ <br/>\
714 captcha_speakit_button(uSeed, 0);
715 @ </td></tr></table></div>
716 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
718 /*
719 ** Add a "Speak the captcha" button.
720 */
721 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
722
--- src/forum.c
+++ src/forum.c
@@ -2047,11 +2047,10 @@
20472047
When it's enabled, the above won't do anything and
20482048
JS will render the editor form in the next element. */
20492049
@ <div hidden id='forumnew-placeholder'>
20502050
@ <input type='hidden' name='title' value='%h(zTitle)'>
20512051
login_insert_csrf_secret();
2052
- captcha_generate_for_js(0);
20532052
@ </div>
20542053
}
20552054
forum_emit_js();
20562055
style_finish_page();
20572056
}
@@ -2282,11 +2281,10 @@
22822281
@ <div hidden id='forumedit-placeholder'>
22832282
#if 0
22842283
@ <input type='hidden' name='title' value='%h(zTitle)'>
22852284
#endif
22862285
login_insert_csrf_secret();
2287
- captcha_generate_for_js(0);
22882286
@ </div>
22892287
forum_emit_js();
22902288
style_finish_page();
22912289
22922290
}
@@ -2984,11 +2982,10 @@
29842982
const char *zContent;
29852983
const char *zStatus;
29862984
const int bHasAttachment = P("file1")!=0;
29872985
Manifest *pPost = 0;
29882986
char *zNewUuid = 0;
2989
- int goodCaptcha = 1;
29902987
int firt = 0; /* In-reply-to rid or 0 */
29912988
int fpid = 0; /* Post rid being edited or 0 */
29922989
int rc = 0; /* Result code. */
29932990
int nrid = 0; /* New artifact rid. */
29942991
int iPostFlags; /* forum_post_flags() (after perms check) */
@@ -3001,13 +2998,10 @@
30012998
ajax_route_error_forbidden();
30022999
return;
30033000
}else if( !ajax_check_csrf(2) ){
30043001
ajax_route_error_csrf();
30053002
return;
3006
- }else if( 0==(goodCaptcha = captcha_is_correct(0)) ){
3007
- ajax_route_error_captcha();
3008
- return;
30093003
}
30103004
30113005
iPostFlags = forum_post_flags(/*must come after permissions init*/);
30123006
bRollback = (FPOST_DRYRUN & iPostFlags);
30133007
zFpid = P("fpid");
30143008
--- src/forum.c
+++ src/forum.c
@@ -2047,11 +2047,10 @@
2047 When it's enabled, the above won't do anything and
2048 JS will render the editor form in the next element. */
2049 @ <div hidden id='forumnew-placeholder'>
2050 @ <input type='hidden' name='title' value='%h(zTitle)'>
2051 login_insert_csrf_secret();
2052 captcha_generate_for_js(0);
2053 @ </div>
2054 }
2055 forum_emit_js();
2056 style_finish_page();
2057 }
@@ -2282,11 +2281,10 @@
2282 @ <div hidden id='forumedit-placeholder'>
2283 #if 0
2284 @ <input type='hidden' name='title' value='%h(zTitle)'>
2285 #endif
2286 login_insert_csrf_secret();
2287 captcha_generate_for_js(0);
2288 @ </div>
2289 forum_emit_js();
2290 style_finish_page();
2291
2292 }
@@ -2984,11 +2982,10 @@
2984 const char *zContent;
2985 const char *zStatus;
2986 const int bHasAttachment = P("file1")!=0;
2987 Manifest *pPost = 0;
2988 char *zNewUuid = 0;
2989 int goodCaptcha = 1;
2990 int firt = 0; /* In-reply-to rid or 0 */
2991 int fpid = 0; /* Post rid being edited or 0 */
2992 int rc = 0; /* Result code. */
2993 int nrid = 0; /* New artifact rid. */
2994 int iPostFlags; /* forum_post_flags() (after perms check) */
@@ -3001,13 +2998,10 @@
3001 ajax_route_error_forbidden();
3002 return;
3003 }else if( !ajax_check_csrf(2) ){
3004 ajax_route_error_csrf();
3005 return;
3006 }else if( 0==(goodCaptcha = captcha_is_correct(0)) ){
3007 ajax_route_error_captcha();
3008 return;
3009 }
3010
3011 iPostFlags = forum_post_flags(/*must come after permissions init*/);
3012 bRollback = (FPOST_DRYRUN & iPostFlags);
3013 zFpid = P("fpid");
3014
--- src/forum.c
+++ src/forum.c
@@ -2047,11 +2047,10 @@
2047 When it's enabled, the above won't do anything and
2048 JS will render the editor form in the next element. */
2049 @ <div hidden id='forumnew-placeholder'>
2050 @ <input type='hidden' name='title' value='%h(zTitle)'>
2051 login_insert_csrf_secret();
 
2052 @ </div>
2053 }
2054 forum_emit_js();
2055 style_finish_page();
2056 }
@@ -2282,11 +2281,10 @@
2281 @ <div hidden id='forumedit-placeholder'>
2282 #if 0
2283 @ <input type='hidden' name='title' value='%h(zTitle)'>
2284 #endif
2285 login_insert_csrf_secret();
 
2286 @ </div>
2287 forum_emit_js();
2288 style_finish_page();
2289
2290 }
@@ -2984,11 +2982,10 @@
2982 const char *zContent;
2983 const char *zStatus;
2984 const int bHasAttachment = P("file1")!=0;
2985 Manifest *pPost = 0;
2986 char *zNewUuid = 0;
 
2987 int firt = 0; /* In-reply-to rid or 0 */
2988 int fpid = 0; /* Post rid being edited or 0 */
2989 int rc = 0; /* Result code. */
2990 int nrid = 0; /* New artifact rid. */
2991 int iPostFlags; /* forum_post_flags() (after perms check) */
@@ -3001,13 +2998,10 @@
2998 ajax_route_error_forbidden();
2999 return;
3000 }else if( !ajax_check_csrf(2) ){
3001 ajax_route_error_csrf();
3002 return;
 
 
 
3003 }
3004
3005 iPostFlags = forum_post_flags(/*must come after permissions init*/);
3006 bRollback = (FPOST_DRYRUN & iPostFlags);
3007 zFpid = P("fpid");
3008
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -875,36 +875,35 @@
875875
});
876876
});
877877
});
878878
}
879879
880
- F.user.isIndividual = ['anonymous','guest'].indexOf(F.user.name)<0;
880
+ F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0;
881881
882
- const eForumNew = document.body.classList.contains('cpage-forumnew')
882
+ const eForumNew = (
883
+ document.body.classList.contains('cpage-forumnew')
884
+ || document.body.classList.contains('cpage-forume1')
885
+ )
883886
? document.querySelector('#forumnew-placeholder')
884887
: null;
885888
if( eForumNew ){
886
- /* /forumnew */
889
+ /* /forumnew and /forume2 */
887890
const fpe = new F.ForumPostEditor({
888891
draftKey: 'draft-forumnew',
889892
hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
890
- captcha: eForumNew.querySelector('.captcha-for-js'),
891893
ondiscard: ()=>{
892894
window.location = F.repoUrl('forum');
893895
}
894896
});
895897
eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
896898
eForumNew.remove();
897899
fossil.page.fpe = fpe /* for testing via the console */;
898900
}/*eForumNew*/
899
- else if( F.user.isIndividual
900
- && (document.body.classList.contains('cpage-forumpost')
901
- || document.body.classList.contains('cpage-forumthread'))){
901
+ else if( (document.body.classList.contains('cpage-forumpost')
902
+ || document.body.classList.contains('cpage-forumthread'))){
902903
/* /forumpost and /forumthread. Take over the Edit/Reply buttons
903
- to use a ForumPostEditor. Because of complications involving
904
- fetching a captcha, we'll leave the buttons as-is for
905
- non-logged-in users. */
904
+ to use a ForumPostEditor. */
906905
907906
const fetchPost = async (fpid)=>{
908907
return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
909908
.then(r=>r.json())
910909
.then(j=>{
911910
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -875,36 +875,35 @@
875 });
876 });
877 });
878 }
879
880 F.user.isIndividual = ['anonymous','guest'].indexOf(F.user.name)<0;
881
882 const eForumNew = document.body.classList.contains('cpage-forumnew')
 
 
 
883 ? document.querySelector('#forumnew-placeholder')
884 : null;
885 if( eForumNew ){
886 /* /forumnew */
887 const fpe = new F.ForumPostEditor({
888 draftKey: 'draft-forumnew',
889 hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
890 captcha: eForumNew.querySelector('.captcha-for-js'),
891 ondiscard: ()=>{
892 window.location = F.repoUrl('forum');
893 }
894 });
895 eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
896 eForumNew.remove();
897 fossil.page.fpe = fpe /* for testing via the console */;
898 }/*eForumNew*/
899 else if( F.user.isIndividual
900 && (document.body.classList.contains('cpage-forumpost')
901 || document.body.classList.contains('cpage-forumthread'))){
902 /* /forumpost and /forumthread. Take over the Edit/Reply buttons
903 to use a ForumPostEditor. Because of complications involving
904 fetching a captcha, we'll leave the buttons as-is for
905 non-logged-in users. */
906
907 const fetchPost = async (fpid)=>{
908 return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
909 .then(r=>r.json())
910 .then(j=>{
911
--- src/fossil.page.forumpost.js
+++ src/fossil.page.forumpost.js
@@ -875,36 +875,35 @@
875 });
876 });
877 });
878 }
879
880 F.user.isIndividual = ['anonymous','nobody'].indexOf(F.user.name)<0;
881
882 const eForumNew = (
883 document.body.classList.contains('cpage-forumnew')
884 || document.body.classList.contains('cpage-forume1')
885 )
886 ? document.querySelector('#forumnew-placeholder')
887 : null;
888 if( eForumNew ){
889 /* /forumnew and /forume2 */
890 const fpe = new F.ForumPostEditor({
891 draftKey: 'draft-forumnew',
892 hiddenFields: eForumNew.querySelectorAll('input[type=hidden]'),
 
893 ondiscard: ()=>{
894 window.location = F.repoUrl('forum');
895 }
896 });
897 eForumNew.parentElement.insertBefore(fpe.widget, eForumNew);
898 eForumNew.remove();
899 fossil.page.fpe = fpe /* for testing via the console */;
900 }/*eForumNew*/
901 else if( (document.body.classList.contains('cpage-forumpost')
902 || document.body.classList.contains('cpage-forumthread'))){
 
903 /* /forumpost and /forumthread. Take over the Edit/Reply buttons
904 to use a ForumPostEditor. */
 
 
905
906 const fetchPost = async (fpid)=>{
907 return window.fetch(F.repoUrl('ajax/artifact.json?uuid='+fpid))
908 .then(r=>r.json())
909 .then(j=>{
910

Keyboard Shortcuts

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