diff --git a/_test/extra.txt b/_test/extra.txt index 6018f15..332c06d 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -447,3 +447,12 @@ x

x

"

//= = = = = = = = = = = = = = = = = = = = = = = =// + + +32: Hex character entities must be limited to 6 characters +//- - - - - - - - -// +A +//- - - - - - - - -// +

A

+//= = = = = = = = = = = = = = = = = = = = = = = =// + diff --git a/renderer/html/html.go b/renderer/html/html.go index 90221b0..5699150 100644 --- a/renderer/html/html.go +++ b/renderer/html/html.go @@ -734,7 +734,7 @@ func (d *defaultWriter) Write(writer util.BufWriter, source []byte) { if nnext < limit && nc == 'x' || nc == 'X' { start := nnext + 1 i, ok = util.ReadWhile(source, [2]int{start, limit}, util.IsHexDecimal) - if ok && i < limit && source[i] == ';' { + if ok && i < limit && source[i] == ';' && i-start < 7 { v, _ := strconv.ParseUint(util.BytesToReadOnlyString(source[start:i]), 16, 32) d.RawWrite(writer, source[n:pos]) n = i + 1 @@ -745,7 +745,7 @@ func (d *defaultWriter) Write(writer util.BufWriter, source []byte) { } else if nc >= '0' && nc <= '9' { start := nnext i, ok = util.ReadWhile(source, [2]int{start, limit}, util.IsNumeric) - if ok && i < limit && i-start < 8 && source[i] == ';' { + if ok && i < limit && i-start < 8 && source[i] == ';' && i-start < 7 { v, _ := strconv.ParseUint(util.BytesToReadOnlyString(source[start:i]), 0, 32) d.RawWrite(writer, source[n:pos]) n = i + 1