updated plugin Jetpack Protect version 2.2.0

This commit is contained in:
2024-06-27 12:10:57 +00:00
committed by Gitium
parent ec9d8a5834
commit 938cef2946
218 changed files with 7469 additions and 1864 deletions
wp-content/plugins/jetpack-protect
CHANGELOG.md
build
composer.jsonjetpack-protect.php
jetpack_vendor
automattic
jetpack-admin-ui
jetpack-assets
jetpack-backup-helper-script-manager
jetpack-boost-core
jetpack-boost-speed-score
jetpack-config
jetpack-connection
jetpack-constants
jetpack-device-detection
jetpack-identity-crisis
jetpack-jitm
jetpack-licensing
jetpack-logo
jetpack-my-jetpack
jetpack-plugins-installer
jetpack-redirect
jetpack-roles
jetpack-status
jetpack-sync
jetpack-transport-helper
jetpack-waf
i18n-map.php
readme.txt
src
vendor

@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.1.3] - 2024-04-08
### Added
- Added functionality for extracting the browser and desktop platform from a user agent. [#36568]
### Changed
- Add new bots. [#36477]
## [2.1.2] - 2024-03-18
### Changed
- Internal updates.
@ -189,6 +196,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Moving jetpack_is_mobile into a package
[2.1.3]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.2...v2.1.3
[2.1.2]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/Automattic/jetpack-device-detection/compare/v2.0.1...v2.1.0

@ -49,6 +49,8 @@ class Device_Detection {
'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ),
'is_tablet' => $ua_info->is_tablet(),
'platform' => $ua_info->get_platform(),
'desktop_platform' => $ua_info->get_desktop_platform(),
'browser' => $ua_info->get_browser(),
);
$info['is_handheld'] = $info['is_phone'] || $info['is_tablet'];

@ -64,19 +64,30 @@ class User_Agent_Info {
*
* @var null|string
*/
private $platform = null;
const PLATFORM_WINDOWS = 'windows';
const PLATFORM_IPHONE = 'iphone';
const PLATFORM_IPOD = 'ipod';
const PLATFORM_IPAD = 'ipad';
const PLATFORM_BLACKBERRY = 'blackberry';
const PLATFORM_BLACKBERRY_10 = 'blackberry_10';
const PLATFORM_SYMBIAN = 'symbian_series60';
const PLATFORM_SYMBIAN_S40 = 'symbian_series40';
const PLATFORM_J2ME_MIDP = 'j2me_midp';
const PLATFORM_ANDROID = 'android';
const PLATFORM_ANDROID_TABLET = 'android_tablet';
const PLATFORM_FIREFOX_OS = 'firefoxOS';
private $platform = null;
const PLATFORM_WINDOWS = 'windows';
const PLATFORM_IPHONE = 'iphone';
const PLATFORM_IPOD = 'ipod';
const PLATFORM_IPAD = 'ipad';
const PLATFORM_BLACKBERRY = 'blackberry';
const PLATFORM_BLACKBERRY_10 = 'blackberry_10';
const PLATFORM_SYMBIAN = 'symbian_series60';
const PLATFORM_SYMBIAN_S40 = 'symbian_series40';
const PLATFORM_J2ME_MIDP = 'j2me_midp';
const PLATFORM_ANDROID = 'android';
const PLATFORM_ANDROID_TABLET = 'android_tablet';
const PLATFORM_FIREFOX_OS = 'firefoxOS';
const PLATFORM_DESKTOP_LINUX = 'linux';
const PLATFORM_DESKTOP_MAC = 'mac';
const PLATFORM_DESKTOP_WINDOWS = 'windows';
const PLATFORM_DESKTOP_CHROME = 'chrome';
const BROWSER_CHROME = 'chrome';
const BROWSER_FIREFOX = 'firefox';
const BROWSER_SAFARI = 'safari';
const BROWSER_EDGE = 'edge';
const BROWSER_OPERA = 'opera';
const BROWSER_IE = 'ie';
const OTHER = 'other';
/**
* A list of dumb-phone user agent parts.
@ -277,6 +288,57 @@ class User_Agent_Info {
return $this->platform;
}
/**
* Returns the platform for desktops
*
* @return string
*/
public function get_desktop_platform() {
$ua = $this->useragent;
if ( empty( $ua ) ) {
return false;
}
$platform = self::OTHER;
if ( static::is_linux_desktop() ) {
$platform = self::PLATFORM_DESKTOP_LINUX;
} elseif ( static::is_mac_desktop() ) {
$platform = self::PLATFORM_DESKTOP_MAC;
} elseif ( static::is_windows_desktop() ) {
$platform = self::PLATFORM_DESKTOP_WINDOWS;
} elseif ( static::is_chrome_desktop() ) {
$platform = self::PLATFORM_DESKTOP_CHROME;
}
return $platform;
}
/**
* A simple pattern matching method for extracting the browser from the user agent.
*
* @return string
*/
public function get_browser() {
$ua = $this->useragent;
if ( empty( $ua ) ) {
return self::OTHER;
}
if ( static::is_opera_mini() || static::is_opera_mobile() || static::is_opera_desktop() || static::is_opera_mini_dumb() ) {
return self::BROWSER_OPERA;
} elseif ( static::is_edge_browser() ) {
return self::BROWSER_EDGE;
} elseif ( static::is_chrome_desktop() || self::is_chrome_for_iOS() ) {
return self::BROWSER_CHROME;
} elseif ( static::is_safari_browser() ) {
return self::BROWSER_SAFARI;
} elseif ( static::is_firefox_mobile() || static::is_firefox_desktop() ) {
return self::BROWSER_FIREFOX;
} elseif ( static::is_ie_browser() ) {
return self::BROWSER_IE;
}
return self::OTHER;
}
/**
* This method detects for UA which can display iPhone-optimized web content.
* Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc.
@ -714,6 +776,46 @@ class User_Agent_Info {
}
}
/**
* Detect Safari browser
*/
public static function is_safari_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Safari' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Detect Edge browser
*/
public static function is_edge_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Edge' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Detect Edge browser
*/
public static function is_ie_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$ua = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
if ( false === ( strpos( $ua, 'MSIE' ) || strpos( $ua, 'Trident/7' ) ) ) {
return false;
}
return true;
}
/**
* Detect modern Opera desktop
*
@ -1271,6 +1373,66 @@ class User_Agent_Info {
return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false );
}
/**
* Determines whether a desktop platform is Linux OS
*
* @return bool
*/
public static function is_linux_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/linux/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Determines whether a desktop platform is Mac OS
*
* @return bool
*/
public static function is_mac_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/macintosh|mac os x/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Determines whether a desktop platform is Windows OS
*
* @return bool
*/
public static function is_windows_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/windows|win32/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Determines whether a desktop platform is Chrome OS
*
* @return bool
*/
public static function is_chrome_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/chrome/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}
/**
* Retrieve the blackberry OS version.
*
@ -1579,6 +1741,7 @@ class User_Agent_Info {
'bne.es_bot', // https://www.bne.es/es/colecciones/archivo-web-espanola/aviso-webmasters
'google-safety;', // https://www.google.com/bot.html
'mojeekbot', // https://www.mojeek.com/bot.html
'linkwalker', // https://www.linkwalker.com/
);
foreach ( $bot_agents as $bot_agent ) {