1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

The URL checking now has its own subroutine.

This commit is contained in:
Russ Rowan 2005-11-23 16:14:57 -05:00
parent 917b310cdb
commit 638cce2d19

View File

@ -1056,25 +1056,7 @@ using the search engine defined by the 'search' configuration option if
# Anything not otherwise useful is a search # Anything not otherwise useful is a search
if ($current_url and loadrc("gotosearch") eq "yes") if ($current_url and loadrc("gotosearch") eq "yes")
{ {
opendir(DIR, '.'); return search(loadrc("search"), $url) if isurl($url) =~ 'false';
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files)
{
return $url if $url eq $file;
}
return $url if $url =~ /^(\/|~)/;
return $url if $url =~ /([0-9]{1,3}\.){3}[0-9]{1,3}($|\/|\?|:[0-9]{1,5})/;
return $url if $url =~ /^((::|)[[:xdigit:]]{1,4}(:|::|)){1,8}($|\/|\?|:[0-9]{1,5})/ and $url =~ /:/;
if ( $url =~ /^(([a-zA-Z]{3,}(|4|6):\/\/|(www|ftp)\.)|)[a-zA-Z0-9]+/
and ($url =~ /[a-zA-Z0-9-]+\.(com|org|net|edu|gov|int|mil)($|\/|\?|:[0-9]{1,5})/
or $url =~ /[a-zA-Z0-9-]+\.(biz|info|name|pro|aero|coop|museum)($|\/|\?|:[0-9]{1,5})/
or $url =~ /[a-zA-Z0-9-]+\.[a-zA-Z]{2}($|\/|\?|:[0-9]{1,5})/))
{
return $url;
}
return $url if $url =~ /^about:/;
return search(loadrc("search"), $url);
} }
@ -1393,4 +1375,31 @@ Russ Rowan, Petr Baudis
sub isurl
{
my ($url) = @_;
opendir(DIR, '.');
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files)
{
return 'true' if $url eq $file;
}
return 'true' if $url =~ /^(\/|~)/;
return 'true' if $url =~ /([0-9]{1,3}\.){3}[0-9]{1,3}($|\/|\?|:[0-9]{1,5})/;
return 'true' if $url =~ /^((::|)[[:xdigit:]]{1,4}(:|::|)){1,8}($|\/|\?|:[0-9]{1,5})/ and $url =~ /:/;
if ( $url =~ /^(([a-zA-Z]{3,}(|4|6):\/\/|(www|ftp)\.)|)[a-zA-Z0-9]+/
and ($url =~ /[a-zA-Z0-9-]+\.(com|org|net|edu|gov|int|mil)($|\/|\?|:[0-9]{1,5})/
or $url =~ /[a-zA-Z0-9-]+\.(biz|info|name|pro|aero|coop|museum)($|\/|\?|:[0-9]{1,5})/
or $url =~ /[a-zA-Z0-9-]+\.[a-zA-Z]{2}($|\/|\?|:[0-9]{1,5})/))
{
return 'true';
}
return 'true' if $url =~ /^about:/;
return 'false';
}
# vim: ts=4 sw=4 sts=0 nowrap # vim: ts=4 sw=4 sts=0 nowrap