hCaptcha / hcaptcha-wordpress-plugin

hCaptcha.com support for Wordpress (Plugin)
GNU General Public License v2.0
80 stars 32 forks source link

Cannot use hCaptcha with forms that have file uploads such as Divi Contact Form #325

Closed angelsvirkov closed 8 months ago

angelsvirkov commented 8 months ago

Some forms such as Divi Contact Form have the possibility to upload a file with the form. While doing so, the underlying code might already send an ajax request, which would trigger the ajaxSuccess event with some arbritrary settings.data type. It looks like the JS assets at ./assets/js/1595567093/hcaptcha-divi.js define an event listener which strictly expects that the settings.data has a callable property includes. The latter is not correct in the case of the file uploads. Therefore, the hCaptcha behaviour crashes and the whole form cannot be submitted.

Steps to reproduce

Uncaught TypeError: settings.data.includes is not a function
    at HTMLDocument.<anonymous> (hcaptcha-divi.min.js?ver=3.10.1:8:19)
    at HTMLDocument.dispatch (jquery.min.js?ver=3.7.1:2:40035)

I will try to submit a PR to fix this as it looks as a minor type guarding issue. -> My attempt to solve the issue https://github.com/hCaptcha/hcaptcha-wordpress-plugin/pull/326

kagg-design commented 8 months ago

Thank you, @angelsvirkov, for the report and the PR; it is appreciated!

I do not have the Divi Contact Form Helper plugin for testing. Could you share a zip file via email to info@kagg.eu?

kagg-design commented 8 months ago

I have changed the issue name. It is not a bug but an enhancement. Our code does not support so far the premium plugin Divi Contact Form Helper.

kagg-design commented 8 months ago

@angelsvirkov, thank you for providing the plugin for testing. I have fixed the issue in this commit.

angelsvirkov commented 8 months ago

Great, thanks. Is there any roadmap or plan for the release of v4?

kagg-design commented 8 months ago

Great, thanks. Is there any roadmap or plan for the release of v4?

Yes, first days of April.