Skip to content

Commit fcec4e9

Browse files
committed
Improve detection of Samsung Smart TVs
1 parent 63cd885 commit fcec4e9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/Analyser/Header/Useragent/Os.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ private function detectTizen($ua)
945945
if (preg_match('/Tizen/u', $ua)) {
946946
$this->data->os->name = 'Tizen';
947947

948-
if (preg_match('/Tizen[\/ ]([0-9.]*[0-9])/u', $ua, $match)) {
948+
if (preg_match('/Tizen[\/ ]?([0-9.]*[0-9])/u', $ua, $match)) {
949949
$this->data->os->version = new Version([ 'value' => $match[1] ]);
950950
}
951951

@@ -954,6 +954,9 @@ private function detectTizen($ua)
954954
if (strtoupper($match[1]) == 'SMART-TV') {
955955
$falsepositive = true;
956956
}
957+
if ($match[1] == 'TV') {
958+
$falsepositive = true;
959+
}
957960
if ($match[1] == 'Linux') {
958961
$falsepositive = true;
959962
}
@@ -1009,7 +1012,7 @@ private function detectTizen($ua)
10091012
}
10101013

10111014

1012-
if (preg_match('/\(SMART[ -]TV;/iu', $ua, $match)) {
1015+
if (preg_match('/\((SMART[ -])?TV;/iu', $ua, $match)) {
10131016
$this->data->device->type = Constants\DeviceType::TELEVISION;
10141017
$this->data->device->manufacturer = 'Samsung';
10151018
$this->data->device->series = 'Smart TV';

tests/data/mobile/os-tizen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@
172172
readable: 'Samsung Browser on a Samsung GT-I9500 prototype running Tizen 2.0'
173173
-
174174
headers: 'User-Agent: Mozilla/5.0(Linux; Tizen2.2;sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.2 Mobile Safari/537.3'
175-
result: { browser: { name: 'Samsung Browser' }, engine: { name: Webkit, version: '537.3' }, os: { name: Tizen }, device: { type: mobile, subtype: smart } }
176-
readable: 'Samsung Browser on Tizen'
175+
result: { browser: { name: 'Samsung Browser' }, engine: { name: Webkit, version: '537.3' }, os: { name: Tizen, version: '2.2' }, device: { type: mobile, subtype: smart } }
176+
readable: 'Samsung Browser on Tizen 2.2'
177177
-
178178
headers: 'User-Agent: Opera/9.80 (Tizen; Opera Mini/7.5.35847/35.5691; U; xx) Presto/2.8.119 Version/11.10'
179179
result: { browser: { name: 'Opera Mini', version: '7.5', type: browser }, engine: { name: Presto, version: 2.8.119 }, os: { name: Tizen }, device: { type: mobile, subtype: smart } }

tests/data/television/samsung.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,7 @@
142142
headers: 'User-Agent: Mozilla/5.0 ( U; Linux/+2013; Maple2012) AppleWebKit/535.20+ (KHTML, like Gecko) Safari/535.20+'
143143
readable: 'a Samsung Smart TV 2013'
144144
result: { engine: { name: Webkit, version: '535.20' }, device: { type: television, manufacturer: Samsung, series: 'Smart TV 2013' } }
145+
-
146+
headers: 'User-Agent: Mozilla/5.0 (TV; Linux; Tizen2.3) AppleWebkit/538.1 (KHTML, like Gecko) SamsungBrowser/1.0 TV Safari/538.1'
147+
readable: 'Samsung Browser 1.0 on a Samsung Smart TV running Tizen 2.3'
148+
result: { browser: { name: 'Samsung Browser', version: '1.0' }, engine: { name: Webkit, version: '538.1' }, os: { name: Tizen, version: '2.3' }, device: { type: television, manufacturer: Samsung, series: 'Smart TV' } }

0 commit comments

Comments
 (0)