Commit 4410934c authored by Artyom Pervukhin's avatar Artyom Pervukhin Committed by Ian Lance Taylor

encoding/xml: fix valid character range

Section 2.2 of the referenced spec http://www.xml.com/axml/testaxml.htm
defines 0xD7FF as a (sub)range boundary, not 0xDF77.

Fixes #25172

Change-Id: Ic5a3328cd46ef6474b8e93c4a343dcfba0e6511f
Reviewed-on: https://go-review.googlesource.com/109495
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 46047e64
......@@ -1140,7 +1140,7 @@ func isInCharacterRange(r rune) (inrange bool) {
return r == 0x09 ||
r == 0x0A ||
r == 0x0D ||
r >= 0x20 && r <= 0xDF77 ||
r >= 0x20 && r <= 0xD7FF ||
r >= 0xE000 && r <= 0xFFFD ||
r >= 0x10000 && r <= 0x10FFFF
}
......
......@@ -650,6 +650,20 @@ func TestDisallowedCharacters(t *testing.T) {
}
}
func TestIsInCharacterRange(t *testing.T) {
invalid := []rune{
utf8.MaxRune + 1,
0xD800, // surrogate min
0xDFFF, // surrogate max
-1,
}
for _, r := range invalid {
if isInCharacterRange(r) {
t.Errorf("rune %U considered valid", r)
}
}
}
var procInstTests = []struct {
input string
expect [2]string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment