sanitize version_string we got from the wire - #8582
Open
r10s wants to merge 1 commit into
Open
Conversation
`version_string` is meant to be displayed by UI, and comes from the wire. therefore, as a general precaution, convert the string to smth. that is regarded as a typical version string. all versions in scope are currently 123.456.789, that is the base. we can adapt if there is really a need, but not for theoretical version strings - and as we do not stop processing, things are not that bad even if we missed a valid usecase.
hpk42
reviewed
Aug 14, 2026
| let version = get_app_version(&accounts, "foo", "baz").await?.unwrap(); | ||
| assert_eq!(version.version_integer, 1337); | ||
| assert_eq!(version.version_string, "13.37"); | ||
| assert_eq!(version.version_string, "13.37"); // spaces are removed by sanizize_version_string() |
j-g00da
reviewed
Aug 14, 2026
Comment on lines
+59
to
+66
| .chars() | ||
| .map(|c| { | ||
| if matches!(c, 'a'..='z' | '0'..='9' | '.' | '-') { | ||
| c | ||
| } else { | ||
| '-' | ||
| } | ||
| }) |
Contributor
There was a problem hiding this comment.
this can be simplified:
Suggested change
| .chars() | |
| .map(|c| { | |
| if matches!(c, 'a'..='z' | '0'..='9' | '.' | '-') { | |
| c | |
| } else { | |
| '-' | |
| } | |
| }) | |
| .replace(|c: char| !c.is_alphanumeric() && c != '.', "-") |
Hocuri
approved these changes
Aug 14, 2026
Hocuri
left a comment
Collaborator
There was a problem hiding this comment.
LGTM once the two comments from hpk and j-g00da are addressed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
version_stringis meant to be displayed by UI, and comes from the wire.therefore, as a general precaution, ensure a string that is
regarded as a typical version string. all versions in scope are currently v123.456.789-shortsuffix, where suffix is a-z and mostly unused in production. that is the base. we can adapt if there is really a need, but not for theoretical version strings. as we do not stop processing, things are not bad even if we missed a valid usecase herr.
moreover, if
version_stringis empty, we skip the candidate - as we cannot display something useful to the user. that little bit of care is expected from relays :)