Module: tools Branch: master Commit: 345c225095e4be9cb97057e19b82cfd6f7a3e17b URL: https://source.winehq.org/git/tools.git/?a=commit;h=345c225095e4be9cb97057e1...
Author: Francois Gouget fgouget@codeweavers.com Date: Thu Dec 5 10:39:43 2019 +0100
testbot/web: Require filling the captcha on the feedback page.
Spammers (or their bots) have taken to spamming the TestBot's feedback page. As if that was going to egt them anywhere! The captcha is only required for users who are not logged in obviously.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/web/Feedback.pl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/testbot/web/Feedback.pl b/testbot/web/Feedback.pl index 36f0a2b..b43397f 100644 --- a/testbot/web/Feedback.pl +++ b/testbot/web/Feedback.pl @@ -33,16 +33,21 @@ sub _initialize($$$) { my ($self, $Request, $RequiredRole) = @_;
+ my $Session = $self->GetCurrentSession(); my @PropertyDescriptors = ( CreateBasicPropertyDescriptor("Name", "Name", !1, !1, "A", 40), CreateBasicPropertyDescriptor("EMail", "Email", !1, !1, "A", 40), CreateBasicPropertyDescriptor("Remarks", "Remarks", !1, 1, "textarea", 1024), ); + if (!$Session and $RegistrationQ) + { + $self->GetParam("FeedA", "") if (!defined $self->GetParam("FeedA")); + push @PropertyDescriptors, CreateBasicPropertyDescriptor("FeedA", "Please demonstrate you are not a bot by answering this question: $RegistrationQ", !1, 1, "A", 40); + }
$self->SUPER::_initialize($Request, $RequiredRole, @PropertyDescriptors);
- my $Session = $self->GetCurrentSession(); - if (defined($Session)) + if ($Session) { # Provide default values my $User = $Session->User; @@ -79,6 +84,17 @@ sub OnSend($) { my ($self) = @_;
+ my $Session = $self->GetCurrentSession(); + if (!$Session and $RegistrationQ) + { + my $FeedA = $self->GetParam("FeedA"); + if ($FeedA !~ /$RegistrationARE/) + { + $self->{ErrMessage} = "Wrong 'captcha' answer. Please try again."; + $self->{ErrField} = "Captcha"; + return !1; + } + } if (! $self->Validate) { return !1;