Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9.0
-
Fix Version/s: 1.10.0
-
Component/s: Zend_Controller
-
Labels:None
Description
Reproduce code:
$userRoute = new Zend_Controller_Router_Route_Hostname(':nickname..'.$configuration->general->domain, array('controller'=>'profile', 'action'=>'view')); $userActionsRoute = new Zend_Controller_Router_Route(':action/*', array('action'=>'view')); $router->addRoute('uActionsRoute', $userRoute->chain($userActionsRoute));
This have the simple purpose to have URLs like:
username.domain.com/action/*, for example john.domain.com/image/id/76
but in ZF 1.8.1 the above route 'uActionsRoute' does not match such URLs. This is because in Controller/Router/Route.php there is a bug in match() method - when matching wildcard variables, $matchedPath is not updated.
Proposed fix:
// Path is longer than a route, it's not a match if (!array_key_exists($pos, $this->_parts)) { if ($partial) { break; } else { return false; } } // If it's a wildcard, get the rest of URL as wildcard data and stop matching if ($this->_parts[$pos] == '*') { $count = count($path); for($i = $pos; $i < $count; $i+=2) { $var = urldecode($path[$i]); //start fix: $matchedPath .= $path[$i] . $this->_urlDelimiter; if (isset ($path[$i+1])) { $matchedPath .= $path[$i+1] . $this->_urlDelimiter; } //end fix if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var]) && !isset($values[$var])) { $this->_wildcardData[$var] = (isset($path[$i+1])) ? urldecode($path[$i+1]) : null; } } break; } //fix: moved this after the above IF block $matchedPath .= $pathPart . $this->_urlDelimiter; //end fix $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null; $pathPart = urldecode($pathPart); // and so on...
Assigning to Ben to triage.