Skip to content

Commit

Permalink
Merge pull request #2117 from fuweid/bugfix_add_new_separator_for_ref…
Browse files Browse the repository at this point in the history
…erence_parse

bugfix: extend reference separator
  • Loading branch information
chuanchang authored Aug 20, 2018
2 parents 5847b76 + 5f3ce8c commit 318aad0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 16 additions & 0 deletions pkg/reference/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ func TestParse(t *testing.T) {
input: " ",
expected: nil,
err: ErrInvalid,
}, {
name: "With __ as separator in name",
input: "new__separator",
expected: namedReference{"new__separator"},
}, {
name: "With __ as separator in name and tag",
input: "new__separator:build__testing",
expected: taggedReference{
Named: namedReference{"new__separator"},
tag: "build__testing",
},
}, {
name: "Invalid separator ___",
input: "new__separator___invalid",
expected: nil,
err: ErrInvalid,
},
} {
ref, err := Parse(tc.input)
Expand Down
6 changes: 4 additions & 2 deletions pkg/reference/regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import "regexp"
//
// v1 org.opencontainers.image.ref.name:
//
// NOTE: extend separator with "__" here to compatibility with moby
//
// ref ::= component ("/" component)*
// component ::= alphanum (separator alphanum)*
// alphanum ::= [A-Za-z0-9]+
// separator ::= [-._:@+] | "--"
// separator ::= [-._:@+] | "--" | "__"
//
// In the image-spec, there is no definition about Tag.
//
Expand All @@ -19,7 +21,7 @@ import "regexp"
var (
regAlphanum = expression(`[A-Za-z0-9]`)

regSeparator = expression(`([-._:@+]|--)`)
regSeparator = expression(`([-._:@+]|--|__)`)

regComponent = group(
oneOrMore(regAlphanum),
Expand Down

0 comments on commit 318aad0

Please sign in to comment.