1
0
mirror of https://github.com/golang/go synced 2024-10-03 00:21:22 -06:00

encoding/pem: ignore spaces and tabs at the end of header lines.

Fixes #3502.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6011046
This commit is contained in:
Adam Langley 2012-04-12 12:33:52 -04:00
parent 4945fc8e40
commit 55af51d5c0
2 changed files with 16 additions and 15 deletions

View File

@ -28,9 +28,10 @@ type Block struct {
}
// getLine results the first \r\n or \n delineated line from the given byte
// array. The line does not include the \r\n or \n. The remainder of the byte
// array (also not including the new line bytes) is also returned and this will
// always be smaller than the original argument.
// array. The line does not include trailing whitespace or the trailing new
// line bytes. The remainder of the byte array (also not including the new line
// bytes) is also returned and this will always be smaller than the original
// argument.
func getLine(data []byte) (line, rest []byte) {
i := bytes.Index(data, []byte{'\n'})
var j int
@ -43,7 +44,7 @@ func getLine(data []byte) (line, rest []byte) {
i--
}
}
return data[0:i], data[j:]
return bytes.TrimRight(data[0:i], " \t"), data[j:]
}
// removeWhitespace returns a copy of its input with all spaces, tab and