From cc1753acab662fd2a3808d9f95c49d4d467a7e4a Mon Sep 17 00:00:00 2001 From: lernae Date: Fri, 21 Apr 2017 18:29:13 -0400 Subject: [PATCH] Fixes #4102 Calendar: Shouldn't trigger on query for calendar.google.com (#4114) --- lib/DDG/Goodie/CalendarToday.pm | 4 ++++ t/CalendarToday.t | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/DDG/Goodie/CalendarToday.pm b/lib/DDG/Goodie/CalendarToday.pm index db5986b7b..cd20ee7d1 100755 --- a/lib/DDG/Goodie/CalendarToday.pm +++ b/lib/DDG/Goodie/CalendarToday.pm @@ -24,6 +24,10 @@ my $relative_dates_regex = relative_dates_regex(); handle remainder => sub { my $query = $_; + + # return if there is no remainder and query_lc is not 'calendar' + return if($query eq '' && $req->query_lc ne 'calendar'); + my $date_object = DateTime->now; my ($currentDay, $currentMonth, $currentYear) = ($date_object->day(), $date_object->month(), $date_object->year()); my $highlightDay = 0; # Initialized, but won't match, by default. diff --git a/t/CalendarToday.t b/t/CalendarToday.t index 6c33fa98a..6bb48eaf5 100755 --- a/t/CalendarToday.t +++ b/t/CalendarToday.t @@ -377,6 +377,8 @@ S M T W T F S November 2009 } } ), + # Invalid input + 'calendar.google.com' => undef, ); # Special focus on relative dates, examining the "today" circle