Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version.InvalidVersionError due to version with prerelease #35

Closed
macobo opened this issue Apr 4, 2024 · 0 comments · Fixed by #36
Closed

Version.InvalidVersionError due to version with prerelease #35

macobo opened this issue Apr 4, 2024 · 0 comments · Fixed by #36

Comments

@macobo
Copy link
Contributor

macobo commented Apr 4, 2024

The following parsing fails

iex(4)> UAInspector.parse("Mozilla/5.0 (Linux; arm_64; Android 10; Mi Note 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5765.05 Mobile Safari/537.36")
** (Version.InvalidVersionError) invalid version: "115.0.5765-05"
    (elixir 1.16.0) lib/version.ex:475: Version.to_matchable/2
    (elixir 1.16.0) lib/version.ex:347: Version.compare/2
    (ua_inspector 3.9.0) lib/ua_inspector/parser/client.ex:293: UAInspector.Parser.Client.resolve_engine_detailed/3
    (ua_inspector 3.9.0) lib/ua_inspector/parser/client.ex:266: UAInspector.Parser.Client.maybe_resolve_engine/4
    (ua_inspector 3.9.0) lib/ua_inspector/parser/client.ex:322: UAInspector.Parser.Client.result/3
    (ua_inspector 3.9.0) lib/ua_inspector/parser/client.ex:24: UAInspector.Parser.Client.parse/2
    (ua_inspector 3.9.0) lib/ua_inspector/parser.ex:155: UAInspector.Parser.parse_client/2
    iex:4: (file)

Problem seems to be using the elixir Version module to compare semver strings with prerelease tags?

macobo added a commit to macobo/ua_inspector that referenced this issue Apr 4, 2024
Issue: elixir-inspector#35

Currently, parsing the following user agent fails:
`Mozilla/5.0 (Linux; arm_64; Android 10; Mi Note 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5765.05 Mobile Safari/537.36`

After this fix, this is parsed as:
```
%UAInspector.Result{
  user_agent: "Mozilla/5.0 (Linux; arm_64; Android 10; Mi Note 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5765.05 Mobile Safari/537.36",
  browser_family: "Chrome",
  client: %UAInspector.Result.Client{
    engine: "Blink",
    engine_version: "115.0.5765.05",
    name: "Chrome Mobile",
    type: "browser",
    version: "115.0.5765.05"
  },
  device: %UAInspector.Result.Device{
    brand: "Xiaomi",
    model: "Mi Note 10",
    type: "phablet"
  },
  os: %UAInspector.Result.OS{name: "Android", platform: "ARM", version: "10"},
  os_family: "Android"
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant