From 74fb241903e482f99b98cf5194ea266bc84633d0 Mon Sep 17 00:00:00 2001 From: PJ Hampton Date: Tue, 29 Aug 2017 20:33:26 +0100 Subject: [PATCH] Fix over triggering on dates. (#4463) --- lib/DDG/Goodie/Calculator.pm | 1 + t/Calculator.t | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/DDG/Goodie/Calculator.pm b/lib/DDG/Goodie/Calculator.pm index 38b4fe32e..cc605f48b 100644 --- a/lib/DDG/Goodie/Calculator.pm +++ b/lib/DDG/Goodie/Calculator.pm @@ -195,6 +195,7 @@ handle query => sub { return if $query =~ m/^\)|\($/; # shouldn't open with a closing brace or finish with an opening brace return if $query =~ m/(a?cosh?|tau|a?sin|a?tan|log|ln|exp|tanh|cbrt|cubed?)e?$/i; # stops empty functions at end or with e return if $query =~ m#(?:x(\^|/)|(\^|/)x)#; # stops triggering on what is most likely algebra + return if $query =~ m#^\d{1,2}/\d{1,2}/\d{2,4}$#; return if $query =~ m#^0\d+/\d+$#; # some shallow preprocessing of the query diff --git a/t/Calculator.t b/t/Calculator.t index 26b1f4015..7ccf4ba4a 100644 --- a/t/Calculator.t +++ b/t/Calculator.t @@ -544,6 +544,10 @@ ddg_goodie_test( '24score' => undef, '24 score' => undef, '06026/6126' => undef, + '7/7/2014' => undef, + '2/3/09' => undef, + '21/12/2012' => undef, + '12/21/2012' => undef, ); done_testing;