File Coverage

blib/lib/Regexp/Common/URI/RFC1738.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 33 33 100.0


line stmt bran cond sub pod time code
1             package Regexp::Common::URI::RFC1738;
2              
3 71     71   226 use Regexp::Common qw /pattern clean no_defaults/;
  71         74  
  71         300  
4              
5 71     71   238 use strict;
  71         116  
  71         1033  
6 71     71   191 use warnings;
  71         70  
  71         1500  
7              
8 71     71   208 use vars qw /$VERSION/;
  71         68  
  71         2741  
9             $VERSION = '2016060801';
10              
11 71     71   216 use vars qw /@EXPORT @EXPORT_OK %EXPORT_TAGS @ISA/;
  71         65  
  71         2927  
12              
13 71     71   206 use Exporter ();
  71         72  
  71         4395  
14             @ISA = qw /Exporter/;
15              
16              
17             my %vars;
18              
19             BEGIN {
20 71     71   330 $vars {low} = [qw /$digit $digits $hialpha $lowalpha $alpha $alphadigit
21             $safe $extra $national $punctuation $unreserved
22             $unreserved_range $reserved $uchar $uchars $xchar
23             $xchars $hex $escape/];
24              
25 71         172 $vars {connect} = [qw /$port $hostnumber $toplabel $domainlabel $hostname
26             $host $hostport $user $password $login/];
27              
28 71         1923 $vars {parts} = [qw /$fsegment $fpath $group $article $grouppart
29             $search $database $wtype $wpath $psegment
30             $fieldname $fieldvalue $fieldspec $ppath/];
31             }
32              
33 71     71   235 use vars map {@$_} values %vars;
  71         99  
  71         154  
  213         40086  
34              
35             @EXPORT = qw /$host/;
36             @EXPORT_OK = map {@$_} values %vars;
37             %EXPORT_TAGS = (%vars, ALL => [@EXPORT_OK]);
38              
39             # RFC 1738, base definitions.
40              
41             # Lowlevel definitions.
42             $digit = '[0-9]';
43             $digits = '[0-9]+';
44             $hialpha = '[A-Z]';
45             $lowalpha = '[a-z]';
46             $alpha = '[a-zA-Z]'; # lowalpha | hialpha
47             $alphadigit = '[a-zA-Z0-9]'; # alpha | digit
48             $safe = '[-$_.+]';
49             $extra = "[!*'(),]";
50             $national = '[][{}|\\^~`]';
51             $punctuation = '[<>#%"]';
52             $unreserved_range = q [-a-zA-Z0-9$_.+!*'(),]; # alphadigit | safe | extra
53             $unreserved = "[$unreserved_range]";
54             $reserved = '[;/?:@&=]';
55             $hex = '[a-fA-F0-9]';
56             $escape = "(?:%$hex$hex)";
57             $uchar = "(?:$unreserved|$escape)";
58             $uchars = "(?:(?:$unreserved|$escape)*)";
59             $xchar = "(?:[$unreserved_range;/?:\@&=]|$escape)";
60             $xchars = "(?:(?:[$unreserved_range;/?:\@&=]|$escape)*)";
61              
62             # Connection related stuff.
63             $port = "(?:$digits)";
64             $hostnumber = "(?:$digits\[.]$digits\[.]$digits\[.]$digits)";
65             $toplabel = "(?:$alpha\[-a-zA-Z0-9]*$alphadigit|$alpha)";
66             $domainlabel = "(?:(?:$alphadigit\[-a-zA-Z0-9]*)?$alphadigit)";
67             $hostname = "(?:(?:$domainlabel\[.])*$toplabel)";
68             $host = "(?:$hostname|$hostnumber)";
69             $hostport = "(?:$host(?::$port)?)";
70              
71             $user = "(?:(?:[$unreserved_range;?&=]|$escape)*)";
72             $password = "(?:(?:[$unreserved_range;?&=]|$escape)*)";
73             $login = "(?:(?:$user(?::$password)?\@)?$hostport)";
74              
75             # Parts (might require more if we add more URIs).
76              
77             # FTP/file
78             $fsegment = "(?:(?:[$unreserved_range:\@&=]|$escape)*)";
79             $fpath = "(?:$fsegment(?:/$fsegment)*)";
80              
81             # NNTP/news.
82             $group = "(?:$alpha\[-A-Za-z0-9.+_]*)";
83             $article = "(?:(?:[$unreserved_range;/?:&=]|$escape)+" .
84             '@' . "$host)";
85             $grouppart = "(?:[*]|$article|$group)"; # It's important that
86             # $article goes before
87             # $group.
88              
89             # WAIS.
90             $search = "(?:(?:[$unreserved_range;:\@&=]|$escape)*)";
91             $database = $uchars;
92             $wtype = $uchars;
93             $wpath = $uchars;
94              
95             # prospero
96             $psegment = "(?:(?:[$unreserved_range?:\@&=]|$escape)*)";
97             $fieldname = "(?:(?:[$unreserved_range?:\@&]|$escape)*)";
98             $fieldvalue = "(?:(?:[$unreserved_range?:\@&]|$escape)*)";
99             $fieldspec = "(?:;$fieldname=$fieldvalue)";
100             $ppath = "(?:$psegment(?:/$psegment)*)";
101              
102             #
103             # The various '(?:(?:[$unreserved_range ...]|$escape)*)' above need
104             # some loop unrolling to speed up the match.
105             #
106              
107             1;
108              
109             __END__