Skip to content

Commit 9dec9c6

Browse files
authored
Don't call siteverify when Captcha solution is empty (#135)
* don't call siteverify when solution is empty * prepare 1.15.1
1 parent 7f4abd6 commit 9dec9c6

File tree

12 files changed

+61
-39
lines changed

12 files changed

+61
-39
lines changed

friendly-captcha/friendly-captcha.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Plugin Name: Friendly Captcha for WordPress
55
* Description: Protect WordPress website forms from spam and abuse with Friendly Captcha, a privacy-first anti-bot solution.
6-
* Version: 1.15.0
6+
* Version: 1.15.1
77
* Requires at least: 5.0
88
* Requires PHP: 7.3
99
* Author: Friendly Captcha GmbH
@@ -19,7 +19,7 @@
1919
die;
2020
}
2121

22-
define('FRIENDLY_CAPTCHA_VERSION', '1.15.0');
22+
define('FRIENDLY_CAPTCHA_VERSION', '1.15.1');
2323
define('FRIENDLY_CAPTCHA_FRIENDLY_CHALLENGE_VERSION', '0.9.12');
2424
define('FRIENDLY_CAPTCHA_FRIENDLY_CAPTCHA_SDK_VERSION', '0.1.7');
2525
define('FRIENDLY_CAPTCHA_SUPPORTED_LANGUAGES', [

friendly-captcha/includes/core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FriendlyCaptcha_Plugin
3131
public static $option_global_puzzle_endpoint_active_name = "frcaptcha_global_endpoint_active";
3232
public static $option_eu_puzzle_endpoint_active_name = "frcaptcha_eu_endpoint_active";
3333

34-
public static $option_verification_failed_alert_name = "frcaptcha_verification_failed_alert";
34+
public static $option_verification_failed_alert_name = "frcaptcha_verification_failed_alert_v2";
3535

3636
public static $integrations = array(
3737
array(
Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,105 @@
11
<?php
22

3-
class frcaptcha_divi_core_addon extends ET_Core_API_Spam_Provider {
4-
public $name = 'FriendlyCaptcha';
3+
class frcaptcha_divi_core_addon extends ET_Core_API_Spam_Provider
4+
{
5+
public $name = 'FriendlyCaptcha';
56

67
/**
7-
* @inheritDoc
8-
*/
9-
public $slug = 'frcaptcha';
8+
* @inheritDoc
9+
*/
10+
public $slug = 'frcaptcha';
1011

11-
public $custom_fields = null; // avoid notice from \ET_Core_API_Email_Providers::_initialize which expects this field
12+
public $custom_fields = null; // avoid notice from \ET_Core_API_Email_Providers::_initialize which expects this field
1213

13-
public function __construct( $owner = 'frcaptcha', $account_name = '', $api_key = '' ) {
14-
parent::__construct( $owner, $account_name, $api_key );
14+
public function __construct($owner = 'frcaptcha', $account_name = '', $api_key = '')
15+
{
16+
parent::__construct($owner, $account_name, $api_key);
1517

16-
$this->_add_actions_and_filters();
17-
}
18+
$this->_add_actions_and_filters();
19+
}
1820

19-
protected function _add_actions_and_filters() {
20-
if ( ! is_admin() && ! et_core_is_fb_enabled() ) {
21-
add_action( 'wp_enqueue_scripts', array( $this, 'action_wp_enqueue_scripts' ) );
22-
}
23-
}
21+
protected function _add_actions_and_filters()
22+
{
23+
if (!is_admin() && !et_core_is_fb_enabled()) {
24+
add_action('wp_enqueue_scripts', array($this, 'action_wp_enqueue_scripts'));
25+
}
26+
}
2427

25-
public function action_wp_enqueue_scripts() {
28+
public function action_wp_enqueue_scripts()
29+
{
2630
$plugin = FriendlyCaptcha_Plugin::$instance;
2731

28-
if ( !$plugin->is_configured() ) {
32+
if (!$plugin->is_configured()) {
2933
return;
3034
}
3135

32-
if ( ! $this->is_enabled() ) {
33-
return;
34-
}
36+
if (!$this->is_enabled()) {
37+
return;
38+
}
3539

3640
frcaptcha_enqueue_widget_scripts(true);
3741

3842
wp_dequeue_script('et-core-api-spam-recaptcha');
39-
}
43+
}
4044

41-
public function is_enabled() {
45+
public function is_enabled()
46+
{
4247
$has_frcaptcha_module = true;
4348

44-
if ( class_exists( 'ET_Dynamic_Assets' ) ) {
49+
if (class_exists('ET_Dynamic_Assets')) {
4550
$et_dynamic_module_framework = et_builder_dynamic_module_framework();
4651
$is_dynamic_framework_enabled = et_builder_is_frontend() && 'on' === $et_dynamic_module_framework;
4752
$is_dynamic_css_enabled = et_builder_is_frontend() && et_use_dynamic_css();
4853

49-
if ( $is_dynamic_framework_enabled && $is_dynamic_css_enabled ) {
54+
if ($is_dynamic_framework_enabled && $is_dynamic_css_enabled) {
5055
$et_dynamic_assets = ET_Dynamic_Assets::init();
5156
$saved_shortcodes = $et_dynamic_assets->get_saved_page_shortcodes();
52-
$frcaptcha_modules = array( 'et_pb_contact_form', 'et_pb_signup' );
53-
$has_frcaptcha_module = ! empty( array_intersect( $saved_shortcodes, $frcaptcha_modules ) );
57+
$frcaptcha_modules = array('et_pb_contact_form', 'et_pb_signup');
58+
$has_frcaptcha_module = !empty(array_intersect($saved_shortcodes, $frcaptcha_modules));
5459
}
5560
}
5661

5762
return $has_frcaptcha_module;
5863
}
5964

60-
public function verify_form_submission() {
65+
public function verify_form_submission()
66+
{
6167
$plugin = FriendlyCaptcha_Plugin::$instance;
6268

63-
if ( !$plugin->is_configured() ) {
69+
if (!$plugin->is_configured()) {
6470
return array(
6571
'success' => true,
6672
'score' => 100000,
6773
);
6874
}
6975

70-
if ( ! $this->is_enabled() ) {
76+
if (!$this->is_enabled()) {
7177
return array(
7278
'success' => true,
7379
'score' => 100000,
7480
);
7581
}
7682

77-
$solution = et_()->array_get_sanitized( $_POST, 'token' );
83+
$solution = et_()->array_get_sanitized($_POST, 'token');
84+
if (empty($solution)) {
85+
return 'Captcha missing';
86+
}
7887

7988
$plugin = FriendlyCaptcha_Plugin::$instance;
8089
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());
8190

82-
if ( $verification["success"] ) {
91+
if ($verification["success"]) {
8392
return array(
8493
'success' => true,
8594
'score' => 100000,
8695
);
8796
} else {
8897
return 'Captcha error';
8998
}
90-
}
99+
}
91100

92-
public function get_account_fields() {
93-
return array();
94-
}
101+
public function get_account_fields()
102+
{
103+
return array();
104+
}
95105
}

friendly-captcha/modules/formidable/FrcaptchaFieldNewType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function validate($args)
8686

8787
if (empty($solution)) {
8888
$errors['field' . $args['id']] = $errorPrefix . FriendlyCaptcha_Plugin::default_error_user_message();
89+
return $errors;
8990
}
9091

9192
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/profile-builder/profile_builder_login.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function frcaptcha_pb_login_validate($user)
3131
$user = new WP_Error('wpbb_recaptcha_error', FriendlyCaptcha_Plugin::default_error_user_message() . __(' (captcha missing)', 'frcaptcha'));
3232
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
3333
remove_filter('authenticate', 'wp_authenticate_email_password', 20, 3);
34+
return;
3435
}
3536

3637
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/profile-builder/profile_builder_register.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function frcaptcha_pb_register_validate($output_field_errors, $form_fields, $glo
3131
// We need to use a field id in the array. Because we don't have such id we just use a high number that will never be used by the plugin itself.
3232
if (empty($solution)) {
3333
$output_field_errors[100] = '<span class="wppb-form-error">' . FriendlyCaptcha_Plugin::default_error_user_message() . __(' (captcha missing)', 'frcaptcha') . '</span>';
34+
return;
3435
}
3536

3637
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/profile-builder/profile_builder_reset_password.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function frcaptcha_pb_reset_password_sent_message($message)
2828

2929
if (empty($solution)) {
3030
$message = 'wppb_recaptcha_error';
31+
return $message;
3132
}
3233

3334
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/woocommerce/woocommerce_checkout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function frcaptcha_wc_checkout_validate()
3737
if (empty($solution)) {
3838
$error_message = $errorPrefix . FriendlyCaptcha_Plugin::default_error_user_message() . __(' (captcha missing)', 'frcaptcha');
3939
wc_add_notice($error_message, 'error');
40+
return;
4041
}
4142

4243
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/woocommerce/woocommerce_login.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function frcaptcha_wc_login_validate($validation_error)
4141
if (empty($solution)) {
4242
$error_message = $errorPrefix . FriendlyCaptcha_Plugin::default_error_user_message() . __(' (captcha missing)', 'frcaptcha');
4343
$validation_error->add('frcaptcha-empty-error', $error_message);
44+
return $validation_error;
4445
}
4546

4647
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

friendly-captcha/modules/woocommerce/woocommerce_register.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function frcaptcha_wc_register_validate($validation_error)
3737
if (empty($solution)) {
3838
$error_message = $errorPrefix . FriendlyCaptcha_Plugin::default_error_user_message() . __(' (captcha missing)', 'frcaptcha');
3939
$validation_error->add('frcaptcha-empty-error', $error_message);
40+
return $validation_error;
4041
}
4142

4243
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key());

0 commit comments

Comments
 (0)