Line 0
Link Here
|
|
|
1 |
--- ../ZoneParse.pm-orig 2014-07-22 09:36:10.000000000 +0200 |
2 |
+++ lib/DNS/ZoneParse.pm 2014-07-22 11:48:56.000000000 +0200 |
3 |
@@ -17,16 +17,20 @@ |
4 |
my $rr_class = qr/(?:IN|HS|CH)/i; |
5 |
my $rr_ttl = qr/(?:\d+[wdhms]?)+/i; |
6 |
|
7 |
-$VERSION = '1.10'; |
8 |
+$VERSION = '1.11'; |
9 |
my ( |
10 |
- %dns_id, %dns_soa, %dns_ns, %dns_a, %dns_cname, %dns_mx, %dns_txt, |
11 |
+ %dns_id, %dns_soa, %dns_ns, %dns_a, %dns_cname, %dns_mx, |
12 |
+ %dns_txt, %dns_spf, |
13 |
%dns_ptr, %dns_a4, %dns_srv, %dns_hinfo, %dns_rp, %dns_loc, |
14 |
%dns_generate, |
15 |
%dns_last_name, %dns_last_origin, %dns_last_class, %dns_last_ttl, |
16 |
%dns_found_origins, %unparseable_line_callback, %last_parse_error_count, |
17 |
); |
18 |
|
19 |
-my %possibly_quoted = map { $_ => undef } qw/ os cpu text mbox /; |
20 |
+my %possibly_quoted = map { $_ => undef } qw/ os cpu text mbox spf /; |
21 |
+ |
22 |
+# https://kb.isc.org/article/AA-00356/0/Can-I-have-a-TXT-or-SPF-record-longer-than-255-characters.html |
23 |
+my %possibly_multiple = map { $_ => undef } qw/ text spf /; |
24 |
|
25 |
sub new { |
26 |
my $class = shift; |
27 |
@@ -71,6 +75,7 @@ |
28 |
delete $dns_cname{$self}; |
29 |
delete $dns_mx{$self}; |
30 |
delete $dns_txt{$self}; |
31 |
+ delete $dns_spf{$self}; |
32 |
delete $dns_ptr{$self}; |
33 |
delete $dns_a4{$self}; |
34 |
delete $dns_srv{$self}; |
35 |
@@ -99,6 +104,7 @@ |
36 |
: $method eq 'cname' ? $dns_cname{$self} |
37 |
: $method eq 'mx' ? $dns_mx{$self} |
38 |
: $method eq 'txt' ? $dns_txt{$self} |
39 |
+ : $method eq 'spf' ? $dns_spf{$self} |
40 |
: $method eq 'ptr' ? $dns_ptr{$self} |
41 |
: $method eq 'aaaa' ? $dns_a4{$self} |
42 |
: $method eq 'srv' ? $dns_srv{$self} |
43 |
@@ -130,6 +136,7 @@ |
44 |
MX => $dns_mx{$self}, |
45 |
PTR => $dns_ptr{$self}, |
46 |
TXT => $dns_txt{$self}, |
47 |
+ SPF => $dns_spf{$self}, |
48 |
SRV => $dns_srv{$self}, |
49 |
HINFO => $dns_hinfo{$self}, |
50 |
RP => $dns_rp{$self}, |
51 |
@@ -235,7 +242,21 @@ |
52 |
next unless defined $o; |
53 |
next unless $o->{'ORIGIN'} eq $process_this_origin; |
54 |
$self->_escape_chars( $o ); |
55 |
- $output .= qq[$o->{name} $o->{ttl} $o->{class} TXT "$o->{text}"\n]; |
56 |
+ my $t = $o->{text}; |
57 |
+ if ( length($t) > 250 ) { |
58 |
+ $t=join('" "',( $t =~ m/.{1,250}/g )); |
59 |
+ } |
60 |
+ $output .= qq[$o->{name} $o->{ttl} $o->{class} TXT "$t"\n]; |
61 |
+ } |
62 |
+ foreach my $o ( @{ $dns_spf{$self} } ) { |
63 |
+ next unless defined $o; |
64 |
+ next unless $o->{'ORIGIN'} eq $process_this_origin; |
65 |
+ $self->_escape_chars( $o ); |
66 |
+ my $t = $o->{spf}; |
67 |
+ if ( length($t) > 250 ) { |
68 |
+ $t=join('" "',( $t =~ m/.{1,250}/g )); |
69 |
+ } |
70 |
+ $output .= qq[$o->{name} $o->{ttl} $o->{class} SPF "$t"\n]; |
71 |
} |
72 |
foreach my $o ( @{ $dns_ptr{$self} } ) { |
73 |
next unless defined $o; |
74 |
@@ -361,6 +382,7 @@ |
75 |
$dns_cname{$self} = []; |
76 |
$dns_mx{$self} = []; |
77 |
$dns_txt{$self} = []; |
78 |
+ $dns_spf{$self} = []; |
79 |
$dns_ptr{$self} = []; |
80 |
$dns_a4{$self} = []; |
81 |
$dns_srv{$self} = []; |
82 |
@@ -614,6 +636,20 @@ |
83 |
text => $4, |
84 |
} ); |
85 |
} elsif ( |
86 |
+ /($valid_name)? \s+ |
87 |
+ $ttl_cls |
88 |
+ SPF \s+ |
89 |
+ ("$valid_quoted_txt_char*(?<!\\)"|$valid_txt_char+) |
90 |
+ /ixo |
91 |
+ ) { |
92 |
+ push @{ $dns_spf{$self} }, |
93 |
+ $self->_massage( { |
94 |
+ name => $1, |
95 |
+ ttl => $2, |
96 |
+ class => $3, |
97 |
+ spf => $4, |
98 |
+ } ); |
99 |
+ } elsif ( |
100 |
/^\s*\$TTL \s+ |
101 |
($rr_ttl) |
102 |
/ixo |
103 |
@@ -817,9 +853,12 @@ |
104 |
$record->{$r} = ''; |
105 |
next; |
106 |
} |
107 |
- if ( exists $possibly_quoted{$r} ) { |
108 |
+ if ( exists $possibly_quoted{$r} ) { |
109 |
+ if ( exists $possibly_multiple{$r} ) { |
110 |
+ $record->{$r} =~ s/"\s+"//; |
111 |
+ } |
112 |
( $record->{$r} =~ s/^"// ) && ( $record->{$r} =~ s/"$// ); |
113 |
- } |
114 |
+ } |
115 |
|
116 |
# We return email addresses just as they are in the file... for better |
117 |
# or worse (mostly for backwards compatability reasons). |
118 |
@@ -1051,7 +1090,7 @@ |
119 |
If you plan to pass a on_unparseable_line callback but do not wish to specify |
120 |
an C<$origin>, pass 'undef' as the C<$origin> parameter. |
121 |
|
122 |
-=item a(), cname(), srv(), mx(), ns(), ptr(), txt(), hinfo(), rp(), loc() |
123 |
+=item a(), cname(), srv(), mx(), ns(), ptr(), txt(), spf(), hinfo(), rp(), loc() |
124 |
|
125 |
These methods return references to the resource records. For example: |
126 |
|
127 |
@@ -1069,6 +1108,9 @@ |
128 |
TXT records also have a 'text' property representing the record's 'txt-data' |
129 |
descriptive text. |
130 |
|
131 |
+SPF records also have a 'spf' property representing the record's 'spf-data' |
132 |
+descriptive text. |
133 |
+ |
134 |
HINFO records also have 'cpu' and 'os' properties. |
135 |
|
136 |
RP records also have 'mbox' and 'text' properties. |