Pick up name regexp change in distribution to allow matching of hostnames as a valid component of a repository.
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
| ... | ... |
@@ -36,7 +36,7 @@ clone git github.com/hashicorp/consul v0.5.2 |
| 36 | 36 |
clone git github.com/boltdb/bolt v1.0 |
| 37 | 37 |
|
| 38 | 38 |
# get graph and distribution packages |
| 39 |
-clone git github.com/docker/distribution ec87e9b6971d831f0eff752ddb54fb64693e51cd # docker/1.8 branch |
|
| 39 |
+clone git github.com/docker/distribution 20c4b7a1805a52753dfd593ee1cc35558722a0ce # docker/1.9 branch |
|
| 40 | 40 |
clone git github.com/vbatts/tar-split v0.9.10 |
| 41 | 41 |
|
| 42 | 42 |
clone git github.com/docker/notary ac05822d7d71ef077df3fc24f506672282a1feea |
| ... | ... |
@@ -767,6 +767,9 @@ func TestValidRemoteName(t *testing.T) {
|
| 767 | 767 |
// Allow embedded hyphens. |
| 768 | 768 |
"docker-rules/docker", |
| 769 | 769 |
|
| 770 |
+ // Allow multiple hyphens as well. |
|
| 771 |
+ "docker---rules/docker", |
|
| 772 |
+ |
|
| 770 | 773 |
//Username doc and image name docker being tested. |
| 771 | 774 |
"doc/docker", |
| 772 | 775 |
|
| ... | ... |
@@ -800,8 +803,11 @@ func TestValidRemoteName(t *testing.T) {
|
| 800 | 800 |
|
| 801 | 801 |
"_docker/_docker", |
| 802 | 802 |
|
| 803 |
- // Disallow consecutive hyphens. |
|
| 804 |
- "dock--er/docker", |
|
| 803 |
+ // Disallow consecutive underscores and periods. |
|
| 804 |
+ "dock__er/docker", |
|
| 805 |
+ "dock..er/docker", |
|
| 806 |
+ "dock_.er/docker", |
|
| 807 |
+ "dock-.er/docker", |
|
| 805 | 808 |
|
| 806 | 809 |
// No repository. |
| 807 | 810 |
"docker/", |
| ... | ... |
@@ -15,10 +15,23 @@ const ( |
| 15 | 15 |
RepositoryNameTotalLengthMax = 255 |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 |
+// domainLabelRegexp represents the following RFC-2396 BNF construct: |
|
| 19 |
+// domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum |
|
| 20 |
+var domainLabelRegexp = regexp.MustCompile(`[a-z0-9](?:-*[a-z0-9])*`) |
|
| 21 |
+ |
|
| 18 | 22 |
// RepositoryNameComponentRegexp restricts registry path component names to |
| 19 |
-// start with at least one letter or number, with following parts able to |
|
| 20 |
-// be separated by one period, dash or underscore. |
|
| 21 |
-var RepositoryNameComponentRegexp = regexp.MustCompile(`[a-z0-9]+(?:[._-][a-z0-9]+)*`) |
|
| 23 |
+// the allow valid hostnames according to: https://www.ietf.org/rfc/rfc2396.txt |
|
| 24 |
+// with the following differences: |
|
| 25 |
+// 1) It DOES NOT allow for fully-qualified domain names, which include a |
|
| 26 |
+// trailing '.', e.g. "google.com." |
|
| 27 |
+// 2) It DOES NOT restrict 'top-level' domain labels to start with just alpha |
|
| 28 |
+// characters. |
|
| 29 |
+// 3) It DOES allow for underscores to appear in the same situations as dots. |
|
| 30 |
+// |
|
| 31 |
+// RFC-2396 uses the BNF construct: |
|
| 32 |
+// hostname = *( domainlabel "." ) toplabel [ "." ] |
|
| 33 |
+var RepositoryNameComponentRegexp = regexp.MustCompile( |
|
| 34 |
+ domainLabelRegexp.String() + `(?:[._]` + domainLabelRegexp.String() + `)*`) |
|
| 22 | 35 |
|
| 23 | 36 |
// RepositoryNameComponentAnchoredRegexp is the version of |
| 24 | 37 |
// RepositoryNameComponentRegexp which must completely match the content |