Skip to content

Version parser accepts strings with leading invalid characters #10782

Description

@james-yusuke

Current behavior

mullvad_version::Version::from_str accepts a valid version when it is preceded by invalid
characters. For example, prefix2025.1 is parsed as 2025.1.

This is also observable through the version utility:

$ ANDROID_VERSION=2025.1 cargo run -q -p mullvad-version --bin mullvad-version -- versionCode
25019000
$ ANDROID_VERSION=prefix2025.1 cargo run -q -p mullvad-version --bin mullvad-version -- versionCode
25019000

Expected behavior

Version strings should only be accepted when the entire input matches the Mullvad version format.
prefix2025.1 should return a parsing error.

Cause

VERSION_REGEX is anchored at the end with $, but is not anchored at the start. Git history
shows that the previous parser used a leading ^.

I searched the existing issues and pull requests for similar reports before filing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions