Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Catch Throwable in timezone validation #16344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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