Fix newline/space handling and braces
( dsjkdjk djsdjk ) ( dkjsdjsd djskdjsd ) Are two different strings, the above contains NO spaces, the bottom one does. This doesn't matter anywhere, except in HIP record, which say some data may not contain spaces.
This commit is contained in:
parent
32ce3502ae
commit
88a0052d1d
2
msg.go
2
msg.go
|
@ -109,7 +109,7 @@ var Rr_str = map[uint16]string{
|
|||
TypeOPT: "OPT",
|
||||
TypeDS: "DS",
|
||||
TypeDHCID: "DHCID",
|
||||
TypeHIP: "HIP"
|
||||
TypeHIP: "HIP",
|
||||
TypeIPSECKEY: "IPSECKEY",
|
||||
TypeSSHFP: "SSHFP",
|
||||
TypeRRSIG: "RRSIG",
|
||||
|
|
|
@ -410,6 +410,7 @@ moutamassey NS ns01.yahoodomains.jp.
|
|||
}
|
||||
}
|
||||
|
||||
// www.example.com. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com
|
||||
func ExampleHIP() {
|
||||
h := `www.example.com. IN HIP ( 2 200100107B1A74DF365639CC39F1D578
|
||||
AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p
|
||||
|
|
49
zscan.go
49
zscan.go
|
@ -562,13 +562,12 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
// discard
|
||||
// this means it can also not be used as rdata
|
||||
case '\n':
|
||||
// hmmm, escape newline
|
||||
// Escaped newline
|
||||
if quote {
|
||||
str[stri] = byte(x[0])
|
||||
stri++
|
||||
break
|
||||
}
|
||||
|
||||
// inside quotes this is legal
|
||||
escape = false
|
||||
if commt {
|
||||
|
@ -585,36 +584,28 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
}
|
||||
break
|
||||
}
|
||||
if stri != 0 {
|
||||
l.value = _STRING
|
||||
l.token = string(str[:stri])
|
||||
if !rrtype {
|
||||
if _, ok := Str_rr[strings.ToUpper(l.token)]; ok {
|
||||
l.value = _RRTYPE
|
||||
rrtype = true
|
||||
}
|
||||
}
|
||||
c <- l
|
||||
}
|
||||
if brace > 0 {
|
||||
l.value = _BLANK
|
||||
l.token = " "
|
||||
if !space {
|
||||
c <- l
|
||||
}
|
||||
} else {
|
||||
|
||||
if brace == 0 {
|
||||
// If there is previous text, we should output it here
|
||||
if stri != 0 {
|
||||
l.value = _STRING
|
||||
l.token = string(str[:stri])
|
||||
if !rrtype {
|
||||
if _, ok := Str_rr[strings.ToUpper(l.token)]; ok {
|
||||
l.value = _RRTYPE
|
||||
rrtype = true
|
||||
}
|
||||
}
|
||||
c <- l
|
||||
}
|
||||
l.value = _NEWLINE
|
||||
l.token = "\n"
|
||||
c <- l
|
||||
}
|
||||
if l.value == _BLANK {
|
||||
space = true
|
||||
}
|
||||
|
||||
stri = 0
|
||||
commt = false
|
||||
rrtype = false
|
||||
owner = true
|
||||
stri = 0
|
||||
commt = false
|
||||
rrtype = false
|
||||
owner = true
|
||||
}
|
||||
case '\\':
|
||||
// quote?
|
||||
if commt {
|
||||
|
|
|
@ -397,7 +397,7 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||
rr := new(RR_HIP)
|
||||
rr.Hdr = h
|
||||
|
||||
// HitLength is represented
|
||||
// HitLength is not represented
|
||||
l := <-c
|
||||
if i, e := strconv.Atoi(l.token); e != nil {
|
||||
return nil, &ParseError{f, "bad HIP PublicKeyAlgorithm", l}
|
||||
|
@ -434,7 +434,6 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||
l = <-c
|
||||
}
|
||||
rr.RendezvousServers = xs
|
||||
|
||||
return rr, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue