[PATCH] testbot/web: Require filling the captcha on the feedback page.

Francois Gouget fgouget at codeweavers.com
Thu Dec 5 03:39:43 CST 2019


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 at codeweavers.com>
---
 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 36f0a2b06..b43397fda 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;
-- 
2.20.1




More information about the wine-devel mailing list