Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang.org/x/net 0.8.0 => 0.9.0, cookies fix #56

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go 1.20
require (
github.com/s0rg/compflag v1.1.0
github.com/s0rg/set v1.0.0
golang.org/x/net v0.8.0
golang.org/x/net v0.9.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ github.com/s0rg/compflag v1.1.0 h1:xhCUPLy+5Ue/Q9I/nIcLti2Ul6P42JYx4UvtYoDXmlQ=
github.com/s0rg/compflag v1.1.0/go.mod h1:XMntVpc3+jpmBe0s8xo4w9swH8T9ARGkMC9HFiDRoUw=
github.com/s0rg/set v1.0.0 h1:/MAmKEQ3Ltodli7/+e8iSTKNwhzmvxkmSDZO8BMTFbE=
github.com/s0rg/set v1.0.0/go.mod h1:n2TtovR+7TrBIztw+6muV9ZLRuDIimsd8YyTN+QBmHQ=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
15 changes: 2 additions & 13 deletions pkg/client/cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package client
import (
"log"
"net/http"
"net/url"
"strings"
)

Expand Down Expand Up @@ -37,25 +36,15 @@ func parseOne(raw string) (rv *http.Cookie, ok bool) {
return
}

var name, value string
var name string

if name = strings.TrimSpace(pair[0]); name == "" {
return
}

value = strings.TrimSpace(pair[1])

if value != "" {
var err error

if value, err = url.QueryUnescape(value); err != nil {
return
}
}

rv = &http.Cookie{
Name: name,
Value: value,
Value: strings.TrimSpace(pair[1]),
}

return rv, true
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Test_prepareCookies(t *testing.T) {
[]string{"NAME1=VALUE1;NAME2=ENCODED%20VALUE;", "NAME3=VALUE3"},
[]*http.Cookie{
{Name: "NAME1", Value: "VALUE1"},
{Name: "NAME2", Value: "ENCODED VALUE"},
{Name: "NAME2", Value: "ENCODED%20VALUE"},
{Name: "NAME3", Value: "VALUE3"},
},
},
Expand All @@ -42,7 +42,7 @@ func Test_prepareCookies(t *testing.T) {
got := prepareCookies(tt.args)

if len(got) != len(tt.want) {
t.Errorf("prepareCookies() invalid rusult count for: %v", tt.want)
t.Errorf("prepareCookies() invalid result count for: %v", tt.want)
}

if len(got) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const (
func TestHTTPGetOK(t *testing.T) {
t.Parallel()

c := New(ua, 1, false, []string{"FOO: BAR"}, []string{"NAME=ENCODED%20VAL"})
c := New(ua, 1, false, []string{"FOO: BAR"}, []string{"NAME=VALUE"})

const (
body = "test-body"
cookie = "ENCODED VAL"
cookie = "VALUE"
)

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down