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.

Bug: T147606
Change-Id: Icc7c47b88b8aa44425acfa3d58d353ddc73bc87e
This commit is contained in:
Bingxing Wang 2016-10-05 01:07:54 -07:00 committed by Florianschmidtwelzow
parent e213255ec6
commit f0932984b9

View file

@ -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 @@ class QuestyCaptcha extends SimpleCaptcha {
public function describeCaptchaType() {
return [
'type' => 'question',
'mime' => 'text/plain',
'mime' => 'text/html',
];
}
@ -88,4 +90,19 @@ class QuestyCaptcha extends SimpleCaptcha {
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;
}
}