mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding fixes for test added in [4911] and [4912]
Fixed #2414 fixes findBy doesn't escape WHERE condition git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4913 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6978359505
commit
5757d6b7e9
2 changed files with 8 additions and 5 deletions
|
@ -1569,7 +1569,7 @@ class DboSource extends DataSource {
|
|||
$data = $this->name($key) . " = " . $this->boolean($value);
|
||||
} elseif ($value === '') {
|
||||
$data = $this->name($key) . " = ''";
|
||||
} elseif (preg_match('/^([a-z]*\\([a-z0-9]*\\)\\x20?|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/i', $value, $match)) {
|
||||
} elseif (preg_match('/^([a-z]+\\([a-z0-9]*\\)\\x20+|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/i', $value, $match)) {
|
||||
if (preg_match('/(\\x20[\\w]*\\x20)/', $key, $regs)) {
|
||||
$clause = $regs['1'];
|
||||
$key = preg_replace('/' . $regs['1'] . '/', '', $key);
|
||||
|
@ -1581,6 +1581,9 @@ class DboSource extends DataSource {
|
|||
} elseif (empty($mValue)) {
|
||||
$match['1'] = ' = ';
|
||||
$match['2'] = $match['0'];
|
||||
} elseif(!isset($match['2'])) {
|
||||
$match['1'] = ' = ';
|
||||
$match['2'] = $match['0'];
|
||||
}
|
||||
|
||||
if (strpos($match['2'], '-!') === 0) {
|
||||
|
@ -1588,7 +1591,7 @@ class DboSource extends DataSource {
|
|||
$data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
|
||||
} else {
|
||||
if (!empty($match['2']) && $quoteValues) {
|
||||
if (strpos($match['2'], '()') === false) {
|
||||
if(!preg_match('/[A-Za-z]+\\([a-z0-9]*\\),?\\x20+/', $match['2'])) {
|
||||
$match['2'] = $this->value($match['2']);
|
||||
}
|
||||
$match['2'] = str_replace(' AND ', "' AND '", $match['2']);
|
||||
|
|
|
@ -1469,9 +1469,9 @@ class DboSourceTest extends UnitTestCase {
|
|||
$result = $this->db->conditions(array('id' => '<> 8'));
|
||||
$this->assertPattern('/^\s*WHERE\s+`id`\s+<>\s+8\s*$/', $result);
|
||||
|
||||
//$result = $this->db->conditions(array('TestModel.field' => '= gribe$@()lu'));
|
||||
//$expected = " WHERE `TestModel.field` = 'gribe$@()lu'";
|
||||
//$this->assertEqual($result, $expected);
|
||||
$result = $this->db->conditions(array('TestModel.field' => '= gribe$@()lu'));
|
||||
$expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testFieldParsing() {
|
||||
|
|
Loading…
Add table
Reference in a new issue