From 21a9904a71b24e753049a31a47b6dab26fde6743 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 21 Feb 2011 17:55:15 -0300 Subject: [PATCH] Adding a protection to cake console be executed in driver root (windows). Fixes #1408. --- cake/console/cake.bat | 2 +- cake/console/cake.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/console/cake.bat b/cake/console/cake.bat index 7e35cfcb9..87ee1c7d9 100644 --- a/cake/console/cake.bat +++ b/cake/console/cake.bat @@ -26,7 +26,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. diff --git a/cake/console/cake.php b/cake/console/cake.php index a4c89b520..f5cf287e4 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -501,6 +501,9 @@ class ShellDispatcher { } $params = str_replace('\\', '/', $params); + if (isset($params['working'])) { + $params['working'] = trim($params['working']); + } if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { if (empty($this->params['app']) && $params['working'] != $params['root']) { $params['root'] = dirname($params['working']); @@ -516,8 +519,10 @@ class ShellDispatcher { $params['root'] .= '/' . dirname($params['app']); } - $params['app'] = basename($params['app']); - $params['working'] = rtrim($params['root'], '/') . '/' . $params['app']; + $params['working'] = rtrim($params['root'], '/'); + if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) { + $params['working'] .= '/' . $params['app']; + } if (!empty($matches[0]) || !empty($isWin)) { $params = str_replace('/', '\\', $params);