Commit e11d94fc authored by Gustavo Niemeyer's avatar Gustavo Niemeyer

template: fix quote-handling with formatters

Fixes issue #1896.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4539093
parent 0f4510b3
......@@ -395,10 +395,11 @@ func words(buf []byte) []string {
} else {
i++
}
} else {
for i < len(buf) && !white(buf[i]) {
i++
}
}
// 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]))
}
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment