merging 1.2

This commit is contained in:
gwoo 2009-05-04 15:57:10 -07:00
parent 94c01ac7b4
commit 6535e6225c
6 changed files with 39 additions and 9 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ // // +---------------------------------------------------------------------------------------------------+ //
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
1.2.2.8120 1.2.3.8166

View file

@ -22,5 +22,5 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
return $config['Cake.version'] = '1.2.2.8120'; return $config['Cake.version'] = '1.2.3.8166';
?> ?>

View file

@ -344,7 +344,8 @@ class Dispatcher extends Object {
return $this->base = $base; return $this->base = $base;
} }
if (!$baseUrl) { if (!$baseUrl) {
$base = dirname(env('PHP_SELF')); $replace = array('<', '>', '*', '\'', '"');
$base = str_replace($replace, '', dirname(env('PHP_SELF')));
if ($webroot === 'webroot' && $webroot === basename($base)) { if ($webroot === 'webroot' && $webroot === basename($base)) {
$base = dirname($base); $base = dirname($base);

View file

@ -1010,7 +1010,10 @@ class Model extends Overloadable {
} }
if ($id !== null && $id !== false) { if ($id !== null && $id !== false) {
$this->data = $this->find(array($this->alias . '.' . $this->primaryKey => $id), $fields); $this->data = $this->find('first', array(
'conditions' => array($this->alias . '.' . $this->primaryKey => $id),
'fields' => $fields
));
return $this->data; return $this->data;
} else { } else {
return false; return false;

View file

@ -1898,6 +1898,23 @@ class DispatcherTest extends CakeTestCase {
unset($_POST['_method']); unset($_POST['_method']);
} }
/**
* Tests that invalid characters cannot be injected into the application base path.
*
* @return void
*/
function testBasePathInjection() {
$self = $_SERVER['PHP_SELF'];
$_SERVER['PHP_SELF'] = urldecode(
"/index.php/%22%3E%3Ch1%20onclick=%22alert('xss');%22%3Eheya%3C/h1%3E"
);
$dispatcher =& new Dispatcher();
$result = $dispatcher->baseUrl();
$expected = '/index.php/h1 onclick=alert(xss);heya';
$this->assertEqual($result, $expected);
}
/** /**
* testEnvironmentDetection method * testEnvironmentDetection method
* *

View file

@ -658,14 +658,23 @@ class RouterTest extends CakeTestCase {
Router::reload(); Router::reload();
Router::setRequestInfo(array( Router::setRequestInfo(array(
array('plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'admin_edit', 'pass' => array(
array(0 => '6'), 'prefix' => 'admin', 'admin' => true, 'form' => array(), 'url' => 'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'admin_edit',
array('url' => 'admin/shows/show_tickets/edit/6')), 'pass' => array('6'), 'prefix' => 'admin', 'admin' => true, 'form' => array(),
array('plugin' => NULL, 'controller' => NULL, 'action' => NULL, 'base' => '', 'here' => '/admin/shows/show_tickets/edit/6', 'webroot' => '/'))); 'url' => array('url' => 'admin/shows/show_tickets/edit/6')
),
array(
'plugin' => null, 'controller' => null, 'action' => null, 'base' => '',
'here' => '/admin/shows/show_tickets/edit/6', 'webroot' => '/'
)
));
Router::parse('/'); Router::parse('/');
$result = Router::url(array('plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6', 'admin' => true, 'prefix' => 'admin', )); $result = Router::url(array(
'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6',
'admin' => true, 'prefix' => 'admin'
));
$expected = '/admin/shows/show_tickets/edit/6'; $expected = '/admin/shows/show_tickets/edit/6';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }