Skip to content

Same key multiple times using encode function in the net/url package #69129

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

Closed
danysz opened this issue Aug 29, 2024 · 3 comments
Closed

Same key multiple times using encode function in the net/url package #69129

danysz opened this issue Aug 29, 2024 · 3 comments

Comments

@danysz
Copy link

danysz commented Aug 29, 2024

What version of Go are you using (go version)?

$ go version
go version go1.23.0 darwin/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/danysz/Library/Caches/go-build'
GOENV='/Users/danysz/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/danysz/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/danysz/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/danysz/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/p2/s5fllbzj1f5cp6jjk8_3w6l80000gn/T/go-build441744932=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOROOT/bin/go version: go version go1.23.0 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.23.0
uname -v: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6020
ProductName:		macOS
ProductVersion:		14.6.1
BuildVersion:		23G93
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

package main

import (
"fmt"
"net/url"
)

func main() {
params := url.Values{}
// Add a parameter with multiple values

params.Add("key1", "val1-1")
params.Add("key2", "val2-1")

params.Add("key3", "val3-1")
params.Add("key3", "val3-2")
params.Add("key3", "val3-3")

params.Add("key1", "val1-2")
params.Add("key2", "val2-2")

fmt.Println(params.Encode())

}

What did you expect to see?

key1=val1-1,val1-2&key2=val2-1,val2-2&key3=val3-1,val3-2,val3-3

What did you see instead?

key1=val1-1&key1=val1-2&key2=val2-1&key2=val2-2&key3=val3-1&key3=val3-2&key3=val3-3

@danysz danysz changed the title Same key multiple times in ecode in the url Same key multiple times using encode function in the net/url package Aug 29, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/609299 mentions this issue: net/url: fixes #69129

@seankhliao
Copy link
Member

separation by commas in not supported by any standard.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants