summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-08-15 15:42:14 +0200
committerThomas Bruederli <thomas@roundcube.net>2012-08-15 15:42:14 +0200
commit13969cf5406c14ba5dd5f830d7a8e2e2134e244b (patch)
treef1107025202acd7d0048f4020b0de09e00e0a850
parent0db8d00d298f8f67d6843f016a5a6259edff9f96 (diff)
Skip ? in quoted values from being replaced with parameters
-rw-r--r--program/include/rcube_db.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php
index f97d70ab3..eb1ad31b2 100644
--- a/program/include/rcube_db.php
+++ b/program/include/rcube_db.php
@@ -388,13 +388,19 @@ class rcube_db
$idx = 0;
while ($pos = strpos($query, '?', $pos)) {
- $val = $this->quote($params[$idx++]);
- unset($params[$idx-1]);
- $query = substr_replace($query, $val, $pos, 1);
- $pos += strlen($val);
+ if ($query[$pos+1] == '?') { // skip escaped ?
+ $pos += 2;
+ }
+ else {
+ $val = $this->quote($params[$idx++]);
+ unset($params[$idx-1]);
+ $query = substr_replace($query, $val, $pos, 1);
+ $pos += strlen($val);
+ }
}
- $query = rtrim($query, ';');
+ // replace escaped ? back to normal
+ $query = rtrim(strtr($query, array('??' => '?')), ';');
$this->debug($query);
@@ -591,7 +597,7 @@ class rcube_db
'integer' => PDO::PARAM_INT,
);
$type = isset($map[$type]) ? $map[$type] : PDO::PARAM_STR;
- return $this->dbh->quote($input, $type);
+ return strtr($this->dbh->quote($input, $type), array('?' => '??')); // escape ?
}
return 'NULL';