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