Skip to content

Commit

Permalink
bug #20286 [Serializer] Fix DataUriNormalizer's regex (dunglas)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.1 branch (closes #20286).

Discussion
----------

[Serializer] Fix DataUriNormalizer's regex

| Q | A |
| --- | --- |
| Branch? | 3.1 |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #20225 |
| License | MIT |
| Doc PR | n/a |

Commits
-------

5dc5dc8 [Serializer] Fix DataUriNormalizer's regex
  • Loading branch information
fabpot committed Nov 11, 2016
2 parents a524ba5 + 5dc5dc8 commit 75e0046
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -85,7 +85,7 @@ public function supportsNormalization($data, $format = null)
*/
public function denormalize($data, $class, $format = null, array $context = array())
{
if (!preg_match('/^data:([a-z0-9]+\/[a-z0-9]+(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
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)) {
throw new UnexpectedValueException('The provided "data:" URI is not valid.');
}

Expand Down

0 comments on commit 75e0046

Please sign in to comment.