Ben.imbushuo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/314236

Change subject: Fixing unexcepted HTML escaping in QuestyCaptcha.
......................................................................

Fixing unexcepted HTML escaping in QuestyCaptcha.

HTML-based questions (e.g. images) will not work well with QuestyCaptcha
on MediaWiki 1.27 due to an unexcepted HTML escape. This commit fixes the
issue by declaring raw HTML form mode, just like MathCaptcha.

Change-Id: Icc7c47b88b8aa44425acfa3d58d353ddc73bc87e
---
M QuestyCaptcha/QuestyCaptcha.class.php
1 file changed, 18 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit 
refs/changes/36/314236/1

diff --git a/QuestyCaptcha/QuestyCaptcha.class.php 
b/QuestyCaptcha/QuestyCaptcha.class.php
index dfe9fd6..14124df 100644
--- a/QuestyCaptcha/QuestyCaptcha.class.php
+++ b/QuestyCaptcha/QuestyCaptcha.class.php
@@ -8,6 +8,8 @@
  * @ingroup Extensions
  */
 
+use MediaWiki\Auth\AuthenticationRequest;
+
 class QuestyCaptcha extends SimpleCaptcha {
        // used for questycaptcha-edit, questycaptcha-addurl, 
questycaptcha-badlogin,
        // questycaptcha-createaccount, questycaptcha-create, 
questycaptcha-sendemail via getMessage()
@@ -33,7 +35,7 @@
        public function describeCaptchaType() {
                return [
                        'type' => 'question',
-                       'mime' => 'text/plain',
+                       'mime' => 'text/html',
                ];
        }
 
@@ -88,4 +90,19 @@
        public function getCaptchaInfo( $captchaData, $id ) {
                return $captchaData['question'];
        }
+
+       public function onAuthChangeFormFields( array $requests, array 
$fieldInfo,
+               array &$formDescriptor, $action ) {
+               /** @var CaptchaAuthenticationRequest $req */
+               $req =
+                       AuthenticationRequest::getRequestByClass( $requests,
+                               CaptchaAuthenticationRequest::class, true );
+               if ( !$req ) {
+                       return;
+               }
+
+               // declare RAW HTML output.
+               $formDescriptor['captchaInfo']['raw'] = true;
+               $formDescriptor['captchaWord']['label-message'] = null;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/314236
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc7c47b88b8aa44425acfa3d58d353ddc73bc87e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmEdit
Gerrit-Branch: master
Gerrit-Owner: Ben.imbushuo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to