From e159493010d4b71c9620a43fd05f8284f29dcfeb Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Tue, 1 Sep 2020 11:15:49 -0500 Subject: [PATCH] Adds support for Applebot --- src/UserAgentParser.php | 4 ++-- tests/user_agents.json | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/UserAgentParser.php b/src/UserAgentParser.php index 6ba738c..7cc864d 100644 --- a/src/UserAgentParser.php +++ b/src/UserAgentParser.php @@ -60,7 +60,7 @@ function parse_user_agent( $u_agent = null ) { preg_match_all('%(?PCamino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit| TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|Edge|Edg|CriOS|UCBrowser|Puffin|OculusBrowser|SamsungBrowser| - Baiduspider|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl| + Baiduspider|Applebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl| Valve\ Steam\ Tenfoot| NintendoBrowser|PLAYSTATION\ (\d|Vita)+) (?:\)?;?) @@ -147,7 +147,7 @@ function parse_user_agent( $u_agent = null ) { } } } - } elseif( $find(array( 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome' ), $key, $browser) ) { + } elseif( $find(array( 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome' ), $key, $browser) ) { $version = $result['version'][$key]; } elseif( $rv_result && $find('Trident') ) { $browser = 'MSIE'; diff --git a/tests/user_agents.json b/tests/user_agents.json index 15973e2..209d2b8 100644 --- a/tests/user_agents.json +++ b/tests/user_agents.json @@ -1,4 +1,14 @@ { + "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit\/600.2.5\n(KHTML, like Gecko) Version\/8.0.2 Safari\/600.2.5 (Applebot\/0.1)": { + "platform": "Macintosh", + "browser": "Applebot", + "version": "0.1" + }, + "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit\/605.1.15\n(KHTML, like Gecko) Version\/12.1.1 Safari\/605.1.15 (Applebot\/0.1)": { + "platform": "Macintosh", + "browser": "Applebot", + "version": "0.1" + }, "Mozilla\/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.11) Gecko\/20071128 Camino\/1.5.4": { "platform": "Macintosh", "browser": "Camino", @@ -604,6 +614,16 @@ "browser": "UC Browser", "version": "2.4.0.367" }, + "Mozilla\/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit\/600.1.4\n(KHTML, like Gecko) Version\/8.0 Mobile\/12B410 Safari\/600.1.4 (Applebot\/0.1;\n+http:\/\/www.apple.com\/go\/applebot)": { + "platform": "iPhone", + "browser": "Applebot", + "version": "0.1" + }, + "Mozilla\/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit\/605.1.15Z\n(KHTML, like Gecko) Version\/13.1 Mobile\/15E148 Safari\/604.1 (Applebot\/0.1)": { + "platform": "iPhone", + "browser": "Applebot", + "version": "0.1" + }, "Mozilla\/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit\/534.46.0 (KHTML, like Gecko) CriOS\/19.0.1084.60 Mobile\/9B206 Safari\/7534.48.3": { "platform": "iPhone", "browser": "Chrome",