Skip to content

Commit

Permalink
Catch Throwable in timezone validation (#16344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Hauberg authored and taylorotwell committed Nov 10, 2016
1 parent 10a3fe3 commit c2e4b5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use DateTime;
use Countable;
use Exception;
use Throwable;
use DateTimeZone;
use RuntimeException;
use DateTimeInterface;
Expand Down Expand Up @@ -1976,6 +1977,8 @@ protected function validateTimezone($attribute, $value)
new DateTimeZone($value);
} catch (Exception $e) {
return false;
} catch (Throwable $e) {
return false;
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,9 @@ public function testValidateTimezone()

$v = new Validator($trans, ['foo' => 'GMT'], ['foo' => 'Timezone']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => ['this_is_not_a_timezone']], ['foo' => 'Timezone']);
$this->assertFalse($v->passes());
}

public function testValidateRegex()
Expand Down

0 comments on commit c2e4b5c

Please sign in to comment.