Committing @miekg patch from gist.

https://gist.github.com/miekg/f1b1fe6dba7d6b088eec
This commit is contained in:
Alex Sergeyev 2014-08-28 08:00:15 -04:00
parent e9bffe6796
commit 755a8483b6
2 changed files with 15 additions and 13 deletions

View File

@ -1071,7 +1071,7 @@ func TestTXT(t *testing.T) {
}
func TestTypeXXXX(t *testing.T) {
_, err := NewRR("example.com IN TYPE1234 \\# 4 aabbccdd")
_, err := NewRR("example.com IN type1234 \\# 4 aabbccdd")
if err != nil {
t.Logf("failed to parse TYPE1234 RR: %s", err.Error())
t.Fail()

View File

@ -88,14 +88,15 @@ func (e *ParseError) Error() (s string) {
}
type lex struct {
token string // text of the token
length int // lenght of the token
err bool // when true, token text has lexer error
value uint8 // value: _STRING, _BLANK, etc.
line int // line in the file
column int // column in the file
torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
comment string // any comment text seen
token string // text of the token
tokenUpper string // uppercase text of the token
length int // lenght of the token
err bool // when true, token text has lexer error
value uint8 // value: _STRING, _BLANK, etc.
line int // line in the file
column int // column in the file
torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
comment string // any comment text seen
}
// *Tokens are returned when a zone file is parsed.
@ -553,14 +554,15 @@ func zlexer(s *scan, c chan lex) {
} else {
l.value = _STRING
l.token = string(str[:stri])
l.tokenUpper = strings.ToUpper(l.token)
l.length = stri
if !rrtype {
if t, ok := StringToType[l.token]; ok {
if t, ok := StringToType[l.tokenUpper]; ok {
l.value = _RRTYPE
l.torc = t
rrtype = true
} else {
if strings.HasPrefix(l.token, "TYPE") {
if strings.HasPrefix(l.tokenUpper, "TYPE") {
if t, ok := typeToInt(l.token); !ok {
l.token = "unknown RR type"
l.err = true
@ -572,11 +574,11 @@ func zlexer(s *scan, c chan lex) {
}
}
}
if t, ok := StringToClass[l.token]; ok {
if t, ok := StringToClass[l.tokenUpper]; ok {
l.value = _CLASS
l.torc = t
} else {
if strings.HasPrefix(l.token, "CLASS") {
if strings.HasPrefix(l.tokenUpper, "CLASS") {
if t, ok := classToInt(l.token); !ok {
l.token = "unknown class"
l.err = true