]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "encoding/xml: disallow empty namespace when prefix is set"
authorIan Lance Taylor <iant@golang.org>
Tue, 29 Nov 2022 19:37:10 +0000 (19:37 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 29 Nov 2022 22:25:08 +0000 (22:25 +0000)
This reverts CL 105636.

Reason for revert: Fails with existing XML data.  At this stage in the release cycle we should revert, and try again next time with some way to support existing XML.

For #8068

Change-Id: Ia84cbf3a84878ac7190f72998545dee22c36c45e
Reviewed-on: https://go-review.googlesource.com/c/go/+/453996
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/encoding/xml/xml.go
src/encoding/xml/xml_test.go

index 9df556a1369800bce077b841905f7f3838a8eb60..1f3084e5ca83a016d7eb8c278d9fb80e9bbc9da7 100644 (file)
@@ -302,10 +302,6 @@ func (d *Decoder) Token() (Token, error) {
                // the translations first.
                for _, a := range t1.Attr {
                        if a.Name.Space == xmlnsPrefix {
-                               if a.Value == "" {
-                                       d.err = d.syntaxError("empty namespace with prefix")
-                                       return nil, d.err
-                               }
                                v, ok := d.ns[a.Name.Local]
                                d.pushNs(a.Name.Local, v, ok)
                                d.ns[a.Name.Local] = a.Value
index df2581252106c4d2b915228e877b1c28d3593ccb..30fb94da6df16fc3d92c49184ad514a586c6b28e 100644 (file)
@@ -916,35 +916,6 @@ func TestIssue5880(t *testing.T) {
        }
 }
 
-func TestIssue8068(t *testing.T) {
-       emptyError := SyntaxError{}
-       noError := emptyError.Error()
-       testCases := []struct {
-               s       string
-               wantErr SyntaxError
-       }{
-               {`<foo xmlns:bar="a"></foo>`, SyntaxError{}},
-               {`<foo xmlns:bar=""></foo>`, SyntaxError{Msg: "empty namespace with prefix", Line: 1}},
-               {`<foo xmlns:="a"></foo>`, SyntaxError{}},
-               {`<foo xmlns:""></foo>`, SyntaxError{Msg: "attribute name without = in element", Line: 1}},
-               {`<foo xmlns:"a"></foo>`, SyntaxError{Msg: "attribute name without = in element", Line: 1}},
-       }
-       var dest string
-       for _, tc := range testCases {
-               if got, want := Unmarshal([]byte(tc.s), &dest), tc.wantErr.Error(); got == nil {
-                       if want != noError {
-                               t.Errorf("%q: got nil, want %s", tc.s, want)
-                       }
-               } else {
-                       if want == "" {
-                               t.Errorf("%q: got %s, want nil", tc.s, got)
-                       } else if got.Error() != want {
-                               t.Errorf("%q: got %s, want %s", tc.s, got, want)
-                       }
-               }
-       }
-}
-
 func TestIssue8535(t *testing.T) {
 
        type ExampleConflict struct {