Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Honeypot Field Plugin to the Captcha Options #19286

Closed
wants to merge 5 commits into from
Closed

Adding a Honeypot Field Plugin to the Captcha Options #19286

wants to merge 5 commits into from

Conversation

coolcat-creations
Copy link
Contributor

@coolcat-creations coolcat-creations commented Jan 4, 2018

Summary of Changes

Altough Honeypot is not really a "captcha" functionality I think it fits best in the captcha plugin group. This plugin creates a hidden field named "repeatmail". The field name can be changed by the user. If repeatmail is filled, the form can't be sent.

Testing Instructions

Enable the Honeypot in the Captcha Options in your main configuration.

  • Use the Contactform and send a mail -> everything should work as before
  • Use element inspector to disable the StyleDeclaration that hides the field and fill the field, try to send the form, an error should appear.

Documentation Changes Required

Yes, as it's a new feature

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-staging labels Jan 4, 2018
@brianteeman
Copy link
Contributor

Personally I dont see the need to add this to the core

@coolcat-creations
Copy link
Contributor Author

Google Captcha v1 and v2 are outdated and the new "invisible recaptcha" creates a always visible google flag. I think a honeypot solution is much more userfriendly and does not display large flags like this in the page corner:
grafik

*
* @return string The HTML to be embedded in the form.
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPLOY_VERSION

*
* @return True if the answer is correct, false otherwise
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPLOY_VERSION

<fieldset name="basic">

<field
name="fieldname"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one tab too many here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name, type, label description

@@ -24,7 +24,7 @@ class PlgCaptchaHoneypot extends JPlugin
*
* @return string The HTML to be embedded in the form.
*
* @since 2.5
* @since 3.9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry you misunderstood me - this should not be a version number but the string _DEPLOY_VERSION_

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

description="PLG_CAPTCHA_HONEYPOT_FIELDNAME_DESC"
type="text"
default="repeatmail"
name="fieldname"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you missed the second comment about the ordering - it should be
name, type, label, description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

*
* @return True if the answer is correct, false otherwise
*
* @since _DEPLOY_VERSION_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 underscores __DEPLOY_VERSION__

*
* @return string The HTML to be embedded in the form.
*
* @since _DEPLOY_VERSION_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 underscores __DEPLOY_VERSION__

}

return true;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

/**
* Verifies if the honeypot field is empty
*
* @param string $code Answer provided by user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to $response

public function onDisplay()
{
$doc = JFactory::getDocument();
/* $doc->addStyleDeclaration('body label[for="' . $this->params->get("fieldname") . '"], body label[for="jform_captcha"], body label[for="jform_captcha"] + span.optional, body #' . $this->params->get("fieldname") . ' {display: none; visibility: hidden; }');*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment

{
$doc = JFactory::getDocument();
/* $doc->addStyleDeclaration('body label[for="' . $this->params->get("fieldname") . '"], body label[for="jform_captcha"], body label[for="jform_captcha"] + span.optional, body #' . $this->params->get("fieldname") . ' {display: none; visibility: hidden; }');*/
return '<input id="' . $this->params->get("fieldname") . '" name="' . $this->params->get("fieldname") . '" size="40" type="text" autocomplete="false" autofill="off" />';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line above

return true;

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line


class PlgCaptchaHoneypot extends JPlugin
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

@brianteeman
Copy link
Contributor

Why do you allow the field name to be changed? Remember that as the field is only hidden from sighted users so in order for this to work as intended the fieldname must be something that a user of assistive technology would not think they need to complete,

public function onDisplay()
{
$doc = JFactory::getDocument();
/* $doc->addStyleDeclaration('body label[for="' . $this->params->get("fieldname") . '"], body label[for="jform_captcha"], body label[for="jform_captcha"] + span.optional, body #' . $this->params->get("fieldname") . ' {display: none; visibility: hidden; }');*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove body from the scope in the CSS

@coolcat-creations
Copy link
Contributor Author

@C-Lodder the body scope was on purpose to enforce hiding the label without using an important. I mean when any 3rd Party Template would have a style for that. What do you think, should I really remove the scope?

@coolcat-creations
Copy link
Contributor Author

@brianteeman thought i would keep it flexible when allowing to change the fieldname so if someone woukd have a repeatmail field for real the conflict could be resolved. How to tell screenreaders that this field is not important i will investigate.

@brianteeman
Copy link
Contributor

. How to tell screenreaders that this field is not important i will investigate.

As far as I am aware that is not possible

@coolcat-creations
Copy link
Contributor Author

I got some more feedback outside this PR and want to put it on hold for a few weeks until I have the time to implement all suggestions. Thanks for reviewing to everyone.

@coolcat-creations
Copy link
Contributor Author

I searched for different possibilities to make the Honeypot - really - accessible but i did not found a method. I think we need something in core that is Google-Independant - but i have no idea what. Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants