Unverified Commit 12efec34 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Merge #2188

b10-loadzone tries to remove comments from RData strings
parents f2f058d5 51970485
...@@ -12,6 +12,7 @@ EXTRA_DIST += ttl1.db ...@@ -12,6 +12,7 @@ EXTRA_DIST += ttl1.db
EXTRA_DIST += ttl2.db EXTRA_DIST += ttl2.db
EXTRA_DIST += ttlext.db EXTRA_DIST += ttlext.db
EXTRA_DIST += example.db EXTRA_DIST += example.db
EXTRA_DIST += comment.db
noinst_SCRIPTS = correct_test.sh noinst_SCRIPTS = correct_test.sh
......
; 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
...@@ -48,6 +48,9 @@ ${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttlext.db >> / ...@@ -48,6 +48,9 @@ ${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttlext.db >> /
echo "loadzone example.com. from example.db" echo "loadzone example.com. from example.db"
${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 example.db >> /dev/null ${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 \$INCLUDE semantics"
echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics" echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics"
echo "I:test master file RFC1035 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 ...@@ -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 RFC1035 TTL and mixed \$INCLUDE with \$TTL semantics"
echo "I:test master file BIND9 extenstion of TTL" 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 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 ${PYTHON_EXEC} ${TEST_FILE_PATH}/get_zonedatas.py ${TEST_OUTPUT_PATH}/zone.sqlite3 > ${TEST_OUTPUT_PATH}/test.out
echo "Compare test results." echo "Compare test results."
......
from isc.datasrc import sqlite3_ds from isc.datasrc import sqlite3_ds
import sys import sys
ZONE_FILE = sys.argv[1] 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 zone_name in zonename_set:
for rr_data in sqlite3_ds.get_zone_datas(zone_name, ZONE_FILE): for rr_data in sqlite3_ds.get_zone_datas(zone_name, ZONE_FILE):
data_len = len(rr_data[2]) data_len = len(rr_data[2])
......
...@@ -77,3 +77,9 @@ ns2.example.com. 80 IN A 1.1.1.1 ...@@ -77,3 +77,9 @@ ns2.example.com. 80 IN A 1.1.1.1
ns3.example.com. 60 IN A 2.2.2.2 ns3.example.com. 60 IN A 2.2.2.2
ns4.example.com. 60 IN A 3.3.3.3 ns4.example.com. 60 IN A 3.3.3.3
ns5.example.com. 90 IN A 4.4.4.4 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?"
...@@ -46,11 +46,16 @@ def pop(line): ...@@ -46,11 +46,16 @@ def pop(line):
# whitespace removed, and all other whitespace compressed to # whitespace removed, and all other whitespace compressed to
# single spaces # 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): def cleanup(s):
global decomment global decomment
s = s.strip().expandtabs() s = s.strip().expandtabs()
s = decomment.sub('', s) s = decomment.search(s).group(1)
return ' '.join(s.split()) return ' '.join(s.split())
######################################################################### #########################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment