Skip to content

Commit

Permalink
Allow trailing dots in host names
Browse files Browse the repository at this point in the history
When generating the pattern for a map entry to match a route host and path,
make sure the pattern allows for a trailing dot in the host name.

RFC 7230, section 5.4, specifies that the HTTP "host" header value includes
the URI host as defined in RFC 3986, section 3.2.2, which indicates that a
trailing dot is permitted.

Note that the same treatment is not required for entries in the certificate
map because RFC 3546, section 3.1, specifies that the server name in a TLS
client hello message does *not* have a trailing dot.

This commit fixes bug 1878319.

https://bugzilla.redhat.com/show_bug.cgi?id=1878319

* pkg/router/template/util/util.go (GenerateRouteRegexp): Match an optional
trailing dot in the host name.
* pkg/router/template/util/util_test.go (TestGenerateRouteRegexp): Verify
that the trailing dot is permitted.
  • Loading branch information
Miciah committed Sep 11, 2020
1 parent 4a6284e commit 43b87b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/router/template/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func GenerateRouteRegexp(hostname, path string, wildcard bool) string {
hostRE = fmt.Sprintf(`[^\.]*%s`, subdomainRE)
}
}
hostRE = fmt.Sprintf("%s\\.?", hostRE)

portRE := "(:[0-9]+)?"

Expand Down
5 changes: 5 additions & 0 deletions pkg/router/template/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ func TestGenerateRouteRegexp(t *testing.T) {
wildcard: false,
match: []string{
"example.com",
"example.com.",
"example.com:80",
"example.com.:80",
"example.com/",
"example.com./",
"example.com./sub",
"example.com/sub",
"example.com./sub/",
"example.com/sub/",
},
nomatch: []string{"other.com"},
Expand Down

0 comments on commit 43b87b3

Please sign in to comment.