3rd-Eden / useragent

Useragent parser for Node.js, ported from browserscope.org
MIT License
898 stars 139 forks source link

useragent strings that contain multiple "Windows NT" versions are not handled properly #38

Closed mcvella closed 9 years ago

mcvella commented 10 years ago

Some useragent strings contain more than one "Windows NT" version.

For example (this is an actual useragent string):

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; Zune 4.0; .NET CLR 1.

Note that there is present both "Windows NT 6.1" and "Windows NT 5.1".

Currently, the useragent module reports this the OS for this as "Windows XP", when in fact it should be "Windows 7".

The fix here is to order the "Windows NT" regexes so that Windows versions are searched for in order from highest version to lowest version (since only the highest "Windows NT" string should be regarded).

I'll open a pull request for this now.

3rd-Eden commented 9 years ago

Closing this, all changes and regexp updates should be made against regexp database that we use, not this module.

( https://github.com/tobie/ua-parser/blob/master/regexes.yaml )