Plugin Directory

Changeset 3262905


Ignore:
Timestamp:
03/27/2025 02:29:13 PM (11 months ago)
Author:
patchstack
Message:

Changed: bumped WP tested up to version.
Fixed: potential issue with captcha on WooCommerce enabled sites.

Location:
patchstack
Files:
262 added
6 edited

Legend:

Unmodified
Added
Removed
  • patchstack/trunk/includes/login.php

    r3260796 r3262905  
    1010 */
    1111class P_Login extends P_Core {
     12
     13    /**
     14     * Validated request or not.
     15     *
     16     * @param boolean
     17     */
     18    private $validated = false;
    1219
    1320    /**
     
    3744            add_filter( 'woocommerce_process_registration_errors', [$this, 'general_captcha_check' ], 10, 1 );
    3845            add_action( 'woocommerce_before_lost_password_form', [ $this, 'add_captcha' ] );
    39             add_action( 'lostpassword_post', [ $this, 'general_captcha_check' ], 1, 1 );
    4046        }
    4147
     
    388394            add_action( 'woocommerce_lostpassword_form', [ $this->plugin->hardening, 'captcha_display' ] );
    389395            add_action( 'allow_password_reset', [ $this, 'general_captcha_check' ] );
     396
     397            // WooCommerce only.
     398            if ( class_exists( 'WooCommerce' ) ) {
     399                add_action( 'lostpassword_post', [ $this, 'general_captcha_check' ], 1, 1 );
     400            }
    390401        }
    391402    }
     
    399410     */
    400411    public function login_captcha_check( $user, $password ) {
     412        if ( $this->validated ) {
     413            return $user;
     414        }
     415
    401416        $result = $this->plugin->hardening->captcha_check();
    402417
    403418        if ( ! $result['response'] ) {
    404419            if ( $result['reason'] === 'ERROR_NO_KEYS' ) {
     420                $this->validated = true;
    405421                return $user;
    406422            }
     
    416432            }
    417433        } else {
     434            $this->validated = true;
    418435            return $user;
    419436        }
     
    428445     */
    429446    public function login_captcha_check_woocommerce( $error, $username, $password, $email ) {
     447        if ( $this->validated ) {
     448            return $error;
     449        }
     450
    430451        $result = $this->plugin->hardening->captcha_check();
    431452
    432453        if ( $result['response'] || $result['reason'] == 'ERROR_NO_KEYS' ) {
     454            $this->validated = true;
    433455            return $error;
    434456        }
     
    449471     */
    450472    public function general_captcha_check( $error ) {
     473        if ( $this->validated ) {
     474            return $error;
     475        }
     476
    451477        $result = $this->plugin->hardening->captcha_check();
    452478
    453479        if ( $result['response'] || $result['reason'] == 'ERROR_NO_KEYS' ) {
     480            $this->validated = true;
    454481            return $error;
    455482        }
  • patchstack/trunk/includes/views/captcha_invisible.php

    r3114829 r3262905  
    44    exit;
    55}
     6
     7$id = 'g-recaptcha-response-' . uniqid();
     8
    69?>
    710<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback" async defer></script>
     
    1215   
    1316    function setResponse(response) {
    14         document.getElementById("captcha-response").value = response;
     17        document.getElementById("<?php echo $id; ?>").value = response;
    1518    }
    1619</script>
    1720<div class="g-recaptcha" data-sitekey="<?php echo esc_attr( $site_key ); ?>" data-size="invisible" data-callback="setResponse"></div>
    18 <input type="hidden" id="captcha-response" name="captcha-response" />
     21<input type="hidden" id="<?php echo $id; ?>" name="captcha-response" />
  • patchstack/trunk/includes/views/captcha_turnstile.php

    r3114829 r3262905  
    44    exit;
    55}
     6
     7$id = 'g-recaptcha-response-' . uniqid();
     8
    69?>
    710<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?compat=recaptcha" async defer></script>
     
    1215   
    1316    function setResponse(response) {
    14         document.getElementById("captcha-response").value = response;
     17        document.getElementById("<?php echo $id; ?>").value = response;
    1518    }
    16    
    1719</script>
    1820<div class="g-recaptcha" style="text-align: center; margin-bottom: 8px;" data-sitekey="<?php echo esc_attr( $site_key ); ?>" data-size="compact" data-callback="setResponse"></div>
    19 <input type="hidden" id="captcha-response" name="captcha-response" />
     21<input type="hidden" id="<?php echo $id; ?>" name="captcha-response" />
  • patchstack/trunk/includes/views/captcha_v3.php

    r2622691 r3262905  
    44    exit;
    55}
     6
     7$id = 'g-recaptcha-response-' . uniqid();
     8
    69?>
    710<script id="gRecaptchaSrc" src="https://www.google.com/recaptcha/api.js?render=<?php echo esc_attr( $site_key ); ?>"></script>
     
    912    grecaptcha.ready(function() {
    1013        grecaptcha.execute('<?php echo esc_attr( $site_key ); ?>', {action: 'submit'}).then(function(token) {
    11             document.getElementById("g-recaptcha-response").value = token;
     14            document.getElementById("<?php echo $id; ?>").value = token;
    1215        });
    1316    });
    1417</script>
    15 <input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" />
     18<input type="hidden" id="<?php echo $id; ?>" name="g-recaptcha-response" />
  • patchstack/trunk/patchstack.php

    r3260796 r3262905  
    55 * Author URI: https://patchstack.com/?utm_medium=wp&utm_source=dashboard&utm_campaign=patchstack%20plugin
    66 * Description: Patchstack identifies security vulnerabilities in WordPress plugins, themes, and core.
    7  * Version: 2.3.1
     7 * Version: 2.3.2
    88 * Author: Patchstack
    99 * License: GPLv3
     
    6060         * @var string
    6161         */
    62         const VERSION = '2.3.1';
     62        const VERSION = '2.3.2';
    6363
    6464        /**
  • patchstack/trunk/readme.txt

    r3260796 r3262905  
    55License URI: https://www.gnu.org/licenses/gpl-3.0.html
    66Requires at least: 4.4
    7 Tested up to: 6.6
    8 Stable tag: 2.3.1
     7Tested up to: 6.7
     8Stable tag: 2.3.2
    99Requires PHP: 5.6
    1010
Note: See TracChangeset for help on using the changeset viewer.