better handle recursive includes
This commit is contained in:
parent
2718f6f23a
commit
01cb137157
30
zscan.go
30
zscan.go
|
@ -117,6 +117,9 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
||||||
close(t)
|
close(t)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if include > 7 {
|
||||||
|
t <- Token{Error: &ParseError{f, "Too deeply nested $INCLUDE", l}}
|
||||||
|
}
|
||||||
var s scanner.Scanner
|
var s scanner.Scanner
|
||||||
c := make(chan lex)
|
c := make(chan lex)
|
||||||
s.Init(r)
|
s.Init(r)
|
||||||
|
@ -187,16 +190,13 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Start with the new file
|
// Start with the new file
|
||||||
r1, e1 := os.Open(l.token)
|
r1, e1 := os.Open(l.token)
|
||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
t <- Token{Error: &ParseError{f, "Failed to open `" + l.token + "'", l}}
|
t <- Token{Error: &ParseError{f, "Failed to open `" + l.token + "'", l}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if include+1 > 8 {
|
parseZone(r1, l.token, t, include+1)
|
||||||
t <- Token{Error: &ParseError{f, "Too deeply nested $INCLUDE", l}}
|
st = _EXPECT_OWNER_DIR
|
||||||
}
|
|
||||||
parseZone(r1, l.token, t, include+1)
|
|
||||||
st = _EXPECT_OWNER_DIR
|
|
||||||
case _EXPECT_DIRTTL_BL:
|
case _EXPECT_DIRTTL_BL:
|
||||||
if l.value != _BLANK {
|
if l.value != _BLANK {
|
||||||
t <- Token{Error: &ParseError{f, "No blank after $TTL-directive", l}}
|
t <- Token{Error: &ParseError{f, "No blank after $TTL-directive", l}}
|
||||||
|
@ -381,14 +381,14 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
||||||
l.value = _OWNER
|
l.value = _OWNER
|
||||||
l.token = str
|
l.token = str
|
||||||
// escape $... start with a \ not a $, so this will work
|
// escape $... start with a \ not a $, so this will work
|
||||||
switch str {
|
switch str {
|
||||||
case "$TTL":
|
case "$TTL":
|
||||||
l.value = _DIRTTL
|
l.value = _DIRTTL
|
||||||
case "$ORIGIN":
|
case "$ORIGIN":
|
||||||
l.value = _DIRORIGIN
|
l.value = _DIRORIGIN
|
||||||
case "$INCLUDE":
|
case "$INCLUDE":
|
||||||
l.value = _DIRINCLUDE
|
l.value = _DIRINCLUDE
|
||||||
}
|
}
|
||||||
c <- l
|
c <- l
|
||||||
} else {
|
} else {
|
||||||
l.value = _STRING
|
l.value = _STRING
|
||||||
|
|
Loading…
Reference in New Issue