mirror of
https://github.com/golang/go
synced 2024-11-20 01:04:40 -07: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:
parent
4945fc8e40
commit
55af51d5c0
@ -28,9 +28,10 @@ type Block struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getLine results the first \r\n or \n delineated line from the given byte
|
// 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. The line does not include trailing whitespace or the trailing new
|
||||||
// array (also not including the new line bytes) is also returned and this will
|
// line bytes. The remainder of the byte array (also not including the new line
|
||||||
// always be smaller than the original argument.
|
// bytes) is also returned and this will always be smaller than the original
|
||||||
|
// argument.
|
||||||
func getLine(data []byte) (line, rest []byte) {
|
func getLine(data []byte) (line, rest []byte) {
|
||||||
i := bytes.Index(data, []byte{'\n'})
|
i := bytes.Index(data, []byte{'\n'})
|
||||||
var j int
|
var j int
|
||||||
@ -43,7 +44,7 @@ func getLine(data []byte) (line, rest []byte) {
|
|||||||
i--
|
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
|
// removeWhitespace returns a copy of its input with all spaces, tab and
|
||||||
|
Loading…
Reference in New Issue
Block a user