podigee/device_detector

Old Ubuntu user agent parsing seems incorrect

janxious opened this issue · 3 comments

Obvious from looking at oss.yml why this is so, but I have what I believe to be a legitimate user agent string from an old version of Ubuntu that is failing the following test:

def test_ubuntu_10_device_detector
  agent_string = 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.10 Chromium/10.0.648.133 Chrome/10.0.648.133 Safari/534.16'

  uap = UserAgentParser::Parser.new.parse(agent_string)
  assert_equal 'Ubuntu 10.10', uap.os.to_s # UAP seemingly has rules to match this

  dd = DeviceDetector.new(agent_string)
  assert_equal 'Ubuntu', dd.os_name
end

Test output:

  1) Failure:
ImprovedUserAgentTest#test_ubuntu_10_device_detector [test/models/user_agent_test.rb:15]:
Expected: "Ubuntu"
  Actual: "$1"

Thanks for reporting the issue!

The oss.yml file itself is correct and detects the old Ubuntu, but what was wrong was the extraction / parsing of the name.

I am fixing and optimizing the code right now, going to release a new version ASAP.

👍 I missed the other line that would pick it up in there.

This issue has been fixed. Thanks again for reporting!