Use filter_id() for the url_param and form_param Twig functions

This is a follow-up to 80263a91dc
This commit is contained in:
Daniel Rudolf 2018-02-24 16:40:00 +01:00
parent 80263a91dc
commit 05c2c968c3
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538

View file

@ -303,7 +303,8 @@ class PicoTwigExtension extends Twig_Extension
*/
public function urlParamFunction($name, $filter = '', $options = null, $flags = null)
{
if (($filter === 'callback') || ($filter === FILTER_CALLBACK)) {
$filter = $filter ? (is_string($filter) ? filter_id($filter) : (int) $filter) : false;
if (!$filter || ($filter === FILTER_CALLBACK)) {
return false;
}
@ -331,7 +332,8 @@ class PicoTwigExtension extends Twig_Extension
*/
public function formParamFunction($name, $filter = '', $options = null, $flags = null)
{
if (($filter === 'callback') || ($filter === FILTER_CALLBACK)) {
$filter = $filter ? (is_string($filter) ? filter_id($filter) : (int) $filter) : false;
if (!$filter || ($filter === FILTER_CALLBACK)) {
return false;
}