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.
Commit
3771f2d635ad6d94da0f09f47cd354c5721140f7f8459f75ac231a1e949c0754
Parent
dc86831179acbe3…
1 file changed
+18
-7
+18
-7
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -689,15 +689,18 @@ | ||
| 689 | 689 | |
| 690 | 690 | /* This appears to be a spider. Offer the captcha */ |
| 691 | 691 | style_set_current_feature("captcha"); |
| 692 | 692 | style_header("I think you are a robot"); |
| 693 | 693 | style_submenu_enable(0); |
| 694 | - @ <form method='POST' action='%R/captchacb'> | |
| 694 | + @ <form method='POST' action='%R/ityaar'> | |
| 695 | 695 | @ <p>You seem like a robot. |
| 696 | 696 | @ |
| 697 | 697 | @ <p>If you are human, you can prove that by solving the captcha below, |
| 698 | 698 | @ after which you will be allowed to proceed. |
| 699 | + if( bTest ){ | |
| 700 | + @ <input type="hidden" name="istest" value="1"> | |
| 701 | + } | |
| 699 | 702 | captcha_generate(3); |
| 700 | 703 | @ </form> |
| 701 | 704 | if( !bTest ){ |
| 702 | 705 | if( P("fossil-goto")==0 ){ |
| 703 | 706 | cgi_set_cookie("fossil-goto", cgi_reconstruct_original_url(), 0, 600); |
| @@ -707,26 +710,34 @@ | ||
| 707 | 710 | } |
| 708 | 711 | return 1; |
| 709 | 712 | } |
| 710 | 713 | |
| 711 | 714 | /* |
| 712 | -** WEBPAGE: captchacb | |
| 715 | +** WEBPAGE: ityaar | |
| 713 | 716 | ** |
| 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". | |
| 716 | 719 | ** |
| 717 | 720 | ** If the captcha is correctly solved, then an anonymous login cookie |
| 718 | 721 | ** is set. Regardless of whether or not the captcha was solved, this |
| 719 | 722 | ** page always redirects to the fossil-goto cookie. |
| 720 | 723 | */ |
| 721 | 724 | void captcha_callback(void){ |
| 725 | + int bTest = atoi(PD("istest","0")); | |
| 722 | 726 | 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 | + } | |
| 725 | 731 | login_redirect_to_g(); |
| 726 | 732 | }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 | + } | |
| 728 | 739 | } |
| 729 | 740 | } |
| 730 | 741 | |
| 731 | 742 | |
| 732 | 743 | /* |
| 733 | 744 |
| --- 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 |