| 1 | package Validate::SPF; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Validates SPF text string | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Validate::SPF::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = '0.004'; # VERSION | |||||||||
| 11 | 1 | our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY | |||||||||
| 12 | |||||||||||
| 13 | 1 | our @EXPORT = (); | |||||||||
| 14 | 1 | our @EXPORT_OK = qw( | |||||||||
| 15 | validate | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | sub validate { | ||||||||||
| 20 | 0 | ▶ | my ( $text ) = @_; | ||||||||
|
Subroutine
validate: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | unless ( $text ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | ▶ | return wantarray ? ( 0, 'no SPF string' ) : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | my $parser = Validate::SPF::Parser->new; | |||||||||
| 27 | |||||||||||
| 28 | 0 | my $parsed = $parser->parse( $text ); | |||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | my $is_valid = $parsed ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | my $error = $is_valid | ||||||||||
| 32 | ? undef | ||||||||||
| 33 | 0 | ▶ | : $parser->error->{text} . ": '" . $parser->error->{context} . "'" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | ; | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | return wantarray ? ( $is_valid, $error ) : $is_valid; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | # a | ||||||||||
| 40 | # a/<prefix-length> | ||||||||||
| 41 | # a:<domain-name> | ||||||||||
| 42 | # a:<domain-name>/<prefix-length> | ||||||||||
| 43 | |||||||||||
| 44 | # mx | ||||||||||
| 45 | # mx/<prefix-length> | ||||||||||
| 46 | # mx:<domain-name> | ||||||||||
| 47 | # mx:<domain-name>/<prefix-length> | ||||||||||
| 48 | |||||||||||
| 49 | # ip4:<IPv4-address> | ||||||||||
| 50 | # ip4:<IPv4-network>/<prefix-length> | ||||||||||
| 51 | |||||||||||
| 52 | # ip6:<IPv6-address> | ||||||||||
| 53 | # ip6:<IPv6-network>/<prefix-length> | ||||||||||
| 54 | |||||||||||
| 55 | # ptr | ||||||||||
| 56 | # ptr:<domain> | ||||||||||
| 57 | |||||||||||
| 58 | # exists:<domain> | ||||||||||
| 59 | |||||||||||
| 60 | # include:<domain> | ||||||||||
| 61 | |||||||||||
| 62 | # redirect=<domain> | ||||||||||
| 63 | |||||||||||
| 64 | # exp=<domain> | ||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | 1 | 1; | |||||||||
| 68 | |||||||||||
| 69 | __END__ | ||||||||||