// Fix dispatcher links

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12946 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard committed 2012-02-02 18:43:17 +00:00
1 parent 206950d894
commit 132bb576c8
3 files changed
+11 -5

No files matched your search

+4 -3
View File
@@ -255,7 +255,7 @@ class DispatcherCore
// Dispatch module controller for front office // Dispatch module controller for front office
case self::FC_MODULE : case self::FC_MODULE :
$module_name = Tools::getValue('module'); $module_name = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : '';
$module = Module::getInstanceByName($module_name); $module = Module::getInstanceByName($module_name);
$controller_class = 'PageNotFoundController'; $controller_class = 'PageNotFoundController';
if (Validate::isLoadedObject($module) && $module->active) if (Validate::isLoadedObject($module) && $module->active)
@@ -537,7 +537,7 @@ class DispatcherCore
$controller = Tools::getValue('controller'); $controller = Tools::getValue('controller');
if (isset($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m))
{ {
$controller = $m[1]; $controller = $m[1];
if (isset($_GET['controller'])) if (isset($_GET['controller']))
@@ -545,7 +545,8 @@ class DispatcherCore
else if (isset($_POST['controller'])) else if (isset($_POST['controller']))
$_POST[$m[2]] = $m[3]; $_POST[$m[2]] = $m[3];
} }
if (!Validate::isControllerName($controller))
$controller = false;
// Use routes ? (for url rewriting) // Use routes ? (for url rewriting)
if ($this->use_routes && !$controller) if ($this->use_routes && !$controller)
{ {
+6 -1
View File
@@ -197,7 +197,7 @@ class ValidateCore
*/ */
public static function isModuleName($module_name) public static function isModuleName($module_name)
{ {
return preg_match('/^[a-zA-Z0-9_-]+$/', $module_name); return (is_string($module_name) && preg_match('/^[a-zA-Z0-9_-]+$/', $module_name));
} }
/** /**
@@ -987,6 +987,11 @@ class ValidateCore
{ {
return (bool)preg_match('/^[0-9]{3,4}[a-zA-Z]{1}$/s', $ape); return (bool)preg_match('/^[0-9]{3,4}[a-zA-Z]{1}$/s', $ape);
} }
public static function isControllerName($name)
{
return (bool)(is_string($name) && preg_match('/^[0-9a-zA-Z-_]*$/u', $name));
}
} }
+1 -1
View File
@@ -573,7 +573,7 @@ class FrontControllerCore extends Controller
header('HTTP/1.0 301 Moved'); header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.$strParams.'">'.$canonicalURL.$strParams.'</a>'); die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.Tools::safeOutput($strParams).'">'.$canonicalURL.Tools::safeOutput($strParams).'</a>');
Tools::redirectLink($canonicalURL.$strParams); Tools::redirectLink($canonicalURL.$strParams);
} }
} }