8000 [Serializer] Don't pass null to preg_match() · symfony/symfony@4e6ea37 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e6ea37

Browse files
committed
[Serializer] Don't pass null to preg_match()
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent bdb0df9 commit 4e6ea37

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ public function supportsNormalization($data, $format = null)
109109
*/
110110
public function denormalize($data, $type, $format = null, array $context = [])
111111
{
112-
if (!preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
112+
if (null === $data || !preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
113113
throw new NotNormalizableValueException('The provided "data:" URI is not valid.');
114114
}
115115

116116
try {
117117
switch ($type) {
118-
case 'Symfony\Component\HttpFoundation\File\File':
118+
case File::class:
119119
return new File($data, false);
120120

121121
case 'SplFileObject':
7CE6

src/Symfony/Component/Serializer/Tests/Normalizer/DataUriNormalizerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public function invalidUriProvider()
139139
['data:text/html;charset,%3Ch1%3EHello!%3C%2Fh1%3E'],
140140
['data:base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC'],
141141
[''],
142+
[null],
142143
['http://wikipedia.org'],
143144
['base64'],
144145
['iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC'],

0 commit comments

Comments
 (0)
0