File Coverage

blib/lib/Regexp/Common/URI/RFC2806.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 40 40 100.0


line stmt bran cond sub pod time code
1             package Regexp::Common::URI::RFC2806;
2              
3 72     72   22284 use Regexp::Common::URI::RFC1035 qw /$domain/;
  72         111  
  72         10560  
4 72     72   23025 use Regexp::Common::URI::RFC2396 qw /$unreserved $escaped $hex/;
  72         119  
  72         8207  
5              
6 72     72   317 use strict;
  72         114  
  72         1160  
7 72     72   209 use warnings;
  72         65  
  72         1477  
8              
9 72     72   209 use vars qw /$VERSION/;
  72         75  
  72         2713  
10             $VERSION = '2017040401';
11              
12 72     72   225 use vars qw /@EXPORT @EXPORT_OK %EXPORT_TAGS @ISA/;
  72         82  
  72         3068  
13              
14 72     72   296 use Exporter ();
  72         126  
  72         6225  
15             @ISA = qw /Exporter/;
16              
17              
18             my %vars;
19              
20             BEGIN {
21 72     72   294 $vars {low} = [qw /$dtmf_digit $wait_for_dial_tone $one_second_pause
22             $pause_character $visual_separator $phonedigit
23             $escaped_no_dquote $quoted_string $token_char
24             $token_chars/];
25 72         134 $vars {parts} = [qw /$future_extension/];
26 72         144 $vars {connect} = [qw /$provider_hostname $provider_tag $service_provider
27             $private_prefix $local_network_prefix
28             $global_network_prefix $network_prefix/];
29 72         179 $vars {phone} = [qw /$phone_context_ident $phone_context_tag
30             $area_specifier $post_dial $isdn_subaddress
31             $t33_subaddress $local_phone_number
32             $local_phone_number_no_future
33             $base_phone_number $global_phone_number
34             $global_phone_number_no_future $telephone_subscriber
35             $telephone_subscriber_no_future/];
36 72         155 $vars {fax} = [qw /$fax_local_phone $fax_local_phone_no_future
37             $fax_global_phone $fax_global_phone_no_future
38             $fax_subscriber $fax_subscriber_no_future/];
39 72         2147 $vars {modem} = [qw //];
40             }
41              
42 72     72   242 use vars map {@$_} values %vars;
  72         73  
  72         174  
  432         50981  
43              
44             @EXPORT = ();
45             @EXPORT_OK = map {@$_} values %vars;
46             %EXPORT_TAGS = (%vars, ALL => [@EXPORT_OK]);
47              
48              
49             # RFC 2806, URIs for tel, fax & modem.
50             $dtmf_digit = "(?:[*#ABCD])";
51             $wait_for_dial_tone= "(?:w)";
52             $one_second_pause = "(?:p)";
53             $pause_character = "(?:[wp])"; # wait_for_dial_tone | one_second_pause.
54             $visual_separator = "(?:[\\-.()])";
55             $phonedigit = "(?:[0-9\\-.()])"; # DIGIT | visual_separator
56             $escaped_no_dquote = "(?:%(?:[01]$hex)|2[013-9A-Fa-f]|[3-9A-Fa-f]$hex)";
57             $quoted_string = "(?:%22(?:(?:%5C(?:$unreserved|$escaped))|" .
58             "$unreserved+|$escaped_no_dquote)*%22)";
59             # It is unclear wether we can allow only unreserved
60             # characters to unescaped, or can we also use uric
61             # characters that are unescaped? Or pchars?
62             $token_char = "(?:[!'*\\-.0-9A-Z_a-z~]|" .
63             "%(?:2[13-7ABDEabde]|3[0-9]|4[1-9A-Fa-f]|" .
64             "5[AEFaef]|6[0-9A-Fa-f]|7[0-9ACEace]))";
65             # Only allowing unreserved chars to be unescaped.
66             $token_chars = "(?:(?:[!'*\\-.0-9A-Z_a-z~]+|" .
67             "%(?:2[13-7ABDEabde]|3[0-9]|4[1-9A-Fa-f]|" .
68             "5[AEFaef]|6[0-9A-Fa-f]|7[0-9ACEace]))*)";
69             $future_extension = "(?:;$token_chars" .
70             "(?:=(?:(?:$token_chars(?:[?]$token_chars)?)|" .
71             "$quoted_string))?)";
72             $provider_hostname = $domain;
73             $provider_tag = "(?:tsp)";
74             $service_provider = "(?:;$provider_tag=$provider_hostname)";
75             $private_prefix = "(?:(?:[!'E-OQ-VX-Z_e-oq-vx-z~]|" .
76             "(?:%(?:2[124-7CFcf]|3[AC-Fac-f]|4[05-9A-Fa-f]|" .
77             "5[1-689A-Fa-f]|6[05-9A-Fa-f]|" .
78             "7[1-689A-Ea-e])))" .
79             "(?:[!'()*\\-.0-9A-Z_a-z~]+|" .
80             "(?:%(?:2[1-9A-Fa-f]|3[AC-Fac-f]|" .
81             "[4-6][0-9A-Fa-f]|7[0-9A-Ea-e])))*)";
82             $local_network_prefix
83             = "(?:[0-9\\-.()*#ABCDwp]+)";
84             $global_network_prefix
85             = "(?:[+][0-9\\-.()]+)";
86             $network_prefix = "(?:$global_network_prefix|$local_network_prefix)";
87             $phone_context_ident
88             = "(?:$network_prefix|$private_prefix)";
89             $phone_context_tag = "(?:phone-context)";
90             $area_specifier = "(?:;$phone_context_tag=$phone_context_ident)";
91             $post_dial = "(?:;postd=[0-9\\-.()*#ABCDwp]+)";
92             $isdn_subaddress = "(?:;isub=[0-9\\-.()]+)";
93             $t33_subaddress = "(?:;tsub=[0-9\\-.()]+)";
94              
95             $local_phone_number= "(?:[0-9\\-.()*#ABCDwp]+$isdn_subaddress?" .
96             "$post_dial?$area_specifier" .
97             "(?:$area_specifier|$service_provider|" .
98             "$future_extension)*)";
99             $local_phone_number_no_future
100             = "(?:[0-9\\-.()*#ABCDwp]+$isdn_subaddress?" .
101             "$post_dial?$area_specifier" .
102             "(?:$area_specifier|$service_provider)*)";
103             $fax_local_phone = "(?:[0-9\\-.()*#ABCDwp]+$isdn_subaddress?" .
104             "$t33_subaddress?$post_dial?$area_specifier" .
105             "(?:$area_specifier|$service_provider|" .
106             "$future_extension)*)";
107             $fax_local_phone_no_future
108             = "(?:[0-9\\-.()*#ABCDwp]+$isdn_subaddress?" .
109             "$t33_subaddress?$post_dial?$area_specifier" .
110             "(?:$area_specifier|$service_provider)*)";
111             $base_phone_number = "(?:[0-9\\-.()]+)";
112             $global_phone_number
113             = "(?:[+]$base_phone_number$isdn_subaddress?" .
114             "$post_dial?" .
115             "(?:$area_specifier|$service_provider|" .
116             "$future_extension)*)";
117             $global_phone_number_no_future
118             = "(?:[+]$base_phone_number$isdn_subaddress?" .
119             "$post_dial?" .
120             "(?:$area_specifier|$service_provider)*)";
121             $fax_global_phone = "(?:[+]$base_phone_number$isdn_subaddress?" .
122             "$t33_subaddress?$post_dial?" .
123             "(?:$area_specifier|$service_provider|" .
124             "$future_extension)*)";
125             $fax_global_phone_no_future
126             = "(?:[+]$base_phone_number$isdn_subaddress?" .
127             "$t33_subaddress?$post_dial?" .
128             "(?:$area_specifier|$service_provider)*)";
129             $telephone_subscriber
130             = "(?:$global_phone_number|$local_phone_number)";
131             $telephone_subscriber_no_future
132             = "(?:$global_phone_number_no_future|" .
133             "$local_phone_number_no_future)";
134             $fax_subscriber = "(?:$fax_global_phone|$fax_local_phone)";
135             $fax_subscriber_no_future
136             = "(?:$fax_global_phone_no_future|" .
137             "$fax_local_phone_no_future)";
138              
139             1;
140              
141             __END__