-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(encoding/gxml): XML special character encoding error (#3740)
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,3 +206,28 @@ func TestErrCase(t *testing.T) { | |
} | ||
}) | ||
} | ||
|
||
func Test_Issue3716(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
xml = `<Person><Bio>I am a software developer & I love coding.</Bio><Email>[email protected]</Email><Name><>&'"AAA</Name></Person>` | ||
m = map[string]interface{}{ | ||
"Person": map[string]interface{}{ | ||
"Name": "<>&'\"AAA", | ||
"Email": "[email protected]", | ||
"Bio": "I am a software developer & I love coding.", | ||
}, | ||
} | ||
) | ||
gxml.XMLEscapeChars(true) | ||
defer gxml.XMLEscapeChars(false) | ||
|
||
xb, err := gxml.Encode(m) | ||
t.AssertNil(err) | ||
t.Assert(string(xb), xml) | ||
|
||
dm, err := gxml.Decode(xb) | ||
t.AssertNil(err) | ||
t.Assert(dm, m) | ||
}) | ||
} |