Fix browser detection on ApplePay module.

This commit is contained in:
Pedro Silva 2023-11-08 11:56:53 +00:00
parent ac7779bc41
commit b352b702c9
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 7 additions and 1 deletions

View file

@ -93,6 +93,11 @@ return array(
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ?? '' );
if ( $user_agent ) {
foreach ( PropertiesDictionary::DISALLOWED_USER_AGENTS as $disallowed_agent ) {
if ( strpos( $user_agent, $disallowed_agent ) !== false ) {
return false;
}
}
foreach ( PropertiesDictionary::ALLOWED_USER_AGENTS as $allowed_agent ) {
if ( strpos( $user_agent, $allowed_agent ) !== false ) {
return true;

View file

@ -13,7 +13,8 @@ namespace WooCommerce\PayPalCommerce\Applepay\Assets;
* Class PropertiesDictionary
*/
class PropertiesDictionary {
public const ALLOWED_USER_AGENTS = array( 'Safari', 'Macintosh', 'iPhone', 'iPad', 'iPod' );
public const DISALLOWED_USER_AGENTS = array( 'Chrome' );
public const ALLOWED_USER_AGENTS = array( 'Safari', 'Macintosh', 'iPhone', 'iPad', 'iPod' );
public const BILLING_CONTACT_INVALID = 'billing Contact Invalid';