Simplify unprintable handling in UnpackDomainName (#845)
* Avoid the for loop for unprintable octets in UnpackDomainName * Unify unprintable checking with writeTXTStringByte These constants are identical.
This commit is contained in:
parent
ed726faad6
commit
b1bf6f1b9b
9
msg.go
9
msg.go
|
@ -405,14 +405,11 @@ Loop:
|
|||
case '"', '\\':
|
||||
s = append(s, '\\', b)
|
||||
default:
|
||||
if b < 32 || b >= 127 { // unprintable, use \DDD
|
||||
if b < ' ' || b > '~' { // unprintable, use \DDD
|
||||
var buf [3]byte
|
||||
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
|
||||
s = append(s, '\\')
|
||||
for i := len(bufs); i < 3; i++ {
|
||||
s = append(s, '0')
|
||||
}
|
||||
s = append(s, bufs...)
|
||||
s = append(s, '\\', '0', '0', '0')
|
||||
copy(s[len(s)-len(bufs):], bufs)
|
||||
} else {
|
||||
s = append(s, b)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue