Repository navigation
Conversation
Reject "." and ".." as architecture or variant components when parsing platform specifiers. These values were previously accepted, but are treated as path components by path.Join, which is used by Format and FormatAll. This could cause platforms to be silently changed when formatting them, making parsing and formatting inconsistent. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add Validate to check that a platform has non-empty OS and architecture fields and that its components are well-formed. Validation follows the existing platform specifier syntax, rejecting invalid characters and path components such as "." and "..", without restricting values to known or supported platforms. This allows callers to validate platform specifications without formatting, parsing, or normalizing them. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
tianon
reviewed
Oct 30, 2026
| return fmt.Errorf(`%q must not be "." or "..": %w`, s, errInvalidArgument) | ||
| } | ||
| if !specifierRe.MatchString(s) { | ||
| return fmt.Errorf("platform specifier component must match %q: %w", specifierRe.String(), errInvalidArgument) |
Member
There was a problem hiding this comment.
Should this error also include s?
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.
platforms: add Validate utility for OCI platform specifications
Add Validate to check that a platform has non-empty OS and
architecture fields and that its components are well-formed.
Validation follows the existing platform specifier syntax, rejecting
invalid characters and path components such as "." and "..", without
restricting values to known or supported platforms.
This allows callers to validate platform specifications without
formatting, parsing, or normalizing them.