Skip to content

Commit

Permalink
fix backslash handling in TXT parser, includes test. Thanks jpmens
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3107 d19b8d6e-7fed-0310-83ef-9ca221ded41b
  • Loading branch information
Peter van Dijk committed Feb 28, 2013
1 parent fb6ed6f commit 3526186
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pdns/dnslabeltext.rl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ vector<string> segmentDNSText(const string& input )
appendSplit(ret, segment, *(fpc));
}

escaped = '\\' ((["\\]@reportEscaped) | ([0-9]{3}$reportEscapedNumber%doneEscapedNumber));
escaped = '\\' (([^0-9]@reportEscaped) | ([0-9]{3}$reportEscapedNumber%doneEscapedNumber));
plain = ((print-'\\'-'"')|'\n'|'\t') $ reportPlain;
txtElement = escaped | plain;

Expand Down
5 changes: 5 additions & 0 deletions regression-tests/escaped-txt/command
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
cleandig text0.example.com TXT
cleandig text1.example.com TXT
cleandig text2.example.com TXT
cleandig text3.example.com TXT
1 change: 1 addition & 0 deletions regression-tests/escaped-txt/description
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 TXT records with 0 to 3 backslashes before a semicolon.
12 changes: 12 additions & 0 deletions regression-tests/escaped-txt/expected_result
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
0 text0.example.com. IN TXT 120 "k=rsa; p=one"
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
Reply to question for qname='text0.example.com.', qtype=TXT
0 text1.example.com. IN TXT 120 "k=rsa; p=one"
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
Reply to question for qname='text1.example.com.', qtype=TXT
0 text2.example.com. IN TXT 120 "k=rsa\\; p=one"
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
Reply to question for qname='text2.example.com.', qtype=TXT
0 text3.example.com. IN TXT 120 "k=rsa\\; p=one"
Rcode: 0, RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
Reply to question for qname='text3.example.com.', qtype=TXT
5 changes: 5 additions & 0 deletions regression-tests/example.com
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ external-mail IN MX 25 server1.test.com.
text IN TXT "Hi, this is some text"
multitext IN TXT "text part one" "text part two" "text part three"
escapedtext IN TXT "begin" "the \"middle\" p\\art" "the end"
text0 IN TXT "k=rsa; p=one"
text1 IN TXT "k=rsa\; p=one"
text2 IN TXT "k=rsa\\; p=one"
text3 IN TXT "k=rsa\\\; p=one"

;
ipv6 IN AAAA 2001:6A8:0:1:210:4BFF:FE4B:4C61
;
Expand Down

0 comments on commit 3526186

Please sign in to comment.