Skip to content

Commit 55acc8b

Browse files
author
Derek Jones
committed
fixed a bug with _protect_identifiers() and db/swap prefixes. It was appending the prefix, but not accounting for the need to swap
1 parent 8c52996 commit 55acc8b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

system/database/DB_driver.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,13 @@ function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifier
13091309
{
13101310
$i++;
13111311
}
1312-
1312+
1313+
// Verify table prefix and replace if necessary
1314+
if ($this->swap_pre != '' && strncmp($parts[$i], $this->swap_pre, strlen($this->swap_pre)) === 0)
1315+
{
1316+
$parts[$i] = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $parts[$i]);
1317+
}
1318+
13131319
// We only add the table prefix if it does not already exist
13141320
if (substr($parts[$i], 0, strlen($this->dbprefix)) != $this->dbprefix)
13151321
{
@@ -1331,6 +1337,12 @@ function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifier
13311337
// Is there a table prefix? If not, no need to insert it
13321338
if ($this->dbprefix != '')
13331339
{
1340+
// Verify table prefix and replace if necessary
1341+
if ($this->swap_pre != '' && strncmp($item, $this->swap_pre, strlen($this->swap_pre)) === 0)
1342+
{
1343+
$item = preg_replace("/^".$this->swap_pre."(\S+?)/", $this->dbprefix."\\1", $item);
1344+
}
1345+
13341346
// Do we prefix an item with no segments?
13351347
if ($prefix_single == TRUE AND substr($item, 0, strlen($this->dbprefix)) != $this->dbprefix)
13361348
{

user_guide/changelog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ <h3>Bug fixes for 1.7.2</h3>
101101
<li>Fixed a bug in the XML-RPC class with parsing dateTime.iso8601 data types.</li>
102102
<li>Fixed a case sensitive string replacement in xss_clean()</li>
103103
<li>Fixed a bug in form_prep() causing it to not preserve entities in the user's original input when called back into a form element</li>
104+
<li>Fixed a bug in _protect_identifiers() where the swap prefix ($swap_pre) was not being observed.</li>
104105
</ul>
105106

106107
<h2>Version 1.7.1</h2>

0 commit comments

Comments
 (0)