Skip to content

Version 3.1.2 chokes (fails hard) on parsing real-world user agent that previous versions could parse successfully #95

Description

@mikethea1

Thanks for building and maintaining this great library! I upgraded to the latest release and found an issue parsing some

Repro code:

HttpUserAgentParser.Parse("Mozilla/5.0 (Linux; U; Android 13; Infinix X6836 Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/145.0.7632.120 Mobile Safari/537.36 OPR/98.0.2254.81553");

On 3.1.2, this fails with:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at MyCSharp.HttpUserAgentParser.HttpUserAgentParser.GetBrowser(String userAgent) in /home/runner/work/HttpUserAgentParser/HttpUserAgentParser/src/HttpUserAgentParser/HttpUserAgentParser.cs:line 108
   at MyCSharp.HttpUserAgentParser.HttpUserAgentParser.Parse(String userAgent) in /home/runner/work/HttpUserAgentParser/HttpUserAgentParser/src/HttpUserAgentParser/HttpUserAgentParser.cs:line 30

On 3.0.28, this works and gives us MobileDeviceType: Android, Name: Opera, Platform: Android, Version: 98.0.2254.81553

Other examples that fail on 3.1.2 but not 3.0.28:

  • Mozilla/5.0 (Linux; U; Android 13; Hisense U53 Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/145.0.7632.79 Mobile Safari/537.36 OPR/98.0.2254.81553
  • Mozilla/5.0 (Linux; Android 10; MED-LX9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.192 Mobile Safari/537.36 OPR/74.0.3922.71152
  • Mozilla/5.0 (Linux; U; Android 13; Infinix X6526 Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/145.0.7632.79 Mobile Safari/537.36 OPR/97.1.2254.80849

Activity

  1. self-assigned this
    on Mar 5, 2026
  2. BenjaminAbt commented on Mar 5, 2026

    @BenjaminAbt
    Member

    Thank you. I added all of yours and current listed Opera User Agents to the test suite and fixed the issue.
    Because it's an hot path issue, I have unlisted 3.1.2 and released 3.1.3

  3. mikethea1 commented on Mar 6, 2026

    @mikethea1
    Author

    @BenjaminAbt I ran 3.1.3 against the set of user agents that originally hit the error and I now see no failures. Really appreciate the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions