--- a/pvl/dns/tests.py Fri Feb 27 17:06:54 2015 +0200
+++ b/pvl/dns/tests.py Fri Feb 27 17:13:18 2015 +0200
@@ -215,6 +215,6 @@
" NS bar",
"foo A 192.0.2.1",
"bar A 192.0.2.2",
- "$INCLUDE \".../includes/test\"",
+ "$INCLUDE .../includes/test",
])
--- a/pvl/dns/zone.py Fri Feb 27 17:06:54 2015 +0200
+++ b/pvl/dns/zone.py Fri Feb 27 17:13:18 2015 +0200
@@ -30,14 +30,17 @@
Quote a value for inclusion into TXT record.
>>> print zone_quote("foo")
- "foo"
+ foo
>>> print zone_quote("foo\\bar")
"foo\\bar"
>>> print zone_quote("foo \"bar\" quux")
"foo \"bar\" quux"
"""
- return u'"' + field.replace('\\', '\\\\').replace('"', '\\"') + u'"'
+ if any(c.isspace() or c == '\\' for c in field):
+ return u'"' + field.replace('\\', '\\\\').replace('"', '\\"') + u'"'
+ else:
+ return field
class ZoneLine (object) :
@@ -226,9 +229,9 @@
"""
if origin:
- return cls.build('INCLUDE', zone_quote(path), origin, **opts)
+ return cls.build('INCLUDE', path, origin, **opts)
else:
- return cls.build('INCLUDE', zone_quote(path), **opts)
+ return cls.build('INCLUDE', path, **opts)
def __init__ (self, directive, arguments, comment=None, line=None, origin=None):
"""
@@ -258,7 +261,7 @@
return u"${directive}\t{arguments}{comment}".format(
directive = self.directive,
- arguments = '\t'.join(self.arguments),
+ arguments = '\t'.join(zone_quote(argument) for argument in self.arguments),
comment = comment,
)