-
Notifications
You must be signed in to change notification settings - Fork 542
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
ImageName should be able to parse image names with IPv6 address literals #2603
Changes from 3 commits
6949be6
16e07c5
302b2b7
dfa0486
b5dbf12
b9515f5
708dff2
7a60b29
70b6723
44bbcdb
81fed6a
4a874ff
51a80d3
ed4154b
6cd411a
ed0cc80
c162993
d38642f
0db5cce
005241e
13e01f8
d828cd2
da8eb46
c142522
ef6583e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -275,7 +275,7 @@ private void doValidate() { | |||||||
String user = inferUser(); | ||||||||
String image = user != null ? repository.substring(user.length() + 1) : repository; | ||||||||
Object[] checks = new Object[] { | ||||||||
"registry", DOMAIN_REGEXP, registry, | ||||||||
"registry", REGISTRY_REGEXP, registry, | ||||||||
"image", IMAGE_NAME_REGEXP, image, | ||||||||
"user", NAME_COMP_REGEXP, user, | ||||||||
"tag", TAG_REGEXP, tag, | ||||||||
|
@@ -323,7 +323,7 @@ private void parseComponentsBeforeTag(String rest) { | |||||||
} | ||||||||
|
||||||||
private boolean isValidDomain(String str) { | ||||||||
return containsPeriodOrColon(str) && DOMAIN_REGEXP.matcher(str).matches(); | ||||||||
return containsPeriodOrColon(str) && REGISTRY_REGEXP.matcher(str).matches(); | ||||||||
} | ||||||||
|
||||||||
private boolean isRegistryValidPathComponent() { | ||||||||
|
@@ -343,6 +343,9 @@ private boolean isRegistryValidPathComponent() { | |||||||
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L25 | ||||||||
private static final String DOMAIN_COMPONENT_REGEXP = "(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])"; | ||||||||
|
||||||||
//https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L91 | ||||||||
private static final String IPV6_ADDRESS_REGEXP = "\\[[a-fA-F0-9:]+\\]"; | ||||||||
|
||||||||
// ========================================================== | ||||||||
|
||||||||
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L18 | ||||||||
|
@@ -351,8 +354,13 @@ private boolean isRegistryValidPathComponent() { | |||||||
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L53 | ||||||||
private static final Pattern IMAGE_NAME_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP + "(?:(?:/" + NAME_COMPONENT_REGEXP + ")+)?"); | ||||||||
|
||||||||
// https://github.com/distribution/reference/blob/8507c7fcf0da9f570540c958ea7b972c30eeaeca/regexp.go#L65 | ||||||||
private static final String OPTIONAL_PORT_REGEXP = "(?::[0-9]+)?"; | ||||||||
private static final String DOMAIN_NAME_REGEXP = DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*"; | ||||||||
private static final String REGISTRY_HOST_REGEXP = "^(?:" + IPV6_ADDRESS_REGEXP + "|" + DOMAIN_NAME_REGEXP + ")"; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L31 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please update the comment pointing to regexp source too? |
||||||||
private static final Pattern DOMAIN_REGEXP = Pattern.compile("^" + DOMAIN_COMPONENT_REGEXP + "(?:\\." + DOMAIN_COMPONENT_REGEXP + ")*(?::[0-9]+)?$"); | ||||||||
private static final Pattern REGISTRY_REGEXP = Pattern.compile(REGISTRY_HOST_REGEXP + OPTIONAL_PORT_REGEXP); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
// https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L37 | ||||||||
private static final Pattern TAG_REGEXP = Pattern.compile("^[\\w][\\w.-]{0,127}$"); | ||||||||
|
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.