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

Update API URLs #2

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/php/Avada/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function verify( $demo_mode ) {
[];

$form_data = wp_parse_args( str_replace( '&', '&', $form_data ) );
$procaptcha_response = $form_data['pro-captcha-response'] ?? '';
$procaptcha_response = $form_data['procaptcha-response'] ?? '';
$_POST['procaptcha-widget-id'] = $form_data['procaptcha-widget-id'] ?? '';
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Missing

Expand Down
2 changes: 1 addition & 1 deletion src/php/BackInStockNotifier/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function after_submit_button( int $product_id, int $variation_id ) {
*/
public function verify( array $post_data, bool $rest_api ) {

$procaptcha_response = $post_data['pro-captcha-response'] ?? '';
$procaptcha_response = $post_data['procaptcha-response'] ?? '';

$result = procaptcha_request_verify( $procaptcha_response );

Expand Down
2 changes: 1 addition & 1 deletion src/php/Brizy/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function verify( $form ) {
continue;
}

if ( 'g-recaptcha-response' === $item['name'] || 'pro-captcha-response' === $item['name'] ) {
if ( 'g-recaptcha-response' === $item['name'] || 'procaptcha-response' === $item['name'] ) {
$procaptcha_response = $item['value'];
}

Expand Down
4 changes: 2 additions & 2 deletions src/php/ElementorPro/PCaptchaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ public function validation( Form_Record $record, Ajax_Handler $ajax_handler ) {
$field = current( $fields );

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';
// phpcs:enable WordPress.Security.NonceVerification.Missing

Expand Down
9 changes: 4 additions & 5 deletions src/php/FluentForm/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ public function add_captcha( array $submit_button, stdClass $form ) {
public function verify( array $errors, array $data, FluentForm $form, array $fields ): array {
remove_filter( 'pre_http_request', [ $this, 'pre_http_request' ] );

$procaptcha_response = $data['pro-captcha-response'] ?? '';
$procaptcha_response = $data['procaptcha-response'] ?? '';
$_POST['procaptcha-widget-id'] = $data['procaptcha-widget-id'] ?? '';
$error_message = procaptcha_request_verify( $procaptcha_response );

if ( null !== $error_message ) {
$errors['pro-captcha-response'] = [ $error_message ];
$errors['procaptcha-response'] = [ $error_message ];
}

return $errors;
Expand Down Expand Up @@ -315,8 +315,7 @@ public function fluentform_has_procaptcha(): bool {
*/
public function pre_http_request( $response, array $parsed_args, string $url ) {
$api_urls = [
'https://api.procaptcha.com/siteverify',
'https://procaptcha.com/siteverify',
'https://api.procaptcha.io/siteverify',
];

if ( ! in_array( $url, $api_urls, true ) ) {
Expand Down Expand Up @@ -379,7 +378,7 @@ private function get_procaptcha_wrapped(): string {
?>
<div class="ff-el-group">
<div class="ff-el-input--content">
<div data-fluent_id="1" name="pro-captcha-response">
<div data-fluent_id="1" name="procaptcha-response">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->get_captcha();
Expand Down
6 changes: 3 additions & 3 deletions src/php/Kadence/AdvancedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public function process_ajax() {
// Nonce is checked by Kadence.

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$error = procaptcha_request_verify( $procaptcha_response );
Expand All @@ -134,7 +134,7 @@ public function process_ajax() {
return;
}

unset( $_POST['pro-captcha-response'], $_POST['g-recaptcha-response'] );
unset( $_POST['procaptcha-response'], $_POST['g-recaptcha-response'] );
// phpcs:enable WordPress.Security.NonceVerification.Missing

$data = [
Expand Down
6 changes: 3 additions & 3 deletions src/php/Kadence/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public function process_ajax() {
// Nonce is checked by Kadence.

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$error = procaptcha_request_verify( $procaptcha_response );
Expand All @@ -107,7 +107,7 @@ public function process_ajax() {
return;
}

unset( $_POST['pro-captcha-response'], $_POST['g-recaptcha-response'] );
unset( $_POST['procaptcha-response'], $_POST['g-recaptcha-response'] );
// phpcs:enable WordPress.Security.NonceVerification.Missing

$data = [
Expand Down
8 changes: 4 additions & 4 deletions src/php/Settings/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ static function ( $secret_key ) use ( $ajax_secret_key ) {
'swa' => 1,
'spst' => 0,
];
$url = add_query_arg( $params, 'https://procaptcha.com/checksiteconfig' );
$url = add_query_arg( $params, 'https://api.prosopo.io/checksiteconfig' );

$raw_response = wp_remote_post( $url );

$raw_body = wp_remote_retrieve_body( $raw_response );

if ( empty( $raw_body ) ) {
$this->send_check_config_error( __( 'Cannot communicate with proCAPTCHA server.', 'procaptcha-for-forms-and-more' ) );
$this->send_check_config_error( __( 'Cannot communicate with Prosopo server.', 'procaptcha-for-forms-and-more' ) );
}

$body = json_decode( $raw_body, true );
Expand All @@ -624,8 +624,8 @@ static function ( $secret_key ) use ( $ajax_secret_key ) {
$this->send_check_config_error( $error );
}

$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$result = procaptcha_request_verify( $procaptcha_response );
Expand Down
4 changes: 2 additions & 2 deletions src/php/SimpleDownloadMonitor/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function verify() {
}

// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
$_POST['pro-captcha-response'] = $_GET['pro-captcha-response'] ?? '';
$_POST['procaptcha-response'] = $_GET['procaptcha-response'] ?? '';
$_POST[ self::NONCE ] = $_GET[ self::NONCE ] ?? '';
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash

$error_message = procaptcha_verify_post( self::NONCE, self::ACTION );

unset( $_POST['pro-captcha-response'], $_POST[ self::NONCE ] );
unset( $_POST['procaptcha-response'], $_POST[ self::NONCE ] );

if ( null === $error_message ) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/php/WPDiscuz/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public function verify( $comment_data ) {
// Nonce is checked by wpDiscuz.

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$result = procaptcha_request_verify( $procaptcha_response );
Expand All @@ -89,7 +89,7 @@ public function verify( $comment_data ) {
return $comment_data;
}

unset( $_POST['pro-captcha-response'], $_POST['g-recaptcha-response'] );
unset( $_POST['procaptcha-response'], $_POST['g-recaptcha-response'] );
// phpcs:enable WordPress.Security.NonceVerification.Missing

wp_die( esc_html( $result ) );
Expand Down
6 changes: 3 additions & 3 deletions src/php/WPDiscuz/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function verify() {
// Nonce is checked by wpDiscuz.

// phpcs:disable WordPress.Security.NonceVerification.Missing
$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$result = procaptcha_request_verify( $procaptcha_response );

unset( $_POST['pro-captcha-response'], $_POST['g-recaptcha-response'] );
unset( $_POST['procaptcha-response'], $_POST['g-recaptcha-response'] );
// phpcs:enable WordPress.Security.NonceVerification.Missing

if ( null === $result ) {
Expand Down
4 changes: 2 additions & 2 deletions src/php/includes/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ function procaptcha_request_verify( $procaptcha_response ) {
*/
function procaptcha_verify_post( string $nonce_field_name = PROCAPTCHA_NONCE, string $nonce_action_name = PROCAPTCHA_ACTION ) {

$procaptcha_response = isset( $_POST['pro-captcha-response'] ) ?
filter_var( wp_unslash( $_POST['pro-captcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
$procaptcha_response = isset( $_POST['procaptcha-response'] ) ?
filter_var( wp_unslash( $_POST['procaptcha-response'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) :
'';

$procaptcha_nonce = isset( $_POST[ $nonce_field_name ] ) ?
Expand Down