From 5e044f0e543479348ed6b2de2760f02f4023b6af Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Wed, 30 Oct 2024 10:43:49 -0500 Subject: [PATCH] Add support for Naver Whale --- README.md | 1 + src/UserAgent/Browsers.php | 1 + src/UserAgentParser.php | 4 ++-- tests/user_agents.dist.json | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf3a00c..85cea72 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ Predefined helper constants from `donatj\UserAgent\Browsers` | `Browsers::VALVE_STEAM_TENFOOT` | Valve Steam Tenfoot | | `Browsers::VIVALDI` | Vivaldi | | `Browsers::WGET` | Wget | +| `Browsers::WHALE` | Whale | | `Browsers::WORDPRESS` | WordPress | | `Browsers::YANDEX` | Yandex | | `Browsers::YANDEXBOT` | YandexBot | diff --git a/src/UserAgent/Browsers.php b/src/UserAgent/Browsers.php index 990ed7b..301230f 100644 --- a/src/UserAgent/Browsers.php +++ b/src/UserAgent/Browsers.php @@ -54,6 +54,7 @@ interface Browsers { const VALVE_STEAM_TENFOOT = 'Valve Steam Tenfoot'; const VIVALDI = 'Vivaldi'; const WGET = 'Wget'; + const WHALE = 'Whale'; const WORDPRESS = 'WordPress'; const YANDEX = 'Yandex'; const YANDEXBOT = 'YandexBot'; diff --git a/src/UserAgentParser.php b/src/UserAgentParser.php index 1da2734..f1c8375 100644 --- a/src/UserAgentParser.php +++ b/src/UserAgentParser.php @@ -98,7 +98,7 @@ function parse_user_agent( $u_agent = null ) { preg_match_all(<<<'REGEX' %(?PCamino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit| TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|(?-i:Edge)|EdgA?|CriOS|UCBrowser|Puffin| -OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android| +OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android|Whale| Baiduspider|Applebot|Facebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|ChatGPT-User|GPTBot|OAI-SearchBot| Valve\ Steam\ Tenfoot|Mastodon| NintendoBrowser|PLAYSTATION\ (?:\d|Vita)+) @@ -188,7 +188,7 @@ function parse_user_agent( $u_agent = null ) { } } } - } elseif( $find([ 'Googlebot', 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) { + } elseif( $find([ 'Googlebot', 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Whale', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) { $version = $result[BROWSER_VERSION][$key]; } elseif( $rv_result && $find('Trident') ) { $browser = 'MSIE'; diff --git a/tests/user_agents.dist.json b/tests/user_agents.dist.json index ef8e155..bb68536 100644 --- a/tests/user_agents.dist.json +++ b/tests/user_agents.dist.json @@ -574,6 +574,26 @@ "browser": "Wget", "version": "1.12" }, + "Mozilla\/5.0 (X11; CrOS x86_64 2.22.17) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/108.0.0.0 Whale\/3.18.186.3 Safari\/537.36": { + "platform": "Chrome OS", + "browser": "Whale", + "version": "3.18.186.3" + }, + "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Whale\/3.24.223.21 Safari\/537.36": { + "platform": "Macintosh", + "browser": "Whale", + "version": "3.24.223.21" + }, + "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/128.0.0.0 Whale\/3.28.266.11 Safari\/537.36": { + "platform": "Macintosh", + "browser": "Whale", + "version": "3.28.266.11" + }, + "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/128.0.0.0 Whale\/3.28.266.14 Safari\/537.36": { + "platform": "Windows", + "browser": "Whale", + "version": "3.28.266.14" + }, "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit\/536.5 (KHTML, like Gecko) YaBrowser\/1.0.1084.5402 Chrome\/19.0.1084.5402 Safari\/536.5": { "platform": "Macintosh", "browser": "Yandex", @@ -839,6 +859,16 @@ "browser": "UC Browser", "version": "13.0.8.1291" }, + "Mozilla\/5.0 (Linux; Android 13; SM-F926N) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/102.0.5005.187 Whale\/2.7.8.2 Safari\/537.36": { + "platform": "Android", + "browser": "Whale", + "version": "2.7.8.2" + }, + "Mozilla\/5.0 (Linux; Android 10; K) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Whale\/3.5.4.2 Mobile Safari\/537.36": { + "platform": "Android", + "browser": "Whale", + "version": "3.5.4.2" + }, "Mozilla\/5.0 (Linux; arm_64; Android 12; SM-G965F) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/100.0.4896.127 YaBrowser\/21.3.4.59 Mobile Safari\/537.36": { "platform": "Android", "browser": "Yandex", @@ -939,6 +969,11 @@ "browser": "UC Browser", "version": "2.4.0.367" }, + "Mozilla\/5.0 (iPad; CPU OS 16_5_1 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/16.0 Whale\/2.8.8.3883 Mobile\/15E148 Safari\/604.1": { + "platform": "iPad", + "browser": "Whale", + "version": "2.8.8.3883" + }, "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",