Skip to content

Commit

Permalink
Bugfix: invalid attribute values gave out-of-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed May 14, 2015
1 parent d0c4cdf commit b4161f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions html/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ func EscapeAttrVal(buf *[]byte, orig, b []byte) []byte {
return orig
}

n := len(b) + 2
var quote byte
var escapedQuote []byte
if doubles > singles {
n += singles * 4
quote = '\''
escapedQuote = singleQuoteEntityBytes
} else {
n += doubles * 4
quote = '"'
escapedQuote = doubleQuoteEntityBytes
}
if len(b)+2 > cap(*buf) {
*buf = make([]byte, 0, len(b)+2) // maximum size, not actual size
if n > cap(*buf) {
*buf = make([]byte, 0, n) // maximum size, not actual size
}
t := (*buf)[:len(b)+2] // maximum size, not actual size
t := (*buf)[:n] // maximum size, not actual size
t[0] = quote
j := 1
start := 0
Expand Down

0 comments on commit b4161f8

Please sign in to comment.