Fossil SCM

Fix the test-captcha sequence so that it remembers it is doing a test and does not try to set the anonymous login on a successful captcha.

drh 2024-07-29 13:15 trunk
Commit 3771f2d635ad6d94da0f09f47cd354c5721140f7f8459f75ac231a1e949c0754
1 file changed +18 -7
+18 -7
--- src/captcha.c
+++ src/captcha.c
@@ -689,15 +689,18 @@
689689
690690
/* This appears to be a spider. Offer the captcha */
691691
style_set_current_feature("captcha");
692692
style_header("I think you are a robot");
693693
style_submenu_enable(0);
694
- @ <form method='POST' action='%R/captchacb'>
694
+ @ <form method='POST' action='%R/ityaar'>
695695
@ <p>You seem like a robot.
696696
@
697697
@ <p>If you are human, you can prove that by solving the captcha below,
698698
@ after which you will be allowed to proceed.
699
+ if( bTest ){
700
+ @ <input type="hidden" name="istest" value="1">
701
+ }
699702
captcha_generate(3);
700703
@ </form>
701704
if( !bTest ){
702705
if( P("fossil-goto")==0 ){
703706
cgi_set_cookie("fossil-goto", cgi_reconstruct_original_url(), 0, 600);
@@ -707,26 +710,34 @@
707710
}
708711
return 1;
709712
}
710713
711714
/*
712
-** WEBPAGE: captchacb
715
+** WEBPAGE: ityaar
713716
**
714
-** This is action for the form that is the captcha. Not intended
715
-** for external use.
717
+** This is the action for the form that is the captcha. Not intended
718
+** for external use. "ityaar" is an acronym "I Think You Are A Robot".
716719
**
717720
** If the captcha is correctly solved, then an anonymous login cookie
718721
** is set. Regardless of whether or not the captcha was solved, this
719722
** page always redirects to the fossil-goto cookie.
720723
*/
721724
void captcha_callback(void){
725
+ int bTest = atoi(PD("istest","0"));
722726
if( captcha_is_correct(1) ){
723
- login_set_anon_cookie(0, 0);
724
- cgi_append_header("X-Robot: 0\r\n");
727
+ if( bTest==0 ){
728
+ login_set_anon_cookie(0, 0);
729
+ cgi_append_header("X-Robot: 0\r\n");
730
+ }
725731
login_redirect_to_g();
726732
}else{
727
- exclude_spiders(0);
733
+ g.isHuman = 0;
734
+ (void)exclude_spiders(bTest);
735
+ if( bTest ){
736
+ @ <hr><p>Wrong code. Try again
737
+ style_finish_page();
738
+ }
728739
}
729740
}
730741
731742
732743
/*
733744
--- src/captcha.c
+++ src/captcha.c
@@ -689,15 +689,18 @@
689
690 /* This appears to be a spider. Offer the captcha */
691 style_set_current_feature("captcha");
692 style_header("I think you are a robot");
693 style_submenu_enable(0);
694 @ <form method='POST' action='%R/captchacb'>
695 @ <p>You seem like a robot.
696 @
697 @ <p>If you are human, you can prove that by solving the captcha below,
698 @ after which you will be allowed to proceed.
 
 
 
699 captcha_generate(3);
700 @ </form>
701 if( !bTest ){
702 if( P("fossil-goto")==0 ){
703 cgi_set_cookie("fossil-goto", cgi_reconstruct_original_url(), 0, 600);
@@ -707,26 +710,34 @@
707 }
708 return 1;
709 }
710
711 /*
712 ** WEBPAGE: captchacb
713 **
714 ** This is action for the form that is the captcha. Not intended
715 ** for external use.
716 **
717 ** If the captcha is correctly solved, then an anonymous login cookie
718 ** is set. Regardless of whether or not the captcha was solved, this
719 ** page always redirects to the fossil-goto cookie.
720 */
721 void captcha_callback(void){
 
722 if( captcha_is_correct(1) ){
723 login_set_anon_cookie(0, 0);
724 cgi_append_header("X-Robot: 0\r\n");
 
 
725 login_redirect_to_g();
726 }else{
727 exclude_spiders(0);
 
 
 
 
 
728 }
729 }
730
731
732 /*
733
--- src/captcha.c
+++ src/captcha.c
@@ -689,15 +689,18 @@
689
690 /* This appears to be a spider. Offer the captcha */
691 style_set_current_feature("captcha");
692 style_header("I think you are a robot");
693 style_submenu_enable(0);
694 @ <form method='POST' action='%R/ityaar'>
695 @ <p>You seem like a robot.
696 @
697 @ <p>If you are human, you can prove that by solving the captcha below,
698 @ after which you will be allowed to proceed.
699 if( bTest ){
700 @ <input type="hidden" name="istest" value="1">
701 }
702 captcha_generate(3);
703 @ </form>
704 if( !bTest ){
705 if( P("fossil-goto")==0 ){
706 cgi_set_cookie("fossil-goto", cgi_reconstruct_original_url(), 0, 600);
@@ -707,26 +710,34 @@
710 }
711 return 1;
712 }
713
714 /*
715 ** WEBPAGE: ityaar
716 **
717 ** This is the action for the form that is the captcha. Not intended
718 ** for external use. "ityaar" is an acronym "I Think You Are A Robot".
719 **
720 ** If the captcha is correctly solved, then an anonymous login cookie
721 ** is set. Regardless of whether or not the captcha was solved, this
722 ** page always redirects to the fossil-goto cookie.
723 */
724 void captcha_callback(void){
725 int bTest = atoi(PD("istest","0"));
726 if( captcha_is_correct(1) ){
727 if( bTest==0 ){
728 login_set_anon_cookie(0, 0);
729 cgi_append_header("X-Robot: 0\r\n");
730 }
731 login_redirect_to_g();
732 }else{
733 g.isHuman = 0;
734 (void)exclude_spiders(bTest);
735 if( bTest ){
736 @ <hr><p>Wrong code. Try again
737 style_finish_page();
738 }
739 }
740 }
741
742
743 /*
744

Keyboard Shortcuts

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