You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2013/02/04 15:58:07 UTC
svn commit: r1442145 -
/spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
Author: mmartinec
Date: Mon Feb 4 14:58:06 2013
New Revision: 1442145
URL: http://svn.apache.org/viewvc?rev=1442145&view=rev
Log:
dns0x20 and domain name case sensitivity tweaks, added an explanation
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm?rev=1442145&r1=1442144&r2=1442145&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm Mon Feb 4 14:58:06 2013
@@ -549,15 +549,20 @@ sub new_dns_packet {
die "a label in a domain name is longer than 63 bytes\n";
}
}
+
if ($self->{conf}->{dns_options}->{dns0x20}) {
$domain = dnsext_dns0x20($domain);
+ } else {
+ $domain =~ tr/A-Z/a-z/; # lowercase, limited to plain ASCII
}
+
# Net::DNS expects RFC 1035 zone format encoding even in its API, silly!
# Since 0.68 it also assumes that domain names containing characters
# with codes above 0177 imply that IDN translation is to be performed.
# Protect also nonprintable characters just in case, ensuring transparency.
$domain =~ s{ ( [\000-\037\177-\377\\] ) }
{ $1 eq '\\' ? "\\$1" : sprintf("\\%03d",ord($1)) }xgse;
+
$packet = Net::DNS::Packet->new($domain, $type, $class);
# a bit noisy, so commented by default...
@@ -617,8 +622,9 @@ sub _packet_id {
# sure the query section of an answer packet matches the query section
# in our packet as formed by new_dns_packet():
#
- # $qname = lc $qname if !$self->{conf}->{dns_options}->{dns0x20};
- return join('/', $id, fmt_dns_question_entry($questions[0]));
+ my($class,$type,$qname) = fmt_dns_question_entry($questions[0]);
+ $qname =~ tr/A-Z/a-z/ if !$self->{conf}->{dns_options}->{dns0x20};
+ return join('/', $id, $class, $type, $qname);
} else {
# odd. this should not happen, but clearly some DNS servers
@@ -763,7 +769,13 @@ sub poll_responses {
$packet->question)));
}
my $id = $self->_packet_id($packet);
+
+ # A hash lookup: the id must match exactly (case-sensitively).
+ # The domain name part of the id was lowercased if dns0x20 is off,
+ # and case-randomized when dns0x20 option is on.
+ #
my $cb = delete $self->{id_to_callback}->{$id};
+
if ($cb) {
$cb->($packet, $id, $now);
$cnt++;