Navigation Menu

Skip to content

Commit

Permalink
Fixing issue in DboSource::name() where special characters in column …
Browse files Browse the repository at this point in the history
…names would not be correctly quoted.

Tests added.
Fixes #1264
  • Loading branch information
markstory committed Nov 25, 2010
1 parent 7d158e8 commit 15ca240
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo_source.php
Expand Up @@ -542,7 +542,7 @@ function name($data) {
return $return;
}
$data = trim($data);
if (preg_match('/^[\w-]+(\.[\w-]+)*$/', $data)) { // string, string.string
if (preg_match('/^[\w-]+(?:\.[^ \*]*)*$/', $data)) { // string, string.string
if (strpos($data, '.') === false) { // string
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
}
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -4077,6 +4077,10 @@ function testName() {
$result = $this->testDb->name(array('my-name', 'Foo-Model.*'));
$expected = array('`my-name`', '`Foo-Model`.*');
$this->assertEqual($result, $expected);

$result = $this->testDb->name(array('Team.P%', 'Team.G/G'));
$expected = array('`Team`.`P%`', '`Team`.`G/G`');
$this->assertEqual($result, $expected);
}

/**
Expand Down

0 comments on commit 15ca240

Please sign in to comment.