Skip to content
Open
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
6 changes: 4 additions & 2 deletions Parser/ParserAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,14 @@ protected function matchUserAgent($regex)
protected function buildByMatch($item, $matches)
{
for ($nb=1;$nb<=3;$nb++) {
if (strpos($item, '$' . $nb) === false) {
if (strpos($item, '$' . $nb) === false && strpos($item, '$u' . $nb) === false && strpos($item, '$l' . $nb) === false && strpos($item, '$uf' . $nb) === false) {
continue;
}

$replace = isset($matches[$nb]) ? $matches[$nb] : '';
$item = trim(str_replace('$' . $nb, $replace, $item));
$item = trim(str_replace(array('$' . $nb, '$u' . $nb, '$l' . $nb, '$uf' . $nb), array($replace, strtoupper($replace), strtolower($replace), ucfirst($replace)), $item));
}

return $item;
}

Expand All @@ -225,6 +226,7 @@ protected function buildVersion($versionString, $matches)
$versionParts = array_slice($versionParts, 0, 1+self::$maxMinorParts);
$versionString = implode('.', $versionParts);
}

return trim($versionString, ' .');
}

Expand Down
20 changes: 20 additions & 0 deletions Tests/fixtures/smartphone-5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7858,6 +7858,26 @@
model: Moto G
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 9; moto g(6) plus) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36
os:
name: Android
short_name: AND
version: "9"
platform: ""
client:
type: browser
name: Chrome Mobile
short_name: CM
version: "73.0.3683.90"
engine: Blink
engine_version: ""
device:
type: smartphone
brand: MR
model: Moto G
os_family: Android
browser_family: Chrome
-
user_agent: Mozilla/5.0 (Linux; Android 6.0.1; MotoG3 Build/MPIS24.107-55-2-17) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36
os:
Expand Down
6 changes: 3 additions & 3 deletions regexes/device/mobiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6022,11 +6022,11 @@ Motorola:
model: 'Moto M'

- regex: 'Moto ([CGEZ]) \(([a-z0-9]+)\)( Plus| Play)?'
model: 'Moto $1$2$3'
model: 'Moto $u1$2$3'
- regex: 'Moto ?([CGEZ])([0-9]+)( Plus| Play)?'
model: 'Moto $1$2$3'
model: 'Moto $u1$2$3'
- regex: 'Moto ?([CGEZ])( Plus| Play)?'
model: 'Moto $1$2'
model: 'Moto $u1$2'

- regex: 'Motorola[ _\-]([a-z0-9]+)'
model: '$1'
Expand Down