Skip to content

Commit

Permalink
Merge pull request #16 from craigw/txt-records-characters
Browse files Browse the repository at this point in the history
Allow the = character in unquoted TXT content
  • Loading branch information
aeden committed Nov 13, 2016
2 parents f0cd2eb + caedd1d commit 74bbb6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/dns/zonefile.treetop
Expand Up @@ -505,7 +505,7 @@ grammar Zonefile
end

rule unquoted_string
[a-zA-Z0-9]+ {
[a-zA-Z0-9=]+ {
def to_s
text_value
end
Expand Down
9 changes: 7 additions & 2 deletions spec/dns/zonefile_spec.rb
Expand Up @@ -73,6 +73,7 @@
@ TXT "some other \\"message\\" goes here" ; embedded quotes
long TXT "a multi-segment TXT record" "usually used for really long TXT records" "since each segment can only span 255 chars"
unquoted TXT some text data
with-eq TXT MS=example
multiline TXT "A TXT record
split across multiple lines
Expand Down Expand Up @@ -142,7 +143,7 @@

it "should build the correct number of resource records" do
zone = DNS::Zonefile.parse(@zonefile)
expect(zone.rr.size).to eq(50)
expect(zone.rr.size).to eq(51)
end

it "should build the correct NS records" do
Expand Down Expand Up @@ -350,7 +351,7 @@
it "should build the correct TXT records" do
zone = DNS::Zonefile.load(@zonefile)
txt_records = zone.records_of DNS::Zonefile::TXT
expect(txt_records.size).to eq(6)
expect(txt_records.size).to eq(7)

expect(txt_records.detect { |r|
r.host == "_domainkey.example.com." && r.data == '"v=DKIM1\;g=*\;k=rsa\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"'
Expand All @@ -372,6 +373,10 @@
r.host == "unquoted.example.com." && r.data == 'some text data'
}).to_not be_nil

expect(txt_records.detect { |r|
r.host == "with-eq.example.com." && r.data == 'MS=example'
}).to_not be_nil

expect(txt_records.detect { |r|
r.host == "multiline.example.com." && r.data == "\"A TXT record\nsplit across multiple lines\nwith LF and CRLF line endings\""
}).to_not be_nil
Expand Down

0 comments on commit 74bbb6d

Please sign in to comment.