Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change Chrome Android smartphone detection to allow "Mobile" anywhere. #7556

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,9 @@ protected function parseDevice(): void
if (null === $this->device && 'Android' === $osFamily
&& $this->matchUserAgent('Chrome/[\.0-9]*')
) {
if ($this->matchUserAgent('(?:Mobile|eliboM) Safari/')) {
if ($this->matchUserAgent('(?:Mobile|eliboM)')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
} elseif ($this->matchUserAgent('(?!Mobile )Safari/')) {
} else {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/fixtures/clienthints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
engine: Blink
engine_version: "98.0.4758.101"
device:
type: tablet
type: smartphone
brand: ""
model: ""
os_family: Android
Expand Down
36 changes: 36 additions & 0 deletions Tests/fixtures/smartphone-37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7523,3 +7523,39 @@
model: Redmi 13C
os_family: Android
browser_family: Opera
-
user_agent: 'Mozilla/5.0 (Linux; U; Android 4.0.4; fa-ir) AppleWebKit/534.35 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.35 Puffin/2.10990AP Mobile'
os:
name: Android
version: "4.0.4"
platform: ""
client:
type: browser
name: Puffin
version: "2.10990"
engine: WebKit
engine_version: "534.35"
device:
type: smartphone
brand: ""
model: ""
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/113.0.5672.162 Mobile DuckDuckGo/5 Safari/537.36
os:
name: Android
version: "13"
platform: ""
client:
type: browser
name: DuckDuckGo Privacy Browser
version: "5"
engine: Blink
engine_version: "113.0.5672.162"
device:
type: smartphone
brand: ""
model: ""
os_family: Android
browser_family: Chrome
18 changes: 0 additions & 18 deletions Tests/fixtures/tablet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,6 @@
model: ""
os_family: Android
browser_family: Android Browser
-
user_agent: 'Mozilla/5.0 (Linux; U; Android 4.0.4; fa-ir) AppleWebKit/534.35 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.35 Puffin/2.10990AP Mobile'
os:
name: Android
version: "4.0.4"
platform: ""
client:
type: browser
name: Puffin
version: "2.10990"
engine: WebKit
engine_version: "534.35"
device:
type: tablet
brand: ""
model: ""
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 4.4.2; Florida Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36
os:
Expand Down
Loading