From 638cce2d190fd55352d2c7ad5bb9bfc62f1c687e Mon Sep 17 00:00:00 2001 From: Russ Rowan Date: Wed, 23 Nov 2005 16:14:57 -0500 Subject: [PATCH] The URL checking now has its own subroutine. --- contrib/perl/hooks.pl | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/contrib/perl/hooks.pl b/contrib/perl/hooks.pl index b614ffcd..b61de668 100644 --- a/contrib/perl/hooks.pl +++ b/contrib/perl/hooks.pl @@ -1056,25 +1056,7 @@ using the search engine defined by the 'search' configuration option if # Anything not otherwise useful is a search if ($current_url and loadrc("gotosearch") eq "yes") { - opendir(DIR, '.'); - 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); + return search(loadrc("search"), $url) if isurl($url) =~ 'false'; } @@ -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