mirror of
https://github.com/golang/go
synced 2024-11-22 02:14:40 -07:00
template: fix quote-handling with formatters
Fixes issue #1896. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/4539093
This commit is contained in:
parent
0f4510b370
commit
e11d94fcd7
@ -395,11 +395,12 @@ func words(buf []byte) []string {
|
||||
} else {
|
||||
i++
|
||||
}
|
||||
} else {
|
||||
}
|
||||
// Even with quotes, break on whitespace only. This will
|
||||
// work with e.g. {""|} and catch quoting mistakes properly.
|
||||
for i < len(buf) && !white(buf[i]) {
|
||||
i++
|
||||
}
|
||||
}
|
||||
s = append(s, string(buf[start:i]))
|
||||
}
|
||||
return s
|
||||
|
@ -762,6 +762,10 @@ var formatterTests = []Test{
|
||||
in: `{"%.02f 0x%02X" 1.1 10|printf}`,
|
||||
out: "1.10 0x0A",
|
||||
},
|
||||
{
|
||||
in: `{""|}{""||}{""|printf}`, // Issue #1896.
|
||||
out: "",
|
||||
},
|
||||
}
|
||||
|
||||
func TestFormatters(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user