~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/Mail/SpamAssassin/Util/RegistrarBoundaries.pm

  • Committer: Bazaar Package Importer
  • Author(s): Noah Meyerhans
  • Date: 2010-01-26 22:53:12 UTC
  • mfrom: (1.1.13 upstream) (5.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100126225312-wkftb10idc1kz2aq
Tags: 3.3.0-1
* New upstream version.
* Switch to dpkg-source 3.0 (quilt) format

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# limitations under the License.
19
19
# </@LICENSE>
20
20
 
 
21
=head1 NAME
 
22
 
 
23
Mail::SpamAssassin::Util::RegistrarBoundaries - domain delegation rules
 
24
 
 
25
=cut
 
26
 
21
27
package Mail::SpamAssassin::Util::RegistrarBoundaries;
22
28
 
23
29
use strict;
24
30
use warnings;
25
31
use bytes;
 
32
use re 'taint';
26
33
 
27
34
use vars qw (
28
 
  @ISA %TWO_LEVEL_DOMAINS %US_STATES %VALID_TLDS
 
35
  @ISA %TWO_LEVEL_DOMAINS %THREE_LEVEL_DOMAINS %US_STATES %VALID_TLDS
29
36
);
30
37
 
31
38
# The list of currently-valid TLDs for the DNS system.
32
39
#
33
 
# http://www.iana.org/cctld/cctld-whois.htm
34
 
# "su" Extra from http://www.iana.org/root-whois/
35
 
# http://www.iana.org/gtld/gtld.htm
36
 
# http://www.iana.org/arpa-dom/
 
40
# http://data.iana.org/TLD/tlds-alpha-by-domain.txt
 
41
# Version 2008020601, Last Updated Thu Feb  7 09:07:00 2008 UTC
 
42
# The following have been removed from the list because they are
 
43
# inactive, as can be seen in the Wikipedia articles about them
 
44
# as of 2008-02-08, e.g. http://en.wikipedia.org/wiki/.so_%28domain_name%29
 
45
#     bv gb pm sj so um yt
 
46
 
37
47
foreach (qw/
38
 
  ac ad ae af ag ai al am an ao aq ar as at au aw az ax ba bb bd be bf bg bh bi 
39
 
  bj bm bn bo br bs bt bv bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cs cu 
40
 
  cv cx cy cz de dj dk dm do dz ec ee eg eh er es et fi fj fk fm fo fr ga gb gd 
41
 
  ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im 
42
 
  in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk 
43
 
  lr ls lt lu lv ly ma mc md mg mh mk ml mm mn mo mp mq mr ms mt mu mv mw mx my 
44
 
  mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl pm pn pr ps pt 
45
 
  pw py qa re ro ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st sv sy sz 
46
 
  tc td tf tg th tj tk tl tm tn to tp tr tt tv tw tz ua ug uk um us uy uz va vc 
47
 
  ve vg vi vn vu wf ws ye yt yu za zm zw 
48
 
  su
49
 
  aero biz com coop info museum name net org pro gov edu mil int
50
 
  arpa
51
 
  eu
52
 
  jobs travel
53
 
  xxx
54
 
  mobi asia cat tel
 
48
  ac ad ae aero af ag ai al am an ao aq ar arpa as asia at au aw ax az
 
49
  ba bb bd be bf bg bh bi biz bj bm bn bo br bs bt bw by bz ca cat cc
 
50
  cd cf cg ch ci ck cl cm cn co com coop cr cu cv cx cy cz de dj dk dm
 
51
  do dz ec edu ee eg er es et eu fi fj fk fm fo fr ga gd ge gf gg gh
 
52
  gi gl gm gn gov gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im
 
53
  in info int io iq ir is it je jm jo jobs jp ke kg kh ki km kn kp kr kw
 
54
  ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mil mk ml mm
 
55
  mn mo mobi mp mq mr ms mt mu museum mv mw mx my mz na name nc ne net
 
56
  nf ng ni nl no np nr nu nz om org pa pe pf pg ph pk pl pn pr pro ps
 
57
  pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn
 
58
  sr st su sv sy sz tc td tel tf tg th tj tk tl tm tn to tp tr travel tt
 
59
  tv tw tz ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yu za
 
60
  zm zw
55
61
  /) { 
56
62
  $VALID_TLDS{$_} = 1;
57
63
}
250
256
}
251
257
 
252
258
# This is required because the .us domain is nuts. See $THREE_LEVEL_DOMAINS
253
 
# and $FOUR_LEVEL_DOMAINS below.
 
259
# below.
254
260
#
255
261
foreach (qw/
256
262
  ak al ar az ca co ct dc de fl ga gu hi ia id il in ks ky la ma md me mi 
260
266
  $US_STATES{$_} = 1;
261
267
}
262
268
 
 
269
foreach (qw/
 
270
  demon.co.uk esc.edu.ar lkd.co.im plc.co.im
 
271
 /) {
 
272
  $THREE_LEVEL_DOMAINS{$_} = 1;
 
273
}
 
274
 
263
275
###########################################################################
264
276
 
 
277
=head1 METHODS
 
278
 
 
279
=over 4
 
280
 
265
281
=item ($hostname, $domain) = split_domain ($fqdn)
266
282
 
267
283
Cut a fully-qualified hostname into the hostname part and the domain
288
304
 
289
305
    # Split scalar domain into components
290
306
    my @domparts = split(/\./, $domain);
291
 
    my @hostname = ();
 
307
    my @hostname;
292
308
 
293
309
    while (@domparts > 1) { # go until we find the TLD
294
310
      if (@domparts == 4) {
307
323
        # demon.co.uk
308
324
        # esc.edu.ar
309
325
        # [^\.]+\.${US_STATES}\.us
310
 
        if ($domparts[2] eq 'uk' || $domparts[2] eq 'ar' || $domparts[2] eq 'im') {
311
 
          my $temp = join('.', @domparts);
312
 
          last if ($temp eq 'demon.co.uk' || $temp eq 'esc.edu.ar' ||
313
 
                   $temp eq 'lkd.co.im' || $temp eq 'plc.co.im');
314
 
        }
315
 
        elsif ($domparts[2] eq 'us') {
 
326
        if ($domparts[2] eq 'us') {
316
327
          last if ($US_STATES{$domparts[1]});
317
328
        }
 
329
        else {
 
330
          my $temp = join(".", @domparts);
 
331
          last if ($THREE_LEVEL_DOMAINS{$temp});
 
332
        }
318
333
      }
319
334
      elsif (@domparts == 2) {
320
335
        # co.uk, etc.