diff --git a/Parser/ParserAbstract.php b/Parser/ParserAbstract.php index 199bb952ba..7344f63bd0 100644 --- a/Parser/ParserAbstract.php +++ b/Parser/ParserAbstract.php @@ -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; } @@ -225,6 +226,7 @@ protected function buildVersion($versionString, $matches) $versionParts = array_slice($versionParts, 0, 1+self::$maxMinorParts); $versionString = implode('.', $versionParts); } + return trim($versionString, ' .'); } diff --git a/Tests/fixtures/smartphone-5.yml b/Tests/fixtures/smartphone-5.yml index ba620772c7..8ee7b28789 100644 --- a/Tests/fixtures/smartphone-5.yml +++ b/Tests/fixtures/smartphone-5.yml @@ -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: diff --git a/regexes/device/mobiles.yml b/regexes/device/mobiles.yml index 1147fd1250..17a8b62982 100644 --- a/regexes/device/mobiles.yml +++ b/regexes/device/mobiles.yml @@ -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'