BIND 10 master, updated. f2408e01aa158c250e4b1638bd77c45448957436 Changelog for #2188

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Aug 31 08:48:43 UTC 2012


The branch, master has been updated
       via  f2408e01aa158c250e4b1638bd77c45448957436 (commit)
       via  12efec3477feb62d7cbe36bdcfbfc7aa28a36f57 (commit)
       via  519704852db4162fd51ba5ea448ed96e67c025fd (commit)
       via  5e8d62ed54882e12dfa5159818b2a84239510987 (commit)
       via  627a1bbee79944d24a1aaecf3ba4c87d47b1003b (commit)
      from  f2f058d5a3ee567c0be22f758a02abacc159e927 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f2408e01aa158c250e4b1638bd77c45448957436
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Aug 31 10:33:51 2012 +0200

    Changelog for #2188

commit 12efec3477feb62d7cbe36bdcfbfc7aa28a36f57
Merge: f2f058d 5197048
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Aug 31 10:31:55 2012 +0200

    Merge #2188
    
    b10-loadzone tries to remove comments from RData strings

commit 519704852db4162fd51ba5ea448ed96e67c025fd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Aug 28 14:54:34 2012 +0200

    [2188] Add missing file
    
    I forgot to add it before.

commit 5e8d62ed54882e12dfa5159818b2a84239510987
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Aug 28 14:28:44 2012 +0200

    [2188] Don't strip comments in the middle of string

commit 627a1bbee79944d24a1aaecf3ba4c87d47b1003b
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Tue Aug 28 13:51:17 2012 +0200

    [2188] Test loading with comments in strings
    
    Obviously, it fails.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                         |    5 +++++
 src/bin/loadzone/tests/correct/Makefile.am        |    1 +
 src/bin/loadzone/tests/correct/comment.db         |    8 ++++++++
 src/bin/loadzone/tests/correct/correct_test.sh.in |    4 ++++
 src/bin/loadzone/tests/correct/get_zonedatas.py   |    2 +-
 src/bin/loadzone/tests/correct/known.test.out     |    6 ++++++
 src/lib/python/isc/datasrc/master.py              |    9 +++++++--
 7 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100644 src/bin/loadzone/tests/correct/comment.db

-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 8036119..933cab2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+471.    [bug]       vorner
+	Fixed a problem when b10-loadzone tried to tread semicolon in string data
+	as start of comment, which caused invalid data being loaded.
+	(Trac #2188, git 12efec3477feb62d7cbe36bdcfbfc7aa28a36f57)
+
 470.	[func]		naokikambe
 	The stats module now supports partial statistics updates. Each
 	module can return only statistics data which have been updated since
diff --git a/src/bin/loadzone/tests/correct/Makefile.am b/src/bin/loadzone/tests/correct/Makefile.am
index fb882ba..a3c67d4 100644
--- a/src/bin/loadzone/tests/correct/Makefile.am
+++ b/src/bin/loadzone/tests/correct/Makefile.am
@@ -12,6 +12,7 @@ EXTRA_DIST += ttl1.db
 EXTRA_DIST += ttl2.db
 EXTRA_DIST += ttlext.db
 EXTRA_DIST += example.db
+EXTRA_DIST += comment.db
 
 noinst_SCRIPTS = correct_test.sh
 
diff --git a/src/bin/loadzone/tests/correct/comment.db b/src/bin/loadzone/tests/correct/comment.db
new file mode 100644
index 0000000..79ce9b7
--- /dev/null
+++ b/src/bin/loadzone/tests/correct/comment.db
@@ -0,0 +1,8 @@
+; Test removal of comments and not removal from strings.
+; We had a bug - see #2188.
+comment.example.com.		60	IN	SOA	ns1.example.com. hostmaster.example.com. 1 43200 900 1814400 7200
+comment.example.com.		60	IN	NS	ns1.example.com.
+comment.example.com.		60	IN	TXT	"Simple text"
+comment.example.com.		60	IN	TXT	"; No comment"
+comment.example.com.		60	IN	TXT	"Also no comment here" ; But here it is a comment
+comment.example.com.		60	IN	TXT	"A combination ; see?" ; This is a "comment
diff --git a/src/bin/loadzone/tests/correct/correct_test.sh.in b/src/bin/loadzone/tests/correct/correct_test.sh.in
index d944451..e3f6a84 100755
--- a/src/bin/loadzone/tests/correct/correct_test.sh.in
+++ b/src/bin/loadzone/tests/correct/correct_test.sh.in
@@ -48,6 +48,9 @@ ${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttlext.db >> /
 echo "loadzone example.com. from example.db"
 ${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 example.db >> /dev/null
 
+echo "loadzone comment.example.com. from comment.db"
+${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 comment.db >> /dev/null
+
 echo "I:test master file \$INCLUDE semantics"
 echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics"
 echo "I:test master file RFC1035 TTL and \$TTL semantics"
@@ -55,6 +58,7 @@ echo "I:test master file BIND8 compatibility and mixed \$INCLUDE with \$TTL sema
 echo "I:test master file RFC1035 TTL and mixed \$INCLUDE with \$TTL semantics"
 echo "I:test master file BIND9 extenstion of TTL"
 echo "I:test master file RFC1035 missing CLASS, TTL, NAME semantics"
+echo "I:test master file comments"
 
 ${PYTHON_EXEC} ${TEST_FILE_PATH}/get_zonedatas.py ${TEST_OUTPUT_PATH}/zone.sqlite3 > ${TEST_OUTPUT_PATH}/test.out
 echo "Compare test results."
diff --git a/src/bin/loadzone/tests/correct/get_zonedatas.py b/src/bin/loadzone/tests/correct/get_zonedatas.py
index faa5634..5bef90d 100644
--- a/src/bin/loadzone/tests/correct/get_zonedatas.py
+++ b/src/bin/loadzone/tests/correct/get_zonedatas.py
@@ -1,7 +1,7 @@
 from isc.datasrc import sqlite3_ds
 import sys
 ZONE_FILE = sys.argv[1]
-zonename_set = ["include.", "ttl1.", "ttl2.", "mix1.", "mix2.", "ttlext.", "example.com."]
+zonename_set = ["include.", "ttl1.", "ttl2.", "mix1.", "mix2.", "ttlext.", "example.com.", "comment.example.com."]
 for zone_name in zonename_set:
     for rr_data in sqlite3_ds.get_zone_datas(zone_name, ZONE_FILE):
         data_len = len(rr_data[2])
diff --git a/src/bin/loadzone/tests/correct/known.test.out b/src/bin/loadzone/tests/correct/known.test.out
index 8e2fe3c..eec692e 100644
--- a/src/bin/loadzone/tests/correct/known.test.out
+++ b/src/bin/loadzone/tests/correct/known.test.out
@@ -77,3 +77,9 @@ ns2.example.com.		80	IN	A	1.1.1.1
 ns3.example.com.		60	IN	A	2.2.2.2
 ns4.example.com.		60	IN	A	3.3.3.3
 ns5.example.com.		90	IN	A	4.4.4.4
+comment.example.com.		60	IN	SOA	ns1.example.com. hostmaster.example.com. 1 43200 900 1814400 7200
+comment.example.com.		60	IN	NS	ns1.example.com.
+comment.example.com.		60	IN	TXT	"Simple text"
+comment.example.com.		60	IN	TXT	"; No comment"
+comment.example.com.		60	IN	TXT	"Also no comment here"
+comment.example.com.		60	IN	TXT	"A combination ; see?"
diff --git a/src/lib/python/isc/datasrc/master.py b/src/lib/python/isc/datasrc/master.py
index bba0805..2c22190 100644
--- a/src/lib/python/isc/datasrc/master.py
+++ b/src/lib/python/isc/datasrc/master.py
@@ -46,11 +46,16 @@ def pop(line):
 #   whitespace removed, and all other whitespace compressed to
 #   single spaces
 #########################################################################
-decomment = re.compile('\s*(?:;.*)+')
+decomment = re.compile('^\s*((?:[^;"]|"[^"]*")*)\s*(?:|;.*)$')
+# Regular expression explained:
+# First, ignore any whitespace at the start. Then take the content,
+# each bit is either a harmless character (no ; nor ") or a string -
+# sequence between " " not containing double quotes. Then there may
+# be a comment at the end.
 def cleanup(s):
     global decomment
     s = s.strip().expandtabs()
-    s = decomment.sub('', s)
+    s = decomment.search(s).group(1)
     return ' '.join(s.split())
 
 #########################################################################



More information about the bind10-changes mailing list