diff --git a/ChangeLog b/ChangeLog index dd26c3f7..3c92156e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-11-27 Brian Curry + + * modules/recaptcha.pl (ReCaptchaQuestionAddTo): Patched with a + Wiki-provided correction, courtesy Bayle Shanks. Apparently, the + previous regular expression in this function failed to match the + Comment form's HTML. This patch corrects that! The reCAPTCHA widget + is now properly displayed by both the Comment and Edit forms. + Thanks, Bayle. (http://bayleshanks.com) + 2008-11-25 Brian Curry * modules/forms.pl (FormsRule): Removed Sidebar-specific hack. diff --git a/modules/recaptcha.pl b/modules/recaptcha.pl index 74d87741..87a8653e 100644 --- a/modules/recaptcha.pl +++ b/modules/recaptcha.pl @@ -26,7 +26,7 @@ recaptcha is simply installable; simply: =cut package OddMuse; -$ModulesDescription .= '

$Id: recaptcha.pl,v 1.5 2008/09/29 11:53:33 leycec Exp $

'; +$ModulesDescription .= '

$Id: recaptcha.pl,v 1.6 2008/11/27 06:00:25 leycec Exp $

'; # ....................{ CONFIGURATION }.................... @@ -133,6 +133,7 @@ $ReCaptchaSecretKey = 'question'; 'edit text' => 1 ); +# ....................{ INITIALIZATION }.................... push(@MyInitVariables, \&ReCaptchaInit); sub ReCaptchaInit { @@ -142,6 +143,76 @@ sub ReCaptchaInit { $InvisibleCookieParameters{$ReCaptchaSecretKey} = 1; } +# ....................{ EDITING }.................... +*OldReCaptchaGetEditForm = *GetEditForm; +*GetEditForm = *NewReCaptchaGetEditForm; + +*OldReCaptchaGetCommentForm = *GetCommentForm; +*GetCommentForm = *NewReCaptchaGetCommentForm; + +sub NewReCaptchaGetEditForm { + return ReCaptchaQuestionAddTo(OldReCaptchaGetEditForm(@_)); +} + +sub NewReCaptchaGetCommentForm { + return ReCaptchaQuestionAddTo(OldReCaptchaGetCommentForm(@_)); +} + +sub ReCaptchaQuestionAddTo { + my $form = shift; + + if (not $upload + and not ReCaptchaException(GetId()) + and not $ReCaptchaRememberAnswer && GetParam($ReCaptchaSecretKey, 0) + and not UserIsEditor()) { + $form =~ + s/(\Q

new()->get_html( + $ReCaptchaPublicKey, undef, $ENV{'HTTPS'} eq 'on', undef); + my $submit_html = $need_button ? $q->submit(-value=> T('Go!')) : ''; + my $options_html = ' +'; + + return $options_html.ReCaptchaGetQuestionHtml($captcha_html.$submit_html); +} + +=head2 ReCaptchaGetQuestionHtml + +Enclose the reCAPTCHA iframe in Oddmuse-specific HTML and CSS. + +Wiki administrators are encouraged to replace this function with their own, +Wiki-specific function by redefining this function in B. + +=cut +sub ReCaptchaGetQuestionHtml { + my $question_html = shift; + return $q->div({-class=> 'question'}, $ReCaptchaTheme eq 'clean' + ? $q->p(T('Please type the following two words:')).$question_html + : $q->p(T('Please answer this captcha:' )).$question_html); +} + +# ....................{ POSTING }.................... *OldReCaptchaDoPost = *DoPost; *DoPost = *NewReCaptchaDoPost; @@ -176,78 +247,6 @@ sub NewReCaptchaDoPost { return (OldReCaptchaDoPost(@params)); } -*OldReCaptchaGetEditForm = *GetEditForm; -*GetEditForm = *NewReCaptchaGetEditForm; - -sub NewReCaptchaGetEditForm { - return ReCaptchaQuestionAddTo(OldReCaptchaGetEditForm(@_)); -} - -*OldReCaptchaGetCommentForm = *GetCommentForm; -*GetCommentForm = *NewReCaptchaGetCommentForm; - -sub NewReCaptchaGetCommentForm { - return ReCaptchaQuestionAddTo(OldReCaptchaGetCommentForm(@_)); -} - -sub ReCaptchaQuestionAddTo { - my $form = shift; - if (not $upload - and not ReCaptchaException(GetId()) - and not $ReCaptchaRememberAnswer && GetParam($ReCaptchaSecretKey, 0) - and not UserIsEditor()) { - $form =~ s/(\Q