Skip to content

Commit

Permalink
Merge pull request #29309 from bomshteyn/5.8
Browse files Browse the repository at this point in the history
[5.8] Add WEBP to image validation rule
  • Loading branch information
taylorotwell authored Jul 29, 2019
2 parents af46990 + 0ecc258 commit 873af2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ public function validateLte($attribute, $value, $parameters)
*/
public function validateImage($attribute, $value)
{
return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg']);
return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,12 @@ public function testValidateImage()
$file6->expects($this->any())->method('getClientOriginalExtension')->will($this->returnValue('svg'));
$v = new Validator($trans, ['x' => $file6], ['x' => 'Image']);
$this->assertTrue($v->passes());

$file7 = $this->getMockBuilder(UploadedFile::class)->setMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock();
$file7->expects($this->any())->method('guessExtension')->will($this->returnValue('webp'));
$file7->expects($this->any())->method('getClientOriginalExtension')->will($this->returnValue('webp'));
$v = new Validator($trans, ['x' => $file7], ['x' => 'Image']);
$this->assertTrue($v->passes());
}

public function testValidateImageDoesNotAllowPhpExtensionsOnImageMime()
Expand Down

0 comments on commit 873af2a

Please sign in to comment.