Skip to content

Commit db26491

Browse files
committed
fix: encode DEL (0x7f) control character (go-logfmt#17)
Fixes: 3f5ba89
1 parent 3948912 commit db26491

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

encode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func writeKey(w io.Writer, key interface{}) error {
170170
// functions it causes them to remove invalid key runes from strings or byte
171171
// slices respectively.
172172
func keyRuneFilter(r rune) rune {
173-
if r <= ' ' || r == '=' || r == '"' || r == 0x7f || r == utf8.RuneError {
173+
if r <= ' ' || r == '=' || r == '"' || r == utf8.RuneError {
174174
return -1
175175
}
176176
return r
@@ -233,7 +233,7 @@ func writeValue(w io.Writer, value interface{}) error {
233233
}
234234

235235
func needsQuotedValueRune(r rune) bool {
236-
return r <= ' ' || r == '=' || r == '"' || r == utf8.RuneError
236+
return r <= ' ' || r == '=' || r == '"' || r == 0x7f || r == utf8.RuneError
237237
}
238238

239239
func writeStringValue(w io.Writer, value string, ok bool) error {

jsonstring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func writeQuotedBytes(w io.Writer, s []byte) (int, error) {
9898
start := 0
9999
for i := 0; i < len(s); {
100100
if b := s[i]; b < utf8.RuneSelf {
101-
if 0x20 <= b && b != '\\' && b != '"' {
101+
if 0x20 <= b && b != '\\' && b != '"' && b != 0x7f {
102102
i++
103103
continue
104104
}

0 commit comments

Comments
 (0)