-
Notifications
You must be signed in to change notification settings - Fork 205
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
spec: more liberal separator for repository names #425
Merged
jdolitsky
merged 1 commit into
opencontainers:main
from
rogpeppe-contrib:002-liberal-separators
Jun 22, 2023
Merged
spec: more liberal separator for repository names #425
jdolitsky
merged 1 commit into
opencontainers:main
from
rogpeppe-contrib:002-liberal-separators
Jun 22, 2023
Conversation
This file contains 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
This change makes the separators consistent with the implementation in the Docker distribution [here](https://github.com/distribution/distribution/blob/97b1d649c4938d0f608d96454d6a8326b1f96acd/reference/regexp.go#L53). Relevant parts from that code: ``` separator = `(?:[._]|__|[-]+)` pathComponent = alphanumeric + anyTimes(separator+alphanumeric) remoteName = pathComponent + anyTimes(`/`+pathComponent) namePat = optional(domainAndPort+`/`) + remoteName ``` Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
rogpeppe
requested review from
dmcgowan,
jzelinskie,
jonjohnsonjr,
jdolitsky,
mikebrow,
stevvooe,
sudo-bmitch and
vbatts
as code owners
June 22, 2023 17:40
jonjohnsonjr
approved these changes
Jun 22, 2023
jdolitsky
approved these changes
Jun 22, 2023
andaaron
reviewed
Jun 22, 2023
@@ -153,7 +153,7 @@ To pull a manifest, perform a `GET` request to a URL in the following form: | |||
The `<reference>` MUST NOT be in any other format. | |||
Throughout this document, `<name>` MUST match the following regular expression: | |||
|
|||
`[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)*` | |||
`[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+(\.|_|__|-+)[a-z0-9]+)*)*` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a valid regex? Is it just me or a new parenthesis is closed without being opened?
@rogpeppe ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
`[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+(\.|_|__|-+)[a-z0-9]+)*)*` | |
`[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*` |
I think this might've been the intent 👀
rogpeppe
added a commit
to rogpeppe-contrib/oci-distribution-spec
that referenced
this pull request
Jun 23, 2023
As pointed out by @andaaron in opencontainers#425, the regular expression proposed there was bogus. It was actually wrong in two different ways. Mea culpa, my apologies. This fixes it. I wrote a few test cases to check: https://go.dev/play/p/4_iYH4Hao1- ```go package main import ( "regexp" "testing" ) func TestRepoPattern(t *testing.T) { r := regexp.MustCompile(`^[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*$`) for _, test := range []struct { s string want bool }{ {"foo", true}, {"foo/bar", true}, {"foo/bar__baz", true}, {"foo/bar___baz", false}, {"/foo", false}, {"foo//bar", false}, {"foo-------b__x.com", true}, {"foo-------b__x.com/p----x", true}, {"foo-", false}, {"-foo", false}, {"foo/-bar", false}, {"foo/bar-", false}, {"foo-bar", true}, {"foo----_bar", false}, {"foo----bar_/x", false}, } { if got, want := r.MatchString(test.s), test.want; got != want { t.Errorf("mismatch on %q; got %v want %v", test.s, got, want) } } } ``` Ideally something like the above would be committed for CI testing but perhaps that's a stage too far. Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Merged
jdolitsky
pushed a commit
that referenced
this pull request
Jun 23, 2023
As pointed out by @andaaron in #425, the regular expression proposed there was bogus. It was actually wrong in two different ways. Mea culpa, my apologies. This fixes it. I wrote a few test cases to check: https://go.dev/play/p/4_iYH4Hao1- ```go package main import ( "regexp" "testing" ) func TestRepoPattern(t *testing.T) { r := regexp.MustCompile(`^[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*$`) for _, test := range []struct { s string want bool }{ {"foo", true}, {"foo/bar", true}, {"foo/bar__baz", true}, {"foo/bar___baz", false}, {"/foo", false}, {"foo//bar", false}, {"foo-------b__x.com", true}, {"foo-------b__x.com/p----x", true}, {"foo-", false}, {"-foo", false}, {"foo/-bar", false}, {"foo/bar-", false}, {"foo-bar", true}, {"foo----_bar", false}, {"foo----bar_/x", false}, } { if got, want := r.MatchString(test.s), test.want; got != want { t.Errorf("mismatch on %q; got %v want %v", test.s, got, want) } } } ``` Ideally something like the above would be committed for CI testing but perhaps that's a stage too far. Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
sudo-bmitch
pushed a commit
to sudo-bmitch/distribution-spec
that referenced
this pull request
Aug 18, 2023
This change makes the separators consistent with the implementation in the Docker distribution [here](https://github.com/distribution/distribution/blob/97b1d649c4938d0f608d96454d6a8326b1f96acd/reference/regexp.go#L53). Relevant parts from that code: ``` separator = `(?:[._]|__|[-]+)` pathComponent = alphanumeric + anyTimes(separator+alphanumeric) remoteName = pathComponent + anyTimes(`/`+pathComponent) namePat = optional(domainAndPort+`/`) + remoteName ``` Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
sudo-bmitch
pushed a commit
to sudo-bmitch/distribution-spec
that referenced
this pull request
Aug 18, 2023
As pointed out by @andaaron in opencontainers#425, the regular expression proposed there was bogus. It was actually wrong in two different ways. Mea culpa, my apologies. This fixes it. I wrote a few test cases to check: https://go.dev/play/p/4_iYH4Hao1- ```go package main import ( "regexp" "testing" ) func TestRepoPattern(t *testing.T) { r := regexp.MustCompile(`^[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*$`) for _, test := range []struct { s string want bool }{ {"foo", true}, {"foo/bar", true}, {"foo/bar__baz", true}, {"foo/bar___baz", false}, {"/foo", false}, {"foo//bar", false}, {"foo-------b__x.com", true}, {"foo-------b__x.com/p----x", true}, {"foo-", false}, {"-foo", false}, {"foo/-bar", false}, {"foo/bar-", false}, {"foo-bar", true}, {"foo----_bar", false}, {"foo----bar_/x", false}, } { if got, want := r.MatchString(test.s), test.want; got != want { t.Errorf("mismatch on %q; got %v want %v", test.s, got, want) } } } ``` Ideally something like the above would be committed for CI testing but perhaps that's a stage too far. Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
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.
This change makes the separators consistent with the implementation in the Docker distribution here.
Relevant parts from that code: