Page MenuHomePhabricator

Support No CAPTCHA reCAPTCHA in VisualEditor
Closed, ResolvedPublic

Description

From the support desk:

ConfirmEdit Simple CAPTCHA is working fine only ReCaptchaNoCaptcha is not working with VisualEditor.
If you look at https://github.com/wikimedia/mediawiki-extensions-VisualEditor/blob/master/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
You can see
"API for different things in the UI. At this point we only support the SimpleCaptcha and FancyCaptcha"
we need find a way fix this.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 4 2018, 3:46 PM
Deskana added a subscriber: Deskana.Sep 4 2018, 6:06 PM

Is ReCaptchaNoCaptcha used in production on Wikimedia wikis?

I imagine it would violate our ToS with regards to giving away user data to a 3rd party.

I imagine it would violate our ToS with regards to giving away user data to a 3rd party.

MediaWiki should not use it by default. ConfirmEdit Module is supported by MediaWiki and that is awesome. No CAPTCHA reCAPTCHA arguably the best option to prevent spam! So why not support it unofficially if it is against ToS.

Krenair added a subscriber: Krenair.Sep 5 2018, 1:24 AM

With our limited resources we have to prioritise support for Wikimedia sites over third parties, but we welcome community patches!

With our limited resources we have to prioritise support for Wikimedia sites over third parties, but we welcome community patches!

Happy to do that. Thank you! If you can throw some relevant resources to learn how ConfirmEdit and VisualEditor communicate. i will try to fix it by writing some code. I try to figure it out myself but failed.

Thanks, the place to start would be ve.init.mw.ArticleTarget.prototype.saveErrorCaptcha in VE.

Thanks, the place to start would be ve.init.mw.ArticleTarget.prototype.saveErrorCaptcha in VE.

I was playing with that for past 2 days. I am not a pro developer. still l know most basic stuff.
so i try to replace simple captcha with nocaptch in code. but it doesn't trigger or returning any error message.

if ( captchaData.type === 'renocaptcha' || captchaData.type === 'math' ) {
			// SimpleCaptcha and MathCaptcha
			msg = 'renocaptcha-edit';
			mw.loader.load( 'ext.confirmEdit.renocaptcha' ); 
		} else if ( captchaData.type === 'question' ) {

How to trigger renocaptcha from ConfirmEdit here?

I try to look at WikiEditor. But no captcha handling like this.
If you know some other extension handling third party captcha like this i can learn from that and implement here.
also WikI Hooks plays a part here?

The captcha will only fire in certain circumstances (such as adding an external link). I imagine there are instructions on ConfirmEdit on how to do that.

Vishnunuk added a comment.EditedSep 6 2018, 11:27 AM
	if ( editApi && editApi.captcha && (
		editApi.captcha.url ||
		editApi.captcha.type === 'simple' ||
		editApi.captcha.type === 'math' ||
		editApi.captcha.type === 'recaptchanocaptcha' ||
		editApi.captcha.type === 'question' 
	) ) {
		this.saveErrorCaptcha( editApi );
		return;
	}

Modified by adding "recaptchanocaptcha" No more unknown error!
Like you said now we can work on

ve.init.mw.ArticleTarget.prototype.saveErrorCaptcha

now "recaptchanocaptcha" check works below.
		if ( captchaData.type === 'simple' || captchaData.type === 'recaptchanocaptcha' || captchaData.type === 'math' ) {
			// SimpleCaptcha and MathCaptcha
			msg = 'captcha-edit';
			 console.log( captchaData)
		} else if ( captchaData.type === 'question' ) {
			// QuestyCaptcha
			msg = 'questycaptcha-edit';
		}

but console.log( captchaData) returns the following

{type: "recaptchanocaptcha", mime: "image/png", key: "6LdXyG0UAAAAAGkPPXSdMmHKIY2o8ld4JjxgJGey", error: "recaptcha-api"}
error: "recaptcha-api"
key: "6LdXyG0UAAAAAGkPPXSdMmHKIY2o8ld4JjxgJGey"
mime: "image/png"
type: "recaptchanocaptcha"
__proto__: Object

This means captcha error.

I still unable to figure out how "getFormInformation" A confirmEdit function that returns forms elements such as captcha elements, Js etc.
How Visual Editor API/MediaWiki editor include this Captcha elements to an edit page. Simple captcha is sending the question on messages. so no issues there. but Fancy captcha use "mw.loader.load( 'ext.confirmEdit.fancyCaptcha' );"
That is an external Javascript.
By using mw.loader.load can we load "getFormInformation" one save page dialogue?

I know it is not easy to answer. but i not making any progress from here. if you can throw some lights that will be awesome :)

The scripts for recaptcha are all in HTMLReCaptchaNoCaptchaField.php, it's likely no one has tried to do this in the client before, so you can either duplicate that code, or come up with a way to expose it in the API.

Deskana triaged this task as Lowest priority.Sep 12 2018, 12:25 PM
Deskana moved this task from To Triage to Freezer on the VisualEditor board.

Change 478288 had a related patch set uploaded (by Nouman; owner: Nouman):
[mediawiki/extensions/ConfirmEdit@master] ConfirmEdit: Support No CAPTCHA reCAPTCHA

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

Change 478288 merged by jenkins-bot:
[mediawiki/extensions/ConfirmEdit@master] ConfirmEdit: Support No CAPTCHA reCAPTCHA

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

Jdforrester-WMF closed this task as Resolved.Jan 7 2019, 4:31 PM
Jdforrester-WMF assigned this task to Nouman.
Jdforrester-WMF removed a project: Patch-For-Review.
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptJan 7 2019, 4:31 PM