Open ghost opened 9 years ago
Here's a test program which (on my linux 2.1.4 server) goes wrong every time:
var useragent = require('useragent');
function testArray(agents) {
// test an array of user agent strings
var i,
parsed,
okcount = 0,
errcount = 0;
console.log('testing %d unique user agent strings', agents.length);
for (i = 0; i < agents.length; i += 1) {
parsed = useragent.parse(agents[i]);
if (parsed.device.family.indexOf('$') !== -1 || parsed.device.family.indexOf('undefined') !== -1) {
console.log('User agent: %s', agents[i]);
console.log('device.family: %s', parsed.device.family);
errcount += 1;
} else {
okcount += 1;
}
}
console.log('success: %d', okcount);
console.log('failure: %d', errcount);
}
var agents = [];
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG GT-I9500 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; U; Android 2.2.1; ZiiLABS ZiiO7 Build/v2.02.04) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile Safari/528.16');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-T230 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36');
agents.push('Mozilla/5.0 (Linux; U; Android 2.2.1; ZiiLABS ZiiO7 Build/v2.00.13-FROYO) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile Safari/528.16');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG GT-I9295 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; U; Android 4.1.1; en-gb; PMP3970B Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30');
agents.push('Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; PMP3970B Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30');
agents.push('Mozilla/5.0 (Linux; U; Android 4.4.2; en-gb; LG-D802 Build/KOT49I.D80220d) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.1599.103 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG GT-I9505/I9505XXUGNJ5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; ar-ae; SAMSUNG SM-N9005 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.4; en-gb; SAMSUNG SM-G901F Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.4; en-us; SAMSUNG SM-N910C Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/2.0 Chrome/34.0.1847.76 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.2.2; IdeaTab A3000-F Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 5.0.1; HTC One_M8 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.4; HTC_One_M8 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.4; HTC One_M8 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG GT-I9505 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-T520 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36');
agents.push('Mozilla/5.0 (Linux; U; Android 4.4.2; en-gb; HTC_One_E8 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');
agents.push('Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LG-D802 Build/KOT49I.D80220c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.1599.103 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; LG-D802 Build/KOT49I.D80220c) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.103 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; ar-ae; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-N9005 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36');
agents.push('Mozilla/5.0 (Linux; U; Android 4.1; en-gb; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30@-@524254924');
testArray(agents);
Sample output:
testing 27 unique user agent strings
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG GT-I9500 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; U; Android 2.2.1; ZiiLABS ZiiO7 Build/v2.02.04) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile Safari/528.16
device.family: ZiiLABS $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-T230 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; U; Android 2.2.1; ZiiLABS ZiiO7 Build/v2.00.13-FROYO) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile Safari/528.16
device.family: ZiiLABS $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG GT-I9295 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; U; Android 4.1.1; en-gb; PMP3970B Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
device.family: Prestigio PMP3970B $2
User agent: Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; PMP3970B Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
device.family: Prestigio PMP3970B $2
User agent: Mozilla/5.0 (Linux; U; Android 4.4.2; en-gb; LG-D802 Build/KOT49I.D80220d) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.1599.103 Mobile Safari/537.36
device.family: LG-$2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG GT-I9505/I9505XXUGNJ5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; ar-ae; SAMSUNG SM-N9005 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung SAMSUNG $2
User agent: Mozilla/5.0 (Linux; Android 4.4.4; en-gb; SAMSUNG SM-G901F Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.4; en-us; SAMSUNG SM-N910C Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/2.0 Chrome/34.0.1847.76 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.2.2; IdeaTab A3000-F Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Safari/537.36
device.family: Lenovo IdeaTab $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 5.0.1; HTC One_M8 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Mobile Safari/537.36
device.family: HTC One $2 $3 $4
User agent: Mozilla/5.0 (Linux; Android 4.4.4; HTC_One_M8 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36
device.family: HTC One $2 $3 $4
User agent: Mozilla/5.0 (Linux; Android 4.4.4; HTC One_M8 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36
device.family: HTC One $2 $3 $4
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG GT-I9505 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-gb; SAMSUNG SM-T520 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; U; Android 4.4.2; en-gb; HTC_One_E8 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
device.family: HTC One $2 $3 $4
User agent: Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LG-D802 Build/KOT49I.D80220c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.1599.103 Mobile Safari/537.36
device.family: LG-$2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; LG-D802 Build/KOT49I.D80220c) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.103 Mobile Safari/537.36
device.family: LG-$2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; ar-ae; SAMSUNG SM-G900FD Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung $2
User agent: Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-N9005 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
device.family: Samsung SAMSUNG $2
User agent: Mozilla/5.0 (Linux; U; Android 4.1; en-gb; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30@-@524254924
device.family: Samsung undefined$2
success: 0
failure: 27
Output on 2.1.3:
testing 27 unique user agent strings
success: 27
failure: 0
Hope that helps.
I'm assuming that the regexp.yml source file that I used changed format causing these kind of build failures. I'll look in to it tonight if can find some spare cycles. Thanks for your detailed report and testcase!
I have two versions of my production server. Most are still on version 2.1.3, but one I built recently has 2.1.4. On this 2.1.4 server, there are some weird device.family results appearing in my logs. For example:
Picking the top one as an example, the user agent is
Using 2.1.3, device.family is correct:
Samsung SM-T230
Using 2.1.4, device.family is incorrect:Samsung $2
90% of devices are OK. These broken ones represent around 10% of the different devices in my logs. I have not noticed any similar issues with browser or operating system. It just looks like device that's a bit broken.
I'm going to force 2.1.3 for the moment on my servers, but hopefully this can be fixed going forward :-)