Merge pull request #1434 from aaronlehmann/uppercase-in-hostname
Allow uppercase characters in hostnamesmaster
						commit
						ee3b7ff76f
					
				| 
						 | 
					@ -6,7 +6,7 @@
 | 
				
			||||||
// 	reference                       := repository [ ":" tag ] [ "@" digest ]
 | 
					// 	reference                       := repository [ ":" tag ] [ "@" digest ]
 | 
				
			||||||
//	name                            := [hostname '/'] component ['/' component]*
 | 
					//	name                            := [hostname '/'] component ['/' component]*
 | 
				
			||||||
//	hostname                        := hostcomponent ['.' hostcomponent]* [':' port-number]
 | 
					//	hostname                        := hostcomponent ['.' hostcomponent]* [':' port-number]
 | 
				
			||||||
//	hostcomponent                   := /([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])/
 | 
					//	hostcomponent                   := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
 | 
				
			||||||
//	port-number                     := /[0-9]+/
 | 
					//	port-number                     := /[0-9]+/
 | 
				
			||||||
//	component                       := alpha-numeric [separator alpha-numeric]*
 | 
					//	component                       := alpha-numeric [separator alpha-numeric]*
 | 
				
			||||||
// 	alpha-numeric                   := /[a-z0-9]+/
 | 
					// 	alpha-numeric                   := /[a-z0-9]+/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ var (
 | 
				
			||||||
	// hostnameComponentRegexp restricts the registry hostname component of a
 | 
						// hostnameComponentRegexp restricts the registry hostname component of a
 | 
				
			||||||
	// repository name to start with a component as defined by hostnameRegexp
 | 
						// repository name to start with a component as defined by hostnameRegexp
 | 
				
			||||||
	// and followed by an optional port.
 | 
						// and followed by an optional port.
 | 
				
			||||||
	hostnameComponentRegexp = match(`(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])`)
 | 
						hostnameComponentRegexp = match(`(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])`)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// hostnameRegexp defines the structure of potential hostname components
 | 
						// hostnameRegexp defines the structure of potential hostname components
 | 
				
			||||||
	// that may be part of image names. This is purposely a subset of what is
 | 
						// that may be part of image names. This is purposely a subset of what is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,6 +111,10 @@ func TestHostRegexp(t *testing.T) {
 | 
				
			||||||
			input: "xn--n3h.com", // ☃.com in punycode
 | 
								input: "xn--n3h.com", // ☃.com in punycode
 | 
				
			||||||
			match: true,
 | 
								match: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								input: "Asdf.com", // uppercase character
 | 
				
			||||||
 | 
								match: true,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	r := regexp.MustCompile(`^` + hostnameRegexp.String() + `$`)
 | 
						r := regexp.MustCompile(`^` + hostnameRegexp.String() + `$`)
 | 
				
			||||||
	for i := range hostcases {
 | 
						for i := range hostcases {
 | 
				
			||||||
| 
						 | 
					@ -399,6 +403,14 @@ func TestFullNameRegexp(t *testing.T) {
 | 
				
			||||||
			match: true,
 | 
								match: true,
 | 
				
			||||||
			subs:  []string{"registry.io", "foo/project--id.module--name.ver---sion--name"},
 | 
								subs:  []string{"registry.io", "foo/project--id.module--name.ver---sion--name"},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								input: "Asdf.com/foo/bar", // uppercase character in hostname
 | 
				
			||||||
 | 
								match: true,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								input: "Foo/FarB", // uppercase characters in remote name
 | 
				
			||||||
 | 
								match: false,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i := range testcases {
 | 
						for i := range testcases {
 | 
				
			||||||
		checkRegexp(t, anchoredNameRegexp, testcases[i])
 | 
							checkRegexp(t, anchoredNameRegexp, testcases[i])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue