Add support for javascript object notation in allowed JSONP callback
This commit is contained in:
parent
18132c18b4
commit
4fa8e68cdc
@ -55,8 +55,11 @@ class JsonResponse extends Response
|
|||||||
if ($callback) {
|
if ($callback) {
|
||||||
// taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/
|
// 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';
|
$pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u';
|
||||||
if (!preg_match($pattern, $callback)) {
|
$parts = explode('.', $callback);
|
||||||
throw new \InvalidArgumentException('The callback name is not valid.');
|
foreach ($parts as $part) {
|
||||||
|
if (!preg_match($pattern, $part)) {
|
||||||
|
throw new \InvalidArgumentException('The callback name is not valid.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user