getgrav / grav-plugin-form

Grav Form Plugin
http://getgrav.org
MIT License
53 stars 79 forks source link

reCaptcha v3 not working when action var length is too long #571

Closed klawuy closed 2 years ago

klawuy commented 2 years ago

Hi !

I added a form with a reCaptcha v3 in a modular page.

Path to the modular page is /user/pages/04.amenager-entreprendre/01.developpement-economique/03.dispositifs-accompagnement/01.les-subventions/07._formulaire-contact

When I submit this form, it give me the following error: Invalid action name, may only include "A-Za-z/_". Do not include user-specific information.

The problem is in the file /user/plugins/form/templates/form/fields/captcha/captcha.html.twig , when I console.log the action variable send to Google, it answer :

amenager_et_entreprendre_developpement_economique_dispositifs_accompagnement_les_subventions_formulaire_contact_contact_subventions

So, it's in the standard required by Google but I think the length of action variable is too long, so Google return an error.

Thanks for your help.

klawuy commented 2 years ago

I replaced the line 5 in this file : https://github.com/getgrav/grav-plugin-form/blob/2b6bb888261aeb14780de2f9db12068ab7bb0cea/templates/forms/fields/captcha/captcha.html.twig#L5

By {% set action = (page.route|trim('/') ~ '-' ~ form.name)|underscorize|md5 %}

The md5 twig filter correct the problem.

rhukster commented 2 years ago

interesting, never ran into that, but probably never had a form so deeply nested. A PR with the fix would be appreciated. Thanks!