Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
a08ab0c0
Commit
a08ab0c0
authored
Aug 14, 2019
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix slice bounds when getting key of address (fixes #2706)
parent
28e1f7c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
caddyhttp/httpserver/plugin.go
caddyhttp/httpserver/plugin.go
+10
-9
caddyhttp/httpserver/plugin_test.go
caddyhttp/httpserver/plugin_test.go
+20
-4
No files found.
caddyhttp/httpserver/plugin.go
View file @
a08ab0c0
...
...
@@ -490,11 +490,10 @@ func (a Address) Key() string {
if
a
.
Host
!=
""
{
res
+=
a
.
Host
}
if
a
.
Port
!=
""
{
if
strings
.
HasPrefix
(
a
.
Original
[
len
(
res
)
:
],
":"
+
a
.
Port
)
{
// insert port only if the original has its own explicit port
res
+=
":"
+
a
.
Port
}
// insert port only if the original has its own explicit port
if
a
.
Port
!=
""
&&
len
(
a
.
Original
)
>=
len
(
res
)
&&
strings
.
HasPrefix
(
a
.
Original
[
len
(
res
)
:
],
":"
+
a
.
Port
)
{
res
+=
":"
+
a
.
Port
}
if
a
.
Path
!=
""
{
res
+=
a
.
Path
...
...
@@ -553,10 +552,12 @@ func standardizeAddress(str string) (Address, error) {
// standardize http and https ports to their respective port numbers
// (this behavior changed in Go 1.12.8)
if
port
==
httpPort
{
u
.
Scheme
=
"http"
}
else
if
port
==
httpsPort
{
u
.
Scheme
=
"https"
if
u
.
Scheme
==
""
{
if
port
==
httpPort
{
u
.
Scheme
=
"http"
}
else
if
port
==
httpsPort
{
u
.
Scheme
=
"https"
}
}
return
Address
{
Original
:
input
,
Scheme
:
u
.
Scheme
,
Host
:
host
,
Port
:
port
,
Path
:
u
.
Path
},
nil
...
...
caddyhttp/httpserver/plugin_test.go
View file @
a08ab0c0
...
...
@@ -43,8 +43,8 @@ func TestStandardizeAddress(t *testing.T) {
{
`:`
,
""
,
""
,
""
,
""
,
false
},
{
`localhost:http`
,
"http"
,
"localhost"
,
"80"
,
""
,
false
},
{
`localhost:https`
,
"https"
,
"localhost"
,
"443"
,
""
,
false
},
{
`:http`
,
"http"
,
""
,
"80"
,
""
,
false
},
{
`:https`
,
"https"
,
""
,
"443"
,
""
,
false
},
{
`:http`
,
"http"
,
""
,
"80"
,
""
,
false
},
// as of Go 1.12.8, service name in port is no longer supported
{
`:https`
,
"https"
,
""
,
"443"
,
""
,
false
},
// as of Go 1.12.8, service name in port is no longer supported
{
`http://localhost:https`
,
""
,
""
,
""
,
""
,
true
},
// conflict
{
`http://localhost:http`
,
"http"
,
"localhost"
,
"80"
,
""
,
false
},
// repeated scheme -- test adjusted for Go 1.12.8 (expect no error)
{
`http://localhost:443`
,
""
,
""
,
""
,
""
,
true
},
// not conventional
...
...
@@ -212,6 +212,10 @@ func TestKeyNormalization(t *testing.T) {
orig
string
res
string
}{
{
orig
:
"http://host:1234/path"
,
res
:
"http://host:1234/path"
,
},
{
orig
:
"HTTP://A/ABCDEF"
,
res
:
"http://a/ABCDEF"
,
...
...
@@ -221,8 +225,20 @@ func TestKeyNormalization(t *testing.T) {
res
:
"a/ABCDEF"
,
},
{
orig
:
"A:2015/Port"
,
res
:
"a:2015/Port"
,
orig
:
"A:2015/Path"
,
res
:
"a:2015/Path"
,
},
{
orig
:
":80"
,
res
:
"http://"
,
},
{
orig
:
":443"
,
res
:
"https://"
,
},
{
orig
:
":1234"
,
res
:
":1234"
,
},
}
for
_
,
item
:=
range
caseSensitiveData
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment