From 4bfcb5fa14d9a089bf8e92724f4c27cd2c835e99 Mon Sep 17 00:00:00 2001 From: GlitchMr Date: Fri, 28 Sep 2012 10:30:28 +0200 Subject: [PATCH] Don't allow silly timezones like GMT+31421858231489. --- lib/DDG/Goodie/TimezoneConverter.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/DDG/Goodie/TimezoneConverter.pm b/lib/DDG/Goodie/TimezoneConverter.pm index 89f094cef..46c597661 100644 --- a/lib/DDG/Goodie/TimezoneConverter.pm +++ b/lib/DDG/Goodie/TimezoneConverter.pm @@ -75,6 +75,7 @@ sub to_time(_) { } handle query => sub { + my $timezone = qr/(\w+(?:\s*[+-]0*[0-9]{1,5}(?::[0-5][0-9])?)?)?/; my ( # Time $hour, $minutes, $seconds, $pm, @@ -102,7 +103,7 @@ handle query => sub { # Spaces between tokens \s* \b # Optional input timezone - (\w+ (?: \s* [+-]\d+ (?: : \d\d )? )? )? + $timezone # Spaces \s+ # in keywords @@ -110,7 +111,7 @@ handle query => sub { # Spaces \s+ # Output timezone - (\w+ (?: \s* [+-]\d+ (?: : \d\d )? )? )? + $timezone \s* \z }x or return;