Skip to content

Commit

Permalink
allow colons in http header values
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubrock authored and mem committed Jan 24, 2023
1 parent 9d183e7 commit db8b550
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/pb/synthetic_monitoring/checks_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ func (s *PingSettings) Validate() error {

func (s *HttpSettings) Validate() error {
for _, h := range s.Headers {
fields := strings.Split(h, ":")
if len(fields) != 2 {
fields := strings.SplitN(h, ":", 2)
if len(fields) < 2 {
return ErrInvalidHttpHeaders
}

Expand Down Expand Up @@ -505,8 +505,8 @@ func (s *HttpSettings) Validate() error {
}

for _, h := range s.ProxyConnectHeaders {
fields := strings.Split(h, ":")
if len(fields) != 2 {
fields := strings.SplitN(h, ":", 2)
if len(fields) < 2 {
return ErrInvalidProxyConnectHeaders
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/pb/synthetic_monitoring/checks_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,12 @@ func TestHttpSettingsValidate(t *testing.T) {
},
expectError: true,
},
"multiple colons": {
input: HttpSettings{
Headers: []string{"origin:https://www.grafana.com"},
},
expectError: false,
},
"invalid name": {
input: HttpSettings{
Headers: []string{"hea;der: value"},
Expand Down

0 comments on commit db8b550

Please sign in to comment.