The browser running on the set-top box is a Opera for Devices 4.22.1, similar to Chrome 94, but with several differences. One difference is that navigator.userAgentDataexists, but is an empty object.
So the check _uach succeeds, also does _uach.platform != 'Unknown' (undefined != 'Unknown'). However, _uach.platform.replace() throws the error, since _uach.platform is undefined).
To Reproduce
If you're not a registered developer for that set-top box, there's no way to reproduce the behavior. You can mimic it by setting var _uach = {}; in line 818.
The browser's user agent is Mozilla/5.0, AppleWebKit/537.36, Chrome/92.0.4515.159, Safari/537.36, OPR/46.0.2207.0, OMI/4.22.1, VODAFONE_STB/7.2.A105.99bba.ngc BCM7271/7.2.A105.99bba.ngc/DTIW387/HIGH (Sagemcom_Broadband_SAS, DTIW387_UHD_VF_DE, Wireless)
Library version 1.0.37
Describe the bug When calling
getOS()
on a Vodafone GigaTV set-top box, an error is thrownTypeError: Cannot read property 'replace' of undefined
.The error happens in the code block starting in https://github.com/faisalman/ua-parser-js/blob/1.0.37/src/ua-parser.js#L868:
The browser running on the set-top box is a Opera for Devices 4.22.1, similar to Chrome 94, but with several differences. One difference is that
navigator.userAgentData
exists, but is an empty object.So the check
_uach
succeeds, also does_uach.platform != 'Unknown'
(undefined != 'Unknown'
). However,_uach.platform.replace()
throws the error, since_uach.platform
isundefined
).To Reproduce If you're not a registered developer for that set-top box, there's no way to reproduce the behavior. You can mimic it by setting
var _uach = {};
in line 818.The browser's user agent is
Mozilla/5.0, AppleWebKit/537.36, Chrome/92.0.4515.159, Safari/537.36, OPR/46.0.2207.0, OMI/4.22.1, VODAFONE_STB/7.2.A105.99bba.ngc BCM7271/7.2.A105.99bba.ngc/DTIW387/HIGH (Sagemcom_Broadband_SAS, DTIW387_UHD_VF_DE, Wireless)
Expected behavior
getOS()
never throws an error.