mirror of
https://github.com/golang/go
synced 2024-11-25 06:07:58 -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,10 +395,11 @@ func words(buf []byte) []string {
|
|||||||
} else {
|
} else {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for i < len(buf) && !white(buf[i]) {
|
// Even with quotes, break on whitespace only. This will
|
||||||
i++
|
// work with e.g. {""|} and catch quoting mistakes properly.
|
||||||
}
|
for i < len(buf) && !white(buf[i]) {
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
s = append(s, string(buf[start:i]))
|
s = append(s, string(buf[start:i]))
|
||||||
}
|
}
|
||||||
|
@ -762,6 +762,10 @@ var formatterTests = []Test{
|
|||||||
in: `{"%.02f 0x%02X" 1.1 10|printf}`,
|
in: `{"%.02f 0x%02X" 1.1 10|printf}`,
|
||||||
out: "1.10 0x0A",
|
out: "1.10 0x0A",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: `{""|}{""||}{""|printf}`, // Issue #1896.
|
||||||
|
out: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFormatters(t *testing.T) {
|
func TestFormatters(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user