From 4768a4d8821008793ad1ede12a56346cb5f9bb67 Mon Sep 17 00:00:00 2001 From: Nalin Bhardwaj Date: Thu, 28 Sep 2017 23:10:31 +0530 Subject: [PATCH] fix file extension regex (#4510) --- lib/DDG/Goodie/Calculator.pm | 2 +- t/Calculator.t | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/DDG/Goodie/Calculator.pm b/lib/DDG/Goodie/Calculator.pm index 2fdd9c371..5647a196d 100644 --- a/lib/DDG/Goodie/Calculator.pm +++ b/lib/DDG/Goodie/Calculator.pm @@ -186,7 +186,7 @@ handle query => sub { return if $req->query_lc =~ /^0x/i; # hex maybe? return if $query =~ /\d+(?:X|x)\.?$/; # websites such as 1337X return if $query =~ /score$/; - return if $query =~ /^(?:\.\w+)/; # Probably looking at file extensions + return if ( $query =~ /^(?:\.\w+)/ && $query !~ $number_re); # Probably looking at file extensions return if $query =~ $network; # Probably want to talk about addresses, not calculations. return if $query =~ m/^(\+?\d{1,2}(\s|-)?|\(\d{2})?\(?\d{3,4}\)?(\s|-)?\d{3}(\s|-)?\d{3,4}(\s?x\d+)?$/; # Probably are searching for a phone number, not making a calculation return if $query =~ m/^\(\d+\)\s+\d+\d+/; diff --git a/t/Calculator.t b/t/Calculator.t index c49372ade..5b4207fd7 100644 --- a/t/Calculator.t +++ b/t/Calculator.t @@ -387,6 +387,12 @@ ddg_goodie_test( 'fact 20' => build_test( '20!' ), + '.32 * 100' => build_test( + '.32 * 100' + ), + '.7 + .32' => build_test( + '.7 + .32' + ), ## Trig testing 'tan 45' => build_test( @@ -551,6 +557,8 @@ ddg_goodie_test( '2/3/09' => undef, '21/12/2012' => undef, '12/21/2012' => undef, + '.7zip * 100' => undef, + '.tar64 + 0.3' => undef, ); done_testing;