[英]Allow param containing slashes in Zend_Controller_Router_Route_Regex
This is my code: 这是我的代码:
$route = new Zend_Controller_Router_Route_Regex('download/([^/]+)(/([^/]+))?/(\d+)/(\d+)',
array('controller' => 'download',
'action' => 'load'),
array(1 => 'name', 3 => 'or_name',
4 => 'p_id', 5 => 'c_id'));
$router->addRoute('download', $route);
The first param should be allowed to contain slashes but in urlencoded form. 应该允许第一个参数包含反斜杠,但必须为反斜杠形式。 But unfortunately it's not working with my current code, it gives me a 404 error instead.
但不幸的是,它不适用于我当前的代码,而是给我一个404错误。
So, is it possible to prevent route parameters from being urldecoded? 因此,是否可以防止对路由参数进行url解码?
Within Zend_Controller_Router_Route_Regex::match
, it calls urlencode
on the path right away: 在
Zend_Controller_Router_Route_Regex::match
,它立即在路径上调用urlencode
:
$path = trim(urldecode($path), '/');
To defeat that, try urlencoding
your name
parameter twice: 要解决这个问题,请尝试对您的
name
参数进行两次urlencoding
:
$url = 'download/'.urlencode(urlencode('hey/there'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.