From 90ff54636076c484a722d8f56f200bbc4317591d Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Tue, 6 Oct 2020 16:23:51 +0100 Subject: [PATCH 01/10] Go Http Client --- .travis.yml | 22 ++++++++++------------ data/applications-bots.php | 2 ++ data/regexes/applications-bots.php | 2 +- data/regexes/applications-browsers.php | 2 +- data/regexes/applications-others.php | 2 +- tests/data/bots/generic.yaml | 8 ++++++++ 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed4b58cca..be631473c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,14 +3,12 @@ dist: trusty language: php php: - - 5.4 - - 5.5 - - 5.6 - 7.0 - 7.1 - 7.2 - 7.3 - 7.4 + # - 8.0 (Release Date: November 26, 2020) before_script: - composer self-update @@ -22,20 +20,20 @@ before_script: # Set memory limit to 2 MB - echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - # Disable X-debug on all but PHP 5.6 - - if [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then phpenv config-rm xdebug.ini; fi + # Disable X-debug on all but PHP 7.0 + - if [ "$TRAVIS_PHP_VERSION" != "7.0" ]; then phpenv config-rm xdebug.ini; fi script: - vendor/bin/phpcs --standard=PSR1,PSR2 -n src - # Run tests (all except PHP 5.6) - - if [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then php bin/runner.php --show check; fi - - if [ "$TRAVIS_PHP_VERSION" != "5.6" ]; then vendor/bin/phpunit; fi + # Run tests (all except PHP 7.0) + - if [ "$TRAVIS_PHP_VERSION" != "7.0" ]; then php bin/runner.php --show check; fi + - if [ "$TRAVIS_PHP_VERSION" != "7.0" ]; then vendor/bin/phpunit; fi - # Run tests with coverage enabled (only PHP 5.6) - - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then php bin/runner.php --coverage --show check; fi - - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then vendor/bin/phpunit --coverage-clover phpunit.xml; fi + # Run tests with coverage enabled (only PHP 7.0) + - if [ "$TRAVIS_PHP_VERSION" = "7.0" ]; then php bin/runner.php --coverage --show check; fi + - if [ "$TRAVIS_PHP_VERSION" = "7.0" ]; then vendor/bin/phpunit --coverage-clover phpunit.xml; fi after_script: # Upload coverage to Coveralls.io - - if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then travis_retry php vendor/bin/coveralls -v; fi + - if [ "$TRAVIS_PHP_VERSION" = "7.0" ]; then travis_retry php vendor/bin/coveralls -v; fi diff --git a/data/applications-bots.php b/data/applications-bots.php index 3c3cac601..41bc6d99d 100644 --- a/data/applications-bots.php +++ b/data/applications-bots.php @@ -298,6 +298,8 @@ [ 'name' => 'Curl', 'id' => 'curl', 'regexp' => '/^curl\/([0-9.]*)/u' ], [ 'name' => 'Go', 'id' => 'package', 'regexp' => '/Go [0-9\.]+ package http/u' ], + [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/Go-http-client\/([0-9.]*)/u' ], + [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/go-httpclient v([0-9.]*)/u' ], [ 'name' => 'Java', 'id' => 'java', 'regexp' => '/^Java\/([0-9.]*)/u' ], [ 'name' => 'Perl', 'id' => 'simple', 'regexp' => '/LWP::Simple\//u' ], [ 'name' => 'Perl', 'id' => 'libwww', 'regexp' => '/libwww-perl\//u' ], diff --git a/data/regexes/applications-bots.php b/data/regexes/applications-bots.php index fa8685a44..ea403dd9a 100644 --- a/data/regexes/applications-bots.php +++ b/data/regexes/applications-bots.php @@ -2,4 +2,4 @@ namespace WhichBrowser\Data; -Applications::$BOTS_REGEX = '/(008|360|a6|abound|muncher|adaxas|addthis|admantx|ahrefsbot|archiver|altavista|curious|cloudfront|amorank|archive|jeeves|astra|backlink|baidu|bazqux|bingbot|msnbot|msmobot|bing|blogbridge|bloglines|bloglovin|blogpulse|blogram|blogtrot|blogshares|boardreader|browsershots|bubing|buck|butterfly|bytespider|heritrix|cliqz|cloudflare|comodo|commafeed|cbot|watchdog|datasearch|daumoa|digg|domaincrawl|discord|domain|exabot|exactseek|ezooms|facebook|fast|flamingo|fastladder|feed|wrangler|validator|fever|florienzh|friendica|robot|genieo|fetchor|google|gomez|ichiro|gooblog|goorss|grammarly|grub|hatena|capture|heureka|htdig|httpmon|hubpages|spider|crawler|kakao|kouio|larbin|linkedin|linkdex|livedoor|ltx71|magpie|mapion|mail\.ru|socialstreams|mixi|mnogo|monitor|dotbot|rogerbot|yeti|netcraft|netvibes|newsblur|newsgator|nimbostratus|orange|pages|psbot|pingdom|pinterest|pocket|postrank|comment|rssbar|hunter|quora|safesearch|scrapy|semrush|seznam|shopwiki|reader|simplepie|site24|slack|sogou|sophora|soso|spdycheck|spinn|detector|summify|telegram|twisted|twitter|tiny|tlsprober|typhoeus|vagabondo|voat|voila|vocus|mcrawler|w3bot|jigsaw|w3c|wayback|webindexer|wordpress|mechanize|xerka|sitemap|yacy|yandex|yahoo|y\!j|slurp|yelp|httpclient|nutch|synapse|indy|wget|curl|package|java|simple|libwww|lwp|urllib|requests|php|pear|zend|ruby)/i'; +Applications::$BOTS_REGEX = '/(008|360|a6|abound|muncher|adaxas|addthis|admantx|ahrefsbot|archiver|altavista|curious|cloudfront|amorank|archive|jeeves|astra|backlink|baidu|bazqux|bingbot|msnbot|msmobot|bing|blogbridge|bloglines|bloglovin|blogpulse|blogram|blogtrot|blogshares|boardreader|browsershots|bubing|buck|butterfly|bytespider|heritrix|cliqz|cloudflare|comodo|commafeed|cbot|watchdog|datasearch|daumoa|digg|domaincrawl|discord|domain|exabot|exactseek|ezooms|facebook|fast|flamingo|fastladder|feed|wrangler|validator|fever|florienzh|friendica|robot|genieo|fetchor|google|gomez|ichiro|gooblog|goorss|grammarly|grub|hatena|capture|heureka|htdig|httpmon|hubpages|spider|crawler|kakao|kouio|larbin|linkedin|linkdex|livedoor|ltx71|magpie|mapion|mail\.ru|socialstreams|mixi|mnogo|monitor|dotbot|rogerbot|yeti|netcraft|netvibes|newsblur|newsgator|nimbostratus|orange|pages|psbot|pingdom|pinterest|pocket|postrank|comment|rssbar|hunter|quora|safesearch|scrapy|semrush|seznam|shopwiki|reader|simplepie|site24|slack|sogou|sophora|soso|spdycheck|spinn|detector|summify|telegram|twisted|twitter|tiny|tlsprober|typhoeus|vagabondo|voat|voila|vocus|mcrawler|w3bot|jigsaw|w3c|wayback|webindexer|wordpress|mechanize|xerka|sitemap|yacy|yandex|yahoo|y\!j|slurp|yelp|httpclient|nutch|synapse|indy|wget|curl|package|gohttpclient|java|simple|libwww|lwp|urllib|requests|php|pear|zend|ruby)/i'; diff --git a/data/regexes/applications-browsers.php b/data/regexes/applications-browsers.php index 4ffa37fb7..56d6f4a30 100644 --- a/data/regexes/applications-browsers.php +++ b/data/regexes/applications-browsers.php @@ -2,4 +2,4 @@ namespace WhichBrowser\Data; -Applications::$BROWSERS_REGEX = '/(115|126|2345|37abc|qihu|1stbrowser|7star|abrowse|acorn|acoo|amigo|aol|america|apus|arachne|arora|aweb|avant|asw|avg|aviator|avira|flyflow|bdbrowser|bdspark|basilisk|beamrise|beonex|blackwren|blackhawk|bolt|blackbird|brave|brisk|browsex|browzar|byffox|camino|canure|ccleaner|cent|charon|chedot|cheshire|chimlac|chimera|chromeplus|colibri|columbus|cometbird|comodo|dragon|conkeror|coc|coolnovo|corom|crazy|crusta|cunaguaro|cyberdog|cyberfox|daedalus|degan|demeter|deskbrowse|diigo|dillo|doczilla|rhodonit|dplus|elements|eudoraweb|falkon|flamesky|flock|framafox|freeu|galeon|globalmojo|epiphany|greenbrowser|hola|hydra|ibrowse|icab|iceape|icecat|icedove|iceweasel|irider|iridium|iron|kapiko|kazehakase|kchrome|kinza|kkman|klondike|kylo|meleon|lbrowser|lbbrowser|light|lobo|lolifox|lovense|lunascape|naenara|netcaptor|madfox|mxbrowser|min|mini|mixshark|mlbrowser|mypal|multixp|netpositive|nichrome|origyn|owb|live|juzi|orca|oregano|otter|palemoon|patriott|perk|polarity|privacy|qiyu|qtweb|quicklook|qupzilla|qute|rekonq|ryouko|sylera|saayaa|salam|shiira|sielo|sitekiosk|sleipnir|slimjet|metasr|sparrow|stainless|station|sunchrome|sundance|sundial|superbird|swiftweasel|swiftfox|swing|to-browser|tencent|tenfourfox|theworld|tulip|tungsten|ultrab|usejump|vimprobable|vivaldi|airwatch|vonkeror|voyager|waterfox|whale|winwap|xvast|yabrowser|zvu|zipzap|1password|3g explorer|4g explorer|aloha|atomiclite|au|awakening|baidu|bdmobile|bidu|baiduboxapp|browser|blazer|acheetahi|cornowser|coolmarket|cute|digia|doris|doroty|www browser|epic|eui|go\.web|helium|heytap|huohoubrowser|surfboard|isurf|jig browser|jumanji|tnsbrowser|kiosk|kiwi|lebrowser|liebao|macross|mammoth|mcent|mint|mib|cmcs|motorola|multizilla|netfrontlife|onebrowser|oneplus|plink|polaris|pure|openwave|up|km|oppo|quark|realme|semc|stnc|sogou|symphony|tenta|ucpro|vivo|weblite|wk|yaani|alti|aplix|awox|browserserver|isis|netbox|spyglass|oregan|viera|zetakey|bunjalloo|nwf|nuanti|wib|prince|demobrowser|dooble|dwb|evm|fireweb|hive|intermec|phantom|qt|roccat|raven|rockmelt|scope|slim|smbrowser|snowshoe|sputnik|surf|tao|taz|uzbl|villanova|vimb|wada|wavelink|webrender|webster|wyzo|yelang|yrcweb|linemode|lynx|links|w3m|nimbus|Webwasher|sankore|adapi|brightsign|coship)/i'; +Applications::$BROWSERS_REGEX = '/(115|126|2345|37abc|qihu|1stbrowser|7star|abrowse|acorn|acoo|amigo|aol|america|apus|arachne|arora|aweb|avant|asw|avg|aviator|avira|flyflow|bdbrowser|bdspark|basilisk|beamrise|beonex|blackwren|blackhawk|bolt|blackbird|brave|brisk|browsex|browzar|byffox|camino|canure|ccleaner|cent|charon|chedot|cheshire|chimlac|chimera|chromeplus|colibri|columbus|cometbird|comodo|dragon|conkeror|coc|coolnovo|corom|crazy|crusta|cunaguaro|cyberdog|cyberfox|daedalus|degan|demeter|deskbrowse|diigo|dillo|doczilla|rhodonit|dplus|elements|eudoraweb|falkon|flamesky|flock|framafox|freeu|galeon|globalmojo|epiphany|greenbrowser|hola|hydra|ibrowse|icab|iceape|icecat|icedove|iceweasel|irider|iridium|iron|kapiko|kazehakase|kchrome|kinza|kkman|klondike|kylo|meleon|lbrowser|lbbrowser|light|lobo|lolifox|lovense|lunascape|naenara|netcaptor|madfox|mxbrowser|min|mini|mixshark|mlbrowser|mypal|multixp|netpositive|nichrome|origyn|owb|live|juzi|orca|oregano|otter|palemoon|patriott|perk|polarity|privacy|qiyu|qtweb|quicklook|qupzilla|qute|rekonq|ryouko|sylera|saayaa|salam|shiira|sielo|sitekiosk|sleipnir|slimjet|metasr|sparrow|stainless|station|sunchrome|sundance|sundial|superbird|swiftweasel|swiftfox|swing|to-browser|tencent|tenfourfox|theworld|tulip|tungsten|ultrab|usejump|vimprobable|vivaldi|airwatch|vonkeror|voyager|waterfox|whale|winwap|xvast|yabrowser|zvu|zipzap|1password|3g explorer|4g explorer|aloha|atomiclite|au|awakening|baidu|bdmobile|bidu|baiduboxapp|browser|blazer|acheetahi|cornowser|coolmarket|cute|digia|doris|doroty|ecosia|www browser|epic|eui|go\.web|helium|heytap|huohoubrowser|surfboard|isurf|jig browser|jumanji|tnsbrowser|kiosk|kiwi|lebrowser|liebao|macross|mammoth|mcent|mint|mobicip|mib|cmcs|motorola|multizilla|netfrontlife|onebrowser|oneplus|plink|polaris|pure|openwave|up|km|oppo|quark|realme|semc|stnc|sogou|symphony|tenta|ucpro|vivo|weblite|wk|yaani|alti|aplix|awox|browserserver|isis|netbox|spyglass|oregan|viera|zetakey|bunjalloo|nwf|nuanti|wib|prince|demobrowser|dooble|dwb|evm|fireweb|hive|intermec|phantom|qt|roccat|raven|rockmelt|scope|slim|smbrowser|snowshoe|sputnik|surf|tao|taz|uzbl|villanova|vimb|wada|wavelink|webrender|webster|wyzo|yelang|yrcweb|linemode|lynx|links|w3m|nimbus|Webwasher|sankore|adapi|brightsign|coship)/i'; diff --git a/data/regexes/applications-others.php b/data/regexes/applications-others.php index c8000539e..483dcade1 100644 --- a/data/regexes/applications-others.php +++ b/data/regexes/applications-others.php @@ -2,4 +2,4 @@ namespace WhichBrowser\Data; -Applications::$OTHERS_REGEX = '/(itunes|qt|bluefish|nightingale|songbird|stagefright|substream|vlc|windows-media|coreplayer|flycast|boxee|kodi|xbmc|lightning|thunderbird|outlook|lotus|postbox|bat|yahoo|daum|flipboard|akregator|blogos|cococ|feed|liferea|news|jetbrains|rss|reeder|reedkit|rome|ziepod|messenger|kakao|kik|line|slack|viber|whatsapp|wire|yammer|fbios|fb4a|googleplus|instagram|pinterest|weibo|tumblr|twitter|wp-android|yelp|office|bingweb|hao123|gsa|naver|sogousearch|yandex|atom|golive|brackets|iweb|frontpage|amaya|websphere|download|tansodl|origin|secondlife|valve|raptr|alipay|cooliris|google|leechcraft|expeditor)/i'; +Applications::$OTHERS_REGEX = '/(itunes|qt|bluefish|nightingale|songbird|stagefright|substream|vlc|windows-media|coreplayer|flycast|boxee|kodi|xbmc|lightning|thunderbird|outlook|lotus|postbox|bat|yahoo|daum|flipboard|akregator|blogos|cococ|feed|liferea|news|jetbrains|rss|reeder|reedkit|rome|ziepod|messenger|kakao|kik|line|slack|viber|whatsapp|wire|yammer|zalo|fbios|fb4a|googleplus|instagram|pinterest|weibo|tumblr|twitter|wp-android|yelp|office|bingweb|hao123|gsa|naver|sogousearch|yandex|atom|golive|brackets|iweb|frontpage|amaya|websphere|download|tansodl|origin|secondlife|valve|raptr|alipay|cooliris|google|leechcraft|expeditor)/i'; diff --git a/tests/data/bots/generic.yaml b/tests/data/bots/generic.yaml index e219a037e..998d3dddb 100644 --- a/tests/data/bots/generic.yaml +++ b/tests/data/bots/generic.yaml @@ -586,3 +586,11 @@ headers: 'User-Agent: PocketParser/2.0 (+https://getpocket.com/pocketparser_ua)' readable: 'Pocket 2.0' result: { browser: { name: Pocket, version: '2.0' }, device: { type: bot } } +- + headers: 'User-Agent: Go-http-client/1.1' + readable: 'Go Http Client 1.1' + result: { browser: { name: 'Go Http Client', version: '1.1' }, device: { type: bot } } +- + headers: 'User-Agent: go-httpclient v0.5.1' + readable: 'Go Http Client 0.5.1' + result: { browser: { name: 'Go Http Client', version: '0.5.1' }, device: { type: bot } } From c66746bcbec54c0a35c86a157a6099a436c6a507 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 12:54:51 +0100 Subject: [PATCH 02/10] Add custom code to detact this bot --- src/Analyser/Header/Useragent/Bot.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index e73aee116..64dbd99a6 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -42,6 +42,12 @@ private function &detectBot($ua) $this->data->device->type = Constants\DeviceType::BOT; } + /* Detect Go Http Client */ + if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { + $this->data->browser->name = 'Go Http Client'; + $this->data->browser->version = $result[1] ?? ''; + } + return $this; } } From ef103e1af3e8cc75dee6abedd604bce414fb2342 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 12:56:22 +0100 Subject: [PATCH 03/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index 64dbd99a6..425654771 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -46,6 +46,8 @@ private function &detectBot($ua) if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { $this->data->browser->name = 'Go Http Client'; $this->data->browser->version = $result[1] ?? ''; + + $this->data->device->type = Constants\DeviceType::BOT; } return $this; From cfef2175db7d478b8f645b4b6585361a06e437b0 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 13:15:47 +0100 Subject: [PATCH 04/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index 425654771..b4b1335a0 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -31,6 +31,15 @@ private function &detectBot($ua) $this->data->device->type = Constants\DeviceType::BOT; } + /* Detect Go Http Client */ + if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { + $this->data->browser->reset(); + $this->data->browser->name = 'Go Http Client'; + $this->data->browser->version = $result[1] ?? ''; + + $this->data->device->type = Constants\DeviceType::BOT; + } + /* Detect based on a predefined list or markers */ if ($bot = Data\Applications::identifyBot($ua)) { @@ -42,14 +51,6 @@ private function &detectBot($ua) $this->data->device->type = Constants\DeviceType::BOT; } - /* Detect Go Http Client */ - if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { - $this->data->browser->name = 'Go Http Client'; - $this->data->browser->version = $result[1] ?? ''; - - $this->data->device->type = Constants\DeviceType::BOT; - } - return $this; } } From d6f55ece9597707e5f577c9532aa90eb913e3e81 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 13:19:03 +0100 Subject: [PATCH 05/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index b4b1335a0..aef6e8a05 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -37,6 +37,7 @@ private function &detectBot($ua) $this->data->browser->name = 'Go Http Client'; $this->data->browser->version = $result[1] ?? ''; + $this->data->device->reset(); $this->data->device->type = Constants\DeviceType::BOT; } From fa5e3269bfec7ddc03538b0535dd2a4eb80ec4ce Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 14:18:33 +0100 Subject: [PATCH 06/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index aef6e8a05..f844643e2 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -34,10 +34,13 @@ private function &detectBot($ua) /* Detect Go Http Client */ if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { $this->data->browser->reset(); + $this->data->os->reset(); + $this->data->engine->reset(); + $this->data->device->reset(); + $this->data->browser->name = 'Go Http Client'; $this->data->browser->version = $result[1] ?? ''; - $this->data->device->reset(); $this->data->device->type = Constants\DeviceType::BOT; } From e4fe20815bf3159f5224abfbbfe2d96645008220 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 14:19:27 +0100 Subject: [PATCH 07/10] Update applications-bots.php --- data/applications-bots.php | 1 - 1 file changed, 1 deletion(-) diff --git a/data/applications-bots.php b/data/applications-bots.php index 41bc6d99d..b834f846c 100644 --- a/data/applications-bots.php +++ b/data/applications-bots.php @@ -298,7 +298,6 @@ [ 'name' => 'Curl', 'id' => 'curl', 'regexp' => '/^curl\/([0-9.]*)/u' ], [ 'name' => 'Go', 'id' => 'package', 'regexp' => '/Go [0-9\.]+ package http/u' ], - [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/Go-http-client\/([0-9.]*)/u' ], [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/go-httpclient v([0-9.]*)/u' ], [ 'name' => 'Java', 'id' => 'java', 'regexp' => '/^Java\/([0-9.]*)/u' ], [ 'name' => 'Perl', 'id' => 'simple', 'regexp' => '/LWP::Simple\//u' ], From da049d1f32269f74a2656ce50ec7581569029005 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 14:34:35 +0100 Subject: [PATCH 08/10] Update applications-bots.php --- data/applications-bots.php | 1 + 1 file changed, 1 insertion(+) diff --git a/data/applications-bots.php b/data/applications-bots.php index b834f846c..41bc6d99d 100644 --- a/data/applications-bots.php +++ b/data/applications-bots.php @@ -298,6 +298,7 @@ [ 'name' => 'Curl', 'id' => 'curl', 'regexp' => '/^curl\/([0-9.]*)/u' ], [ 'name' => 'Go', 'id' => 'package', 'regexp' => '/Go [0-9\.]+ package http/u' ], + [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/Go-http-client\/([0-9.]*)/u' ], [ 'name' => 'Go Http Client', 'id' => 'gohttpclient', 'regexp' => '/go-httpclient v([0-9.]*)/u' ], [ 'name' => 'Java', 'id' => 'java', 'regexp' => '/^Java\/([0-9.]*)/u' ], [ 'name' => 'Perl', 'id' => 'simple', 'regexp' => '/LWP::Simple\//u' ], From 4a2fd041d2bb2cf48783363fdbf0512973005e52 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 14:40:20 +0100 Subject: [PATCH 09/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index f844643e2..4c82bf228 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -32,7 +32,8 @@ private function &detectBot($ua) } /* Detect Go Http Client */ - if (preg_match('/Go-http-client\/([0-9.]*)/u', $ua, $result)) { + + if (preg_match('/Go-http-client\/([0-9.]*)/iu', $ua, $result)) { $this->data->browser->reset(); $this->data->os->reset(); $this->data->engine->reset(); From 974f868a8f887224f98e5465f7dadb67a02ba889 Mon Sep 17 00:00:00 2001 From: Ayumi Hamasaki Date: Wed, 7 Oct 2020 19:16:15 +0100 Subject: [PATCH 10/10] Update Bot.php --- src/Analyser/Header/Useragent/Bot.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Analyser/Header/Useragent/Bot.php b/src/Analyser/Header/Useragent/Bot.php index 4c82bf228..b8acd1f81 100644 --- a/src/Analyser/Header/Useragent/Bot.php +++ b/src/Analyser/Header/Useragent/Bot.php @@ -4,6 +4,7 @@ use WhichBrowser\Constants; use WhichBrowser\Data; +use WhichBrowser\Model\Version; trait Bot { @@ -33,14 +34,12 @@ private function &detectBot($ua) /* Detect Go Http Client */ - if (preg_match('/Go-http-client\/([0-9.]*)/iu', $ua, $result)) { + if (preg_match('/Go-http-client\/([0-9.]*)/iu', $ua, $match)) { $this->data->browser->reset(); - $this->data->os->reset(); - $this->data->engine->reset(); $this->data->device->reset(); - + $this->data->browser->name = 'Go Http Client'; - $this->data->browser->version = $result[1] ?? ''; + $this->data->browser->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::BOT; }