X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/9b9648223ab2db3960298d04b83ecdd147ec21e9..9218fb0859abdc5a09758bed809b26902ae179d6:/selfforum-cgi/shared/CheckRFC.pm diff --git a/selfforum-cgi/shared/CheckRFC.pm b/selfforum-cgi/shared/CheckRFC.pm index 639f77f..d1731d2 100644 --- a/selfforum-cgi/shared/CheckRFC.pm +++ b/selfforum-cgi/shared/CheckRFC.pm @@ -17,6 +17,7 @@ use vars qw( @email @EXPORT @ISA + $VERSION ); $v56 = eval q[ @@ -26,6 +27,10 @@ $v56 = eval q[ use Carp qw(croak); +# Version check +# +$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + ################################################################################ # # Export @@ -53,25 +58,27 @@ require Exporter; # sub is_URL ($@) { my ($string, @schemes) = @_; + my $scheme; return unless (defined ($string) and length ($string)); @schemes = qw(http) unless (@schemes); @schemes = keys %url if (@schemes == 1 and $schemes[0] eq ':ALL'); - for (@schemes) { - croak "unknown url scheme '$_'" unless exists $url{$_}; - unless (/mailto/) { - return 1 if ($string =~ /$url{$_}/); + for $scheme (@schemes) { + croak "unknown url scheme '$scheme'" unless exists $url{$scheme}; + unless ($scheme =~ /mailto/) { + return 1 if ($string =~ /$url{$scheme}/); } else { - return unless ($string =~ /^mailto:(.+)/); - - if ($_ eq 'mailto') { - return 1 if (is_email ($1)); - } - elsif ($_ eq 'strict_mailto') { - return 1 if (is_email ($1,1)); + if ($string =~ /^mailto:(.+)/) { + + if ($scheme eq 'mailto') { + return 1 if (is_email ($1)); + } + elsif ($scheme eq 'strict_mailto') { + return 1 if (is_email ($1,1)); + } } } } @@ -177,22 +184,22 @@ BEGIN { # credits to an unknown(?) programmer ;) # modified by n.d.p. - my $lowalpha = '(?:[a-z])'; - my $hialpha = '(?:[A-Z])'; - my $alpha = "(?:$lowalpha|$hialpha)"; - my $digit = '(?:\d)'; - my $safe = '(?:[$_.+-])'; - my $extra = '(?:[!*\'(),])'; - my $national = '(?:[{}|\\\\^~\[\]`])'; - my $punctuation = '(?:[<>#%"])'; - my $reserved = '(?:[;/?:@&=])'; - my $hex = '(?:[\dA-Fa-f])'; + my $lowalpha = '[a-z]'; + my $hialpha = '[A-Z]'; + my $alpha = '[a-zA-Z]'; + my $digit = '\d'; + my $safe = '[$_.+-]'; + my $extra = '[!*\'(),]'; + my $national = '[{}|\\\\^~\[\]`]'; + my $punctuation = '[<>#%"]'; + my $reserved = '[;/?:@&=]'; + my $hex = '[\dA-Fa-f]'; my $escape = "(?:%$hex$hex)"; - my $unreserved = "(?:$alpha|$digit|$safe|$extra)"; + my $unreserved = '[{}|\\\\^~\[\]`a-zA-Z\d$_.+-]'; #"(?:$alpha|$digit|$safe|$extra)"; my $uchar = "(?:$unreserved|$escape)"; my $xchar = "(?:$unreserved|$escape|$reserved)"; my $digits = '(?:\d+)'; - my $alphadigit = "(?:$alpha|\\d)"; + my $alphadigit = '[a-zA-Z\d]'; #"(?:$alpha|$digit)"; # URL schemeparts for ip based protocols: my $urlpath = "(?:$xchar*)";