Bug 453652 - improve captcha to reduce spam, re-resolve bug 453613, fix bug 453619 to inform feedbackers they need to CC the submitter.
git-svn-id: svn://10.0.0.236/trunk@254048 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -34,13 +34,19 @@ use Template;
|
||||
use CGI;
|
||||
use Email::Send;
|
||||
use Net::RBLClient;
|
||||
use Captcha::reCAPTCHA;
|
||||
|
||||
# use CGI::Carp qw(fatalsToBrowser);
|
||||
|
||||
# Configuration
|
||||
my $STATIC_CAPTCHA_RESULT = "7";
|
||||
# If you are using Hendrix on your site, you'll need new API keys.
|
||||
# Get them at http://recaptcha.net/api/getkey . If these variables contain
|
||||
# keys, they won't work for you anyway.
|
||||
my $RECAPTCHA_PUBLIC = "6LckBgMAAAAAAHlkAGWVrdc3gorusTVlLjixmeFh";
|
||||
my $RECAPTCHA_PRIVATE = "6LckBgMAAAAAACSa3zXC9K3_TU2KaDsLyt9UXSW2";
|
||||
|
||||
# Map products to destination
|
||||
# When updating these two lists, don't forget the browser detection code in
|
||||
# index.html.tmpl.
|
||||
my %product_destination_map = (
|
||||
"Firefox" => "mozilla.feedback.firefox",
|
||||
"Firefox Release Candidate" => "mozilla.feedback.firefox.prerelease",
|
||||
@@ -96,8 +102,10 @@ my $form = $cgi->Vars;
|
||||
my $vars;
|
||||
$vars->{'form'} = $form;
|
||||
$vars->{'products'} = \@products_list;
|
||||
$vars->{'default_product'} = $form->{'product'};
|
||||
$vars->{'stylesheet'} = $skin;
|
||||
$vars->{'referer'} = $::ENV{'HTTP_REFERER'};
|
||||
$vars->{'recaptcha_public_key'} = $RECAPTCHA_PUBLIC;
|
||||
|
||||
my $template = Template->new({
|
||||
INCLUDE_PATH => ["template"],
|
||||
@@ -117,12 +125,7 @@ if (!$action) {
|
||||
$template->process("index.html.tmpl", $vars)
|
||||
|| die("Template process failed: " . $template->error() . "\n");
|
||||
}
|
||||
elsif ($action eq "submit") {
|
||||
if (defined($form->{'captcha'}) &&
|
||||
($form->{'captcha'} ne $STATIC_CAPTCHA_RESULT)) {
|
||||
throwError("captcha_error");
|
||||
}
|
||||
|
||||
elsif ($action eq "submit") {
|
||||
# Check the poster's IP against some blacklists
|
||||
$rbl->lookup($::ENV{REMOTE_ADDR});
|
||||
my %rbl_results = $rbl->txt_hash();
|
||||
@@ -131,6 +134,27 @@ elsif ($action eq "submit") {
|
||||
throwError("rbl_hit");
|
||||
}
|
||||
|
||||
# Check the CAPTCHA
|
||||
# throwError("captcha_error");
|
||||
# XXX Currently we allow posting if CAPTCHA is not present. This is
|
||||
# a temporary measure so we don't have to have a flag day to update
|
||||
# all the different places which feed into Hendrix. We can then come
|
||||
# back and change this to throw an error for a bogus CAPTCHA.
|
||||
if ($form->{'recaptcha_response_field'} ||
|
||||
$form->{'recaptcha_challenge_field'})
|
||||
{
|
||||
my $c = Captcha::reCAPTCHA->new;
|
||||
|
||||
my $result = $c->check_answer($RECAPTCHA_PRIVATE,
|
||||
$ENV{'REMOTE_ADDR'},
|
||||
$form->{'recaptcha_challenge_field'},
|
||||
$form->{'recaptcha_response_field'});
|
||||
|
||||
if (!$result->{is_valid}) {
|
||||
throwError("captcha_error", $result->{error});
|
||||
}
|
||||
}
|
||||
|
||||
# Format the parameters and send to the newsgroup.
|
||||
|
||||
# Check for compulsory parameters
|
||||
@@ -159,11 +183,11 @@ elsif ($action eq "submit") {
|
||||
my $success = $sender->send($theMsg);
|
||||
|
||||
# Give user feedback on success/failure
|
||||
throwError("cant_post") if (!$success);
|
||||
|
||||
$vars->{'headers'} = $headers;
|
||||
$vars->{'message'} = $message;
|
||||
|
||||
throwError("cant_post") if (!$success);
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
$template->process("submit-successful.html.tmpl", $vars)
|
||||
|| die("Template process failed: " . $template->error() . "\n");
|
||||
@@ -193,8 +217,9 @@ sub removeNewlinesFilter {
|
||||
}
|
||||
|
||||
sub throwError {
|
||||
my ($error) = @_;
|
||||
my ($error, $info) = @_;
|
||||
$vars->{'error'} = $error;
|
||||
$vars->{'info'} = $info || "";
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
$template->process("error.html.tmpl", $vars)
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
[% SWITCH error %]
|
||||
[% CASE "bad_parameters" %]
|
||||
<p class="error">
|
||||
You need to fill in all the required fields - name, product, summary
|
||||
and your actual feedback.
|
||||
You need to fill in all the required fields - name, product, summary,
|
||||
your actual feedback and the humanness check.
|
||||
</p>
|
||||
|
||||
<p>Please press Back and fill in the missing field(s).</p>
|
||||
@@ -50,17 +50,16 @@
|
||||
[% message FILTER html %]
|
||||
</pre>
|
||||
|
||||
[% CASE "like_spam" %]
|
||||
<p class="error">
|
||||
Sorry, your message looks like some spam we've been receiving. Please
|
||||
press Back, change the Summary to something else and try again.
|
||||
</p>
|
||||
|
||||
[% CASE "captcha_error" %]
|
||||
<p class="error">
|
||||
Sorry, you didn't correctly calculate the sum. We ask you to answer
|
||||
this question to prevent
|
||||
spammers using our form. Please press Back, check your maths and try again.
|
||||
I'm afraid you didn't pass the Humanness Check. Please don't
|
||||
take it personally, but press Back and try again.<br>
|
||||
<br>
|
||||
<small>Error info:
|
||||
<pre>
|
||||
[% info %]
|
||||
</pre>
|
||||
</small>
|
||||
</p>
|
||||
|
||||
[% CASE "rbl_hit" %]
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
# ***** END LICENSE BLOCK ***** %]
|
||||
|
||||
[% script = BLOCK %]
|
||||
var ids = ["name", "subject", "comments"];
|
||||
var ids = ["name", "subject", "comments", "recaptcha_response_field"];
|
||||
|
||||
function checkSubmitEnable() {
|
||||
/* To enable the button, all fields must have a value */
|
||||
@@ -46,9 +46,9 @@ function browserDetect() {
|
||||
var matches = [
|
||||
{ regexp: /SeaMonkey/, product: "SeaMonkey" },
|
||||
{ regexp: /Camino/, product: "Camino" },
|
||||
{ regexp: /\/3\.0[ab]\d+([^p]|$)/, product: "Gran Paradiso" },
|
||||
{ regexp: /\/3\.1[ab]\d+([^p]|$)/, product: "Shiretoko" },
|
||||
{ regexp: /Minefield/, product: "Minefield" },
|
||||
{ regexp: /GranParadiso/, product: "Gran Paradiso" },
|
||||
{ regexp: /Shiretoko/, product: "Shiretoko" },
|
||||
];
|
||||
|
||||
var defaultProduct = "[% form.product FILTER remove('"') %]";
|
||||
@@ -88,8 +88,8 @@ function onLoad() {
|
||||
onload = "onLoad()"
|
||||
%]
|
||||
|
||||
<p style="text-align: center; color: darkred">
|
||||
<b>Please accept our thanks, but do not expect a response to feedback sumitted here.</b></p>
|
||||
<p>This system is for feedback on Firefox, Thunderbird and other Mozilla
|
||||
projects.</p>
|
||||
|
||||
<fieldset>
|
||||
<legend>Other Options</legend>
|
||||
@@ -97,13 +97,14 @@ function onLoad() {
|
||||
<li><b>Need support?</b>
|
||||
<a href="http://www.mozilla.org/support/">Go here</a>
|
||||
<li><b>Broken website?</b>
|
||||
Pull down the Help menu in Firefox and select "Report Broken Web Site"
|
||||
Visit it, then select <tt>Help | Report Broken Web Site...</tt> from the browser menu
|
||||
<li><b>Specific and detailed bug report?</b>
|
||||
<a href="https://bugzilla.mozilla.org/enter_bug.cgi">Go here</a>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<br>
|
||||
<p style="text-align: center; color: darkred">
|
||||
<b>Please accept our thanks, but do not expect a response to feedback submitted here.</b></p>
|
||||
|
||||
<form id="feedback-form" method="POST">
|
||||
<table id="feedback-table">
|
||||
@@ -129,7 +130,9 @@ function onLoad() {
|
||||
<select id="product" name="product">
|
||||
[% FOREACH product = products %]
|
||||
[% NEXT IF product == "Other" %]
|
||||
<option name="[% product %]">[% product %]</option>
|
||||
<option name="[% product %]"
|
||||
[% " selected='selected'" IF product == default_product %]
|
||||
>[% product %]</option>
|
||||
[% END %]
|
||||
<option name="Other">Other (please state)</option>
|
||||
</select>
|
||||
@@ -155,11 +158,23 @@ function onLoad() {
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">
|
||||
What is 1 + 6?:
|
||||
Humanness Check:
|
||||
</td>
|
||||
<td class="widget">
|
||||
<input id="captcha" name="captcha" type="text"
|
||||
size="2" value=""/>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="http://api.recaptcha.net/challenge?k=[% recaptcha_public_key %]">
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<iframe src="http://api.recaptcha.net/noscript?k=[% recaptcha_public_key %]"
|
||||
height="300" width="500" frameborder="0"></iframe><br>
|
||||
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
|
||||
</textarea>
|
||||
<input type="hidden" name="recaptcha_response_field"
|
||||
value="manual_challenge">
|
||||
</noscript>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -36,3 +36,7 @@ Comments:
|
||||
Browser Details: [% form.useragent %]
|
||||
[% END %]
|
||||
From URL: [% referer %]
|
||||
|
||||
Note to readers: Hendrix gives no expectation of a response to this feedback
|
||||
but if you wish to provide one you must BCC (not CC) the sender for them to
|
||||
see it.
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
|
||||
<p>Thank you for your feedback, and for using our software.</p>
|
||||
|
||||
<p>Why not get involved in our community? <a href="http://quality.mozilla.org/get-involved">Help the Mozilla Project test Firefox, Thunderbird and other products</a>.
|
||||
<p>Why not get involved in our community? <a href="http://quality.mozilla.org/get-involved">Help the Mozilla Project make Firefox, Thunderbird and other products even more awesome</a>.
|
||||
|
||||
<p>Your message was:</p>
|
||||
<p>The message sent to the feedback system was:</p>
|
||||
|
||||
<pre>
|
||||
[% message FILTER html %]
|
||||
|
||||
Reference in New Issue
Block a user