Go version
go version go1.21.11 linux/amd64
Output of go env in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.11'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3671854511=/tmp/go-build -gno-record-gcc-switches'
What did you do?
https://go.dev/play/p/FRIvYTU13fC
What did you see happen?
encoding/xml does not reject XML with the following violations of namespace constraints:
-
Binding a URL other than http://www.w3.org/XML/1998/namespace to the prefix xml:
<!-- Ill-formed: cannot bind prefix xml: to a URL other than
http://www.w3.org/XML/1998/namespace -->
<a xmlns:xml="https://example.com"/>
-
Binding http://www.w3.org/XML/1998/namespace to a prefix other than xml:
<!-- Ill-formed: cannot bind a prefix other than xml: to
http://www.w3.org/XML/1998/namespace -->
<a xmlns:a="http://www.w3.org/XML/1998/namespace"/>
-
Declaring http://www.w3.org/XML/1998/namespace as the default namespace:
<!-- Ill-formed: cannot declare http://www.w3.org/XML/1998/namespace
as default namespace -->
<a xmlns="http://www.w3.org/XML/1998/namespace"/>
-
Declaring the prefix xmlns, whether it is with the correct URL http://www.w3.org/2000/xmlns/
<!-- Ill-formed: cannot declare xmlns: prefix -->
<a xmlns:xmlns="http://www.w3.org/2000/xmlns/"/>
or with any other URL:
<!-- Ill-formed: cannot declare xmlns: prefix -->
<a xmlns:xmlns="https://example.com"/>
-
Binding the URL http://www.w3.org/2000/xmlns/ to any prefix:
<!-- Ill-formed: cannot bind a prefix to
http://www.w3.org/2000/xmlns/ -->
<a xmlns:a="http://www.w3.org/2000/xmlns/"/>
-
Declaring http://www.w3.org/2000/xmlns/ as the default namespace:
<!-- Ill-formed: cannot declare http://www.w3.org/2000/xmlns/
as default namespace -->
<a xmlns="http://www.w3.org/2000/xmlns/"/>
-
Using xmlns as the prefix for an element:
<!-- Ill-formed: xmlns: cannot be the prefix of an element name -->
<xmlns:a/>
-
Undeclaring a namespace prefix by binding the empty string
<!-- Ill-formed: cannot bind a namespace to the empty string -->
<a xmlns:a=""/>
What did you expect to see?
encoding/xml should reject these violations, whether Token or RawToken are used. Detecting these violations can be done without maintaining any additional state and without resolving prefixes to namespace URLs.
Go version
go version go1.21.11 linux/amd64Output of
go envin your module/workspace:What did you do?
https://go.dev/play/p/FRIvYTU13fC
What did you see happen?
encoding/xmldoes not reject XML with the following violations of namespace constraints:Binding a URL other than
http://www.w3.org/XML/1998/namespaceto the prefixxml:Binding
http://www.w3.org/XML/1998/namespaceto a prefix other thanxml:Declaring
http://www.w3.org/XML/1998/namespaceas the default namespace:Declaring the prefix
xmlns, whether it is with the correct URLhttp://www.w3.org/2000/xmlns/or with any other URL:
Binding the URL
http://www.w3.org/2000/xmlns/to any prefix:Declaring
http://www.w3.org/2000/xmlns/as the default namespace:Using
xmlnsas the prefix for an element:Undeclaring a namespace prefix by binding the empty string
What did you expect to see?
encoding/xmlshould reject these violations, whetherTokenorRawTokenare used. Detecting these violations can be done without maintaining any additional state and without resolving prefixes to namespace URLs.