8000 Improve the regex · symfony/symfony@60fadea · GitHub
[go: up one dir, main page]

Skip to content

Commit 60fadea

Browse files
committed
Improve the regex
1 parent c6346d9 commit 60fadea

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function supportsNormalization($data, $format = null)
8585
*/
8686
public function denormalize($data, $class, $format = null, array $context = array())
8787
{
88-
if (!preg_match('/^data:([a-z0-9]+\/[a-z0-9\-\.\+]+(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
88+
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)) {
8989
throw new UnexpectedValueException('The provided "data:" URI is not valid.');
9090
}
9191

0 commit comments

Comments
 (0)
0