Skip to content

Commit 38946b4

Browse files
[12.x] Document image rule SVG security changes (#10136)
* Update validation.md * Update validation.md * Update validation.md * Update validation.md * Update validation.md * Remove extra new line * Revert "Remove extra new line" This reverts commit 8cadafd. * Revert "Update validation.md" This reverts commit aa684e6. * Revert "Update validation.md" This reverts commit 84f56ee. * Revert "Update validation.md" This reverts commit d262a82. * Update validation.md * fix commas * Revert "fix commas" This reverts commit a9749b7. * formatting * Update validation.md * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent bb0d238 commit 38946b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

validation.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,10 @@ The field under validation must contain a valid color value in [hexadecimal](htt
14791479
<a name="rule-image"></a>
14801480
#### image
14811481

1482-
The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp).
1482+
The file under validation must be an image (jpg, jpeg, png, bmp, gif, or webp).
1483+
1484+
> [!WARNING]
1485+
> By default, the image rule does not allow SVG files due to the possibility of XSS vulnerabilities. If you need to allow SVG files, you may provide the `allow_svg` directive to the `image` rule (`image:allow_svg`).
14831486
14841487
<a name="rule-in"></a>
14851488
#### in:_foo_,_bar_,...
@@ -2202,7 +2205,9 @@ Laravel provides a variety of validation rules that may be used to validate uplo
22022205
],
22032206
]);
22042207

2205-
If your application accepts images uploaded by your users, you may use the `File` rule's `image` constructor method to indicate that the uploaded file should be an image. In addition, the `dimensions` rule may be used to limit the dimensions of the image:
2208+
If your application accepts images uploaded by your users, you may use the `File` rule's `image` constructor method to ensure that the file under validation is an image (jpg, jpeg, png, bmp, gif, or webp).
2209+
2210+
In addition, the `dimensions` rule may be used to limit the dimensions of the image:
22062211

22072212
use Illuminate\Support\Facades\Validator;
22082213
use Illuminate\Validation\Rule;
@@ -2221,6 +2226,9 @@ If your application accepts images uploaded by your users, you may use the `File
22212226
> [!NOTE]
22222227
> More information regarding validating image dimensions may be found in the [dimension rule documentation](#rule-dimensions).
22232228
2229+
> [!WARNING]
2230+
> By default, the `image` rule does not allow SVG files due to the possibility of XSS vulnerabilities. If you need to allow SVG files, you may pass `allowSvg: true` to the `image` rule: `File::image(allowSvg: true)`.
2231+
22242232
<a name="validating-files-file-sizes"></a>
22252233
#### File Sizes
22262234

0 commit comments

Comments
 (0)