From 1eb0400ff719c5eecd3ec0cc7980c0f4a8d8d06e Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Tue, 8 Sep 2026 12:08:51 -0400 Subject: [PATCH 1/4] Jetpack: validate site verification codes --- ...sgcom-534-validate-site-verification-codes | 4 ++ ....wpcom-json-api-site-settings-endpoint.php | 15 +++++ .../blog-verification-tools.php | 47 ++++++++------ .../verification-tools-utils.php | 41 +++++++++++- ...N_API_Site_Settings_V1_4_Endpoint_Test.php | 38 +++++++++++ .../Jetpack_Verification_Tools_Utils_Test.php | 63 +++++++++++++++++++ 6 files changed, 187 insertions(+), 21 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/dsgcom-534-validate-site-verification-codes diff --git a/projects/plugins/jetpack/changelog/dsgcom-534-validate-site-verification-codes b/projects/plugins/jetpack/changelog/dsgcom-534-validate-site-verification-codes new file mode 100644 index 000000000000..4d82de2c40a9 --- /dev/null +++ b/projects/plugins/jetpack/changelog/dsgcom-534-validate-site-verification-codes @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Site Verification: Reject invalid verification codes instead of reporting a successful save. diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php index 1b1b96fa48d4..3baa66f91089 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php @@ -1235,6 +1235,21 @@ function ( &$value ) { case 'verification_services_codes': $verification_codes = jetpack_verification_validate( $value ); + foreach ( $value as $service_key => $raw_code ) { + if ( '' === $raw_code || null === $raw_code ) { + continue; + } + + $validated_code = isset( $verification_codes[ $service_key ] ) ? $verification_codes[ $service_key ] : ''; + if ( '' === $validated_code ) { + return new WP_Error( + 'invalid_input', + __( 'Invalid site verification code. Enter only the content value from the meta tag.', 'jetpack' ), + 400 + ); + } + } + if ( update_option( 'verification_services_codes', $verification_codes ) ) { $updated[ $key ] = $verification_codes; } diff --git a/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php b/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php index a80bad752773..4913674e120c 100644 --- a/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php +++ b/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php @@ -16,36 +16,43 @@ * @return array - an array of supported services. */ function jetpack_verification_services() { + $patterns = jetpack_verification_service_patterns(); + return array( 'google' => array( - 'name' => 'Google Search Console', - 'key' => 'google-site-verification', - 'format' => 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8', - 'url' => 'https://www.google.com/webmasters/tools/', + 'name' => 'Google Search Console', + 'key' => 'google-site-verification', + 'format' => 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8', + 'url' => 'https://www.google.com/webmasters/tools/', + 'pattern' => $patterns['google'], ), 'bing' => array( - 'name' => 'Bing Webmaster Center', - 'key' => 'msvalidate.01', - 'format' => '12C1203B5086AECE94EB3A3D9830B2E', - 'url' => 'https://www.bing.com/toolbox/webmaster/', + 'name' => 'Bing Webmaster Center', + 'key' => 'msvalidate.01', + 'format' => '12C1203B5086AECE94EB3A3D9830B2E', + 'url' => 'https://www.bing.com/toolbox/webmaster/', + 'pattern' => $patterns['bing'], ), 'pinterest' => array( - 'name' => 'Pinterest Site Verification', - 'key' => 'p:domain_verify', - 'format' => 'f100679e6048d45e4a0b0b92dce1efce', - 'url' => 'https://pinterest.com/website/verify/', + 'name' => 'Pinterest Site Verification', + 'key' => 'p:domain_verify', + 'format' => 'f100679e6048d45e4a0b0b92dce1efce', + 'url' => 'https://pinterest.com/website/verify/', + 'pattern' => $patterns['pinterest'], ), 'yandex' => array( - 'name' => 'Yandex.Webmaster', - 'key' => 'yandex-verification', - 'format' => '44d68e1216009f40', - 'url' => 'https://webmaster.yandex.com/sites/', + 'name' => 'Yandex.Webmaster', + 'key' => 'yandex-verification', + 'format' => '44d68e1216009f40', + 'url' => 'https://webmaster.yandex.com/sites/', + 'pattern' => $patterns['yandex'], ), 'facebook' => array( - 'name' => 'Facebook Domain Verification', - 'key' => 'facebook-domain-verification', - 'format' => 'rvv8b23jxlp1lq41I9rwsvpzncy1fd', - 'url' => 'https://business.facebook.com/settings/', + 'name' => 'Facebook Domain Verification', + 'key' => 'facebook-domain-verification', + 'format' => 'rvv8b23jxlp1lq41I9rwsvpzncy1fd', + 'url' => 'https://business.facebook.com/settings/', + 'pattern' => $patterns['facebook'], ), ); } diff --git a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php index 1f916e96a55e..11e116a87f9c 100644 --- a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php +++ b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php @@ -6,6 +6,23 @@ * @package jetpack */ +if ( ! function_exists( 'jetpack_verification_service_patterns' ) ) { + /** + * Return the accepted character patterns for verification service codes. + * + * @return array Verification service patterns. + */ + function jetpack_verification_service_patterns() { + return array( + 'google' => '/^[A-Za-z0-9_-]+$/', + 'bing' => '/^[A-Fa-f0-9]+$/', + 'pinterest' => '/^[a-f0-9]+$/', + 'yandex' => '/^[a-f0-9]+$/', + 'facebook' => '/^[A-Za-z0-9_-]+$/', + ); + } +} + if ( ! function_exists( 'jetpack_verification_validate' ) ) { /** * Validate jetpack verification codes. @@ -13,17 +30,39 @@ * @param array $verification_services_codes - array of verification codes. */ function jetpack_verification_validate( $verification_services_codes ) { + $service_patterns = jetpack_verification_service_patterns(); + foreach ( $verification_services_codes as $key => $code ) { + $code = is_scalar( $code ) ? (string) $code : ''; + // Parse html meta tag if it does not look like a valid code. if ( ! preg_match( '/^[a-z0-9_-]+$/i', $code ) ) { $code = jetpack_verification_get_code( $code ); } - $code = esc_attr( trim( $code ) ); + $code = esc_attr( trim( (string) $code ) ); // limit length to 100 chars. $code = substr( $code, 0, 100 ); + if ( '' !== $code && isset( $service_patterns[ $key ] ) && ! preg_match( $service_patterns[ $key ], $code ) ) { + if ( function_exists( 'add_settings_error' ) ) { + $services = function_exists( 'jetpack_verification_services' ) ? jetpack_verification_services() : array(); + $service_name = isset( $services[ $key ]['name'] ) ? $services[ $key ]['name'] : ucfirst( $key ); + add_settings_error( + 'verification_services_codes', + 'invalid_' . $key . '_verification_code', + sprintf( + /* translators: %s: Name of the verification service. */ + __( 'Invalid verification code for %s. Enter only the content value from the meta tag.', 'jetpack' ), + $service_name + ) + ); + } + + $code = ''; + } + /** * Fire after each Verification code was validated. * diff --git a/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php b/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php index 1e67cc412998..16f1ed0f4e73 100644 --- a/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php +++ b/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php @@ -181,6 +181,44 @@ public function test_post_settings_sets_key_values( $setting_name, $setting_valu $this->assertSame( $expected_value, $updated[ $setting_name ] ); } + /** + * Invalid site verification codes return an actionable client error and are not saved. + */ + public function test_post_rejects_invalid_site_verification_code() { + $setting = wp_json_encode( + array( 'verification_services_codes' => array( 'bing' => 'not-a-bing-token' ) ), + JSON_UNESCAPED_SLASHES + ); + + $response = $this->make_post_request( $setting ); + + $this->assertWPError( $response ); + $this->assertSame( 'invalid_input', $response->get_error_code() ); + $this->assertSame( 400, $response->get_error_data() ); + $this->assertFalse( get_option( 'verification_services_codes' ) ); + } + + /** + * A valid site verification meta tag is reduced to its content value and saved. + */ + public function test_post_saves_site_verification_code_from_meta_tag() { + $setting = wp_json_encode( + array( + 'verification_services_codes' => array( + 'bing' => '', + ), + ), + JSON_UNESCAPED_SLASHES + ); + + $response = $this->make_post_request( $setting ); + + $this->assertSame( + array( 'bing' => '12C1203B5086AECE94EB3A3D9830B2E' ), + $response['updated']['verification_services_codes'] + ); + } + /** * The free tier description is capped to 500 characters to match the * paid-tier description field. diff --git a/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php b/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php index 0327e019dc08..0ec245a92c13 100644 --- a/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php +++ b/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php @@ -1,6 +1,7 @@ assertSame( + array( $service => $code ), + jetpack_verification_validate( array( $service => $code ) ) + ); + } + + /** + * Verification codes with invalid service-specific characters are rejected. + * + * @dataProvider invalid_verification_code_provider + * + * @param string $service Verification service key. + * @param string $code Verification code. + */ + #[DataProvider( 'invalid_verification_code_provider' )] + public function test_service_specific_invalid_code_is_rejected( $service, $code ) { + $this->assertSame( + array( $service => '' ), + jetpack_verification_validate( array( $service => $code ) ) + ); + } + + /** + * Provide valid verification codes. + * + * @return array Test cases. + */ + public static function valid_verification_code_provider() { + return array( + 'google' => array( 'google', 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8' ), + 'bing' => array( 'bing', '12C1203B5086AECE94EB3A3D9830B2E' ), + 'pinterest' => array( 'pinterest', 'f100679e6048d45e4a0b0b92dce1efce' ), + 'yandex' => array( 'yandex', '44d68e1216009f40' ), + 'facebook' => array( 'facebook', 'rvv8b23jxlp1lq41I9rwsvpzncy1fd' ), + ); + } + + /** + * Provide invalid verification codes. + * + * @return array Test cases. + */ + public static function invalid_verification_code_provider() { + return array( + 'bing with non-hex characters' => array( 'bing', 'not-a-bing-token' ), + 'pinterest with uppercase letters' => array( 'pinterest', 'ABCDEF123456' ), + 'yandex with non-hex characters' => array( 'yandex', 'not-a-yandex-token' ), + 'google with spaces' => array( 'google', 'not a google token' ), + 'facebook with punctuation' => array( 'facebook', 'not.a.facebook.token' ), + ); + } } From a810a9ce55e847bc45fdb7dfb285fbb3bad365ca Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Tue, 8 Sep 2026 12:25:10 -0400 Subject: [PATCH 2/4] Jetpack: satisfy verification static analysis --- .../class.wpcom-json-api-site-settings-endpoint.php | 2 +- .../modules/verification-tools/verification-tools-utils.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php index 3baa66f91089..1f61f86facee 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php @@ -1240,7 +1240,7 @@ function ( &$value ) { continue; } - $validated_code = isset( $verification_codes[ $service_key ] ) ? $verification_codes[ $service_key ] : ''; + $validated_code = $verification_codes[ $service_key ] ?? ''; if ( '' === $validated_code ) { return new WP_Error( 'invalid_input', diff --git a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php index 11e116a87f9c..4f3f821c9cbe 100644 --- a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php +++ b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php @@ -48,7 +48,7 @@ function jetpack_verification_validate( $verification_services_codes ) { if ( '' !== $code && isset( $service_patterns[ $key ] ) && ! preg_match( $service_patterns[ $key ], $code ) ) { if ( function_exists( 'add_settings_error' ) ) { $services = function_exists( 'jetpack_verification_services' ) ? jetpack_verification_services() : array(); - $service_name = isset( $services[ $key ]['name'] ) ? $services[ $key ]['name'] : ucfirst( $key ); + $service_name = $services[ $key ]['name'] ?? ucfirst( $key ); add_settings_error( 'verification_services_codes', 'invalid_' . $key . '_verification_code', From 45a8b66920344bcc61813504a0e7af8b57015a45 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Tue, 8 Sep 2026 20:12:58 -0400 Subject: [PATCH 3/4] Simplify site verification code validation --- .../blog-verification-tools.php | 47 ++++++++----------- .../verification-tools-utils.php | 23 ++------- ...N_API_Site_Settings_V1_4_Endpoint_Test.php | 2 +- .../Jetpack_Verification_Tools_Utils_Test.php | 28 +++++------ 4 files changed, 38 insertions(+), 62 deletions(-) diff --git a/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php b/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php index 4913674e120c..a80bad752773 100644 --- a/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php +++ b/projects/plugins/jetpack/modules/verification-tools/blog-verification-tools.php @@ -16,43 +16,36 @@ * @return array - an array of supported services. */ function jetpack_verification_services() { - $patterns = jetpack_verification_service_patterns(); - return array( 'google' => array( - 'name' => 'Google Search Console', - 'key' => 'google-site-verification', - 'format' => 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8', - 'url' => 'https://www.google.com/webmasters/tools/', - 'pattern' => $patterns['google'], + 'name' => 'Google Search Console', + 'key' => 'google-site-verification', + 'format' => 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8', + 'url' => 'https://www.google.com/webmasters/tools/', ), 'bing' => array( - 'name' => 'Bing Webmaster Center', - 'key' => 'msvalidate.01', - 'format' => '12C1203B5086AECE94EB3A3D9830B2E', - 'url' => 'https://www.bing.com/toolbox/webmaster/', - 'pattern' => $patterns['bing'], + 'name' => 'Bing Webmaster Center', + 'key' => 'msvalidate.01', + 'format' => '12C1203B5086AECE94EB3A3D9830B2E', + 'url' => 'https://www.bing.com/toolbox/webmaster/', ), 'pinterest' => array( - 'name' => 'Pinterest Site Verification', - 'key' => 'p:domain_verify', - 'format' => 'f100679e6048d45e4a0b0b92dce1efce', - 'url' => 'https://pinterest.com/website/verify/', - 'pattern' => $patterns['pinterest'], + 'name' => 'Pinterest Site Verification', + 'key' => 'p:domain_verify', + 'format' => 'f100679e6048d45e4a0b0b92dce1efce', + 'url' => 'https://pinterest.com/website/verify/', ), 'yandex' => array( - 'name' => 'Yandex.Webmaster', - 'key' => 'yandex-verification', - 'format' => '44d68e1216009f40', - 'url' => 'https://webmaster.yandex.com/sites/', - 'pattern' => $patterns['yandex'], + 'name' => 'Yandex.Webmaster', + 'key' => 'yandex-verification', + 'format' => '44d68e1216009f40', + 'url' => 'https://webmaster.yandex.com/sites/', ), 'facebook' => array( - 'name' => 'Facebook Domain Verification', - 'key' => 'facebook-domain-verification', - 'format' => 'rvv8b23jxlp1lq41I9rwsvpzncy1fd', - 'url' => 'https://business.facebook.com/settings/', - 'pattern' => $patterns['facebook'], + 'name' => 'Facebook Domain Verification', + 'key' => 'facebook-domain-verification', + 'format' => 'rvv8b23jxlp1lq41I9rwsvpzncy1fd', + 'url' => 'https://business.facebook.com/settings/', ), ); } diff --git a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php index 4f3f821c9cbe..0566ee447b31 100644 --- a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php +++ b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php @@ -6,23 +6,6 @@ * @package jetpack */ -if ( ! function_exists( 'jetpack_verification_service_patterns' ) ) { - /** - * Return the accepted character patterns for verification service codes. - * - * @return array Verification service patterns. - */ - function jetpack_verification_service_patterns() { - return array( - 'google' => '/^[A-Za-z0-9_-]+$/', - 'bing' => '/^[A-Fa-f0-9]+$/', - 'pinterest' => '/^[a-f0-9]+$/', - 'yandex' => '/^[a-f0-9]+$/', - 'facebook' => '/^[A-Za-z0-9_-]+$/', - ); - } -} - if ( ! function_exists( 'jetpack_verification_validate' ) ) { /** * Validate jetpack verification codes. @@ -30,13 +13,13 @@ function jetpack_verification_service_patterns() { * @param array $verification_services_codes - array of verification codes. */ function jetpack_verification_validate( $verification_services_codes ) { - $service_patterns = jetpack_verification_service_patterns(); + $code_pattern = '/^[a-z0-9_-]+$/i'; foreach ( $verification_services_codes as $key => $code ) { $code = is_scalar( $code ) ? (string) $code : ''; // Parse html meta tag if it does not look like a valid code. - if ( ! preg_match( '/^[a-z0-9_-]+$/i', $code ) ) { + if ( ! preg_match( $code_pattern, $code ) ) { $code = jetpack_verification_get_code( $code ); } @@ -45,7 +28,7 @@ function jetpack_verification_validate( $verification_services_codes ) { // limit length to 100 chars. $code = substr( $code, 0, 100 ); - if ( '' !== $code && isset( $service_patterns[ $key ] ) && ! preg_match( $service_patterns[ $key ], $code ) ) { + if ( '' !== $code && ! preg_match( $code_pattern, $code ) ) { if ( function_exists( 'add_settings_error' ) ) { $services = function_exists( 'jetpack_verification_services' ) ? jetpack_verification_services() : array(); $service_name = $services[ $key ]['name'] ?? ucfirst( $key ); diff --git a/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php b/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php index 16f1ed0f4e73..84bd995bb700 100644 --- a/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php +++ b/projects/plugins/jetpack/tests/php/json-api/WPCOM_JSON_API_Site_Settings_V1_4_Endpoint_Test.php @@ -186,7 +186,7 @@ public function test_post_settings_sets_key_values( $setting_name, $setting_valu */ public function test_post_rejects_invalid_site_verification_code() { $setting = wp_json_encode( - array( 'verification_services_codes' => array( 'bing' => 'not-a-bing-token' ) ), + array( 'verification_services_codes' => array( 'bing' => 'not.a.valid.token' ) ), JSON_UNESCAPED_SLASHES ); diff --git a/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php b/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php index 0ec245a92c13..7dd41ea8e533 100644 --- a/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php +++ b/projects/plugins/jetpack/tests/php/modules/verification-tools/Jetpack_Verification_Tools_Utils_Test.php @@ -48,7 +48,7 @@ public function test_jetpack_verification_validate_google_code_in_meta_single_qu } /** - * Verification codes with valid service-specific characters are accepted. + * Verification codes with valid characters are accepted for every service. * * @dataProvider valid_verification_code_provider * @@ -56,7 +56,7 @@ public function test_jetpack_verification_validate_google_code_in_meta_single_qu * @param string $code Verification code. */ #[DataProvider( 'valid_verification_code_provider' )] - public function test_service_specific_valid_code_is_accepted( $service, $code ) { + public function test_valid_code_is_accepted_for_every_service( $service, $code ) { $this->assertSame( array( $service => $code ), jetpack_verification_validate( array( $service => $code ) ) @@ -64,7 +64,7 @@ public function test_service_specific_valid_code_is_accepted( $service, $code ) } /** - * Verification codes with invalid service-specific characters are rejected. + * Verification codes with invalid characters are rejected for every service. * * @dataProvider invalid_verification_code_provider * @@ -72,7 +72,7 @@ public function test_service_specific_valid_code_is_accepted( $service, $code ) * @param string $code Verification code. */ #[DataProvider( 'invalid_verification_code_provider' )] - public function test_service_specific_invalid_code_is_rejected( $service, $code ) { + public function test_invalid_code_is_rejected_for_every_service( $service, $code ) { $this->assertSame( array( $service => '' ), jetpack_verification_validate( array( $service => $code ) ) @@ -86,11 +86,11 @@ public function test_service_specific_invalid_code_is_rejected( $service, $code */ public static function valid_verification_code_provider() { return array( - 'google' => array( 'google', 'dBw5CvburAxi537Rp9qi5uG2174Vb6JwHwIRwPSLIK8' ), - 'bing' => array( 'bing', '12C1203B5086AECE94EB3A3D9830B2E' ), - 'pinterest' => array( 'pinterest', 'f100679e6048d45e4a0b0b92dce1efce' ), - 'yandex' => array( 'yandex', '44d68e1216009f40' ), - 'facebook' => array( 'facebook', 'rvv8b23jxlp1lq41I9rwsvpzncy1fd' ), + 'google' => array( 'google', 'verification_Code-123' ), + 'bing' => array( 'bing', 'verification_Code-123' ), + 'pinterest' => array( 'pinterest', 'verification_Code-123' ), + 'yandex' => array( 'yandex', 'verification_Code-123' ), + 'facebook' => array( 'facebook', 'verification_Code-123' ), ); } @@ -101,11 +101,11 @@ public static function valid_verification_code_provider() { */ public static function invalid_verification_code_provider() { return array( - 'bing with non-hex characters' => array( 'bing', 'not-a-bing-token' ), - 'pinterest with uppercase letters' => array( 'pinterest', 'ABCDEF123456' ), - 'yandex with non-hex characters' => array( 'yandex', 'not-a-yandex-token' ), - 'google with spaces' => array( 'google', 'not a google token' ), - 'facebook with punctuation' => array( 'facebook', 'not.a.facebook.token' ), + 'google' => array( 'google', 'invalid.code' ), + 'bing' => array( 'bing', 'invalid.code' ), + 'pinterest' => array( 'pinterest', 'invalid.code' ), + 'yandex' => array( 'yandex', 'invalid.code' ), + 'facebook' => array( 'facebook', 'invalid.code' ), ); } } From 6b724a9ccfb860b84d09729ceaf6c8a80c65c6d2 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Tue, 8 Sep 2026 20:32:36 -0400 Subject: [PATCH 4/4] Jetpack: remove redundant verification admin error --- .../verification-tools-utils.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php index 0566ee447b31..268bcafe284e 100644 --- a/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php +++ b/projects/plugins/jetpack/modules/verification-tools/verification-tools-utils.php @@ -29,20 +29,6 @@ function jetpack_verification_validate( $verification_services_codes ) { $code = substr( $code, 0, 100 ); if ( '' !== $code && ! preg_match( $code_pattern, $code ) ) { - if ( function_exists( 'add_settings_error' ) ) { - $services = function_exists( 'jetpack_verification_services' ) ? jetpack_verification_services() : array(); - $service_name = $services[ $key ]['name'] ?? ucfirst( $key ); - add_settings_error( - 'verification_services_codes', - 'invalid_' . $key . '_verification_code', - sprintf( - /* translators: %s: Name of the verification service. */ - __( 'Invalid verification code for %s. Enter only the content value from the meta tag.', 'jetpack' ), - $service_name - ) - ); - } - $code = ''; }