merged branch aripringle/master (PR #4333)

Commits
-------

4fa8e68 Add support for javascript object notation in allowed JSONP callback

Discussion
----------

Add support for javascript object notation in allowed JSONP callback

---------------------------------------------------------------------------

by travisbot at 2012-05-18T23:09:45Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1371497) (merged 4fa8e68c into 18132c18).
This commit is contained in:
Fabien Potencier 2012-05-22 11:56:42 +02:00
commit 3ab88f23b9

View File

@ -55,8 +55,11 @@ class JsonResponse extends Response
if ($callback) {
// taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/
$pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u';
if (!preg_match($pattern, $callback)) {
throw new \InvalidArgumentException('The callback name is not valid.');
$parts = explode('.', $callback);
foreach ($parts as $part) {
if (!preg_match($pattern, $part)) {
throw new \InvalidArgumentException('The callback name is not valid.');
}
}
}