mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
modify regex to match optional table alias and ignore column alias equal to column name
This commit is contained in:
@@ -991,14 +991,17 @@ class DB_Model extends CI_Model
|
||||
|
||||
// Find and replace all the occurrences of the provided encrypted columns
|
||||
// with the postgresql decryption function
|
||||
$query = preg_replace(
|
||||
'/\b' . $encryptedColumn . '\b/',
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
),
|
||||
$query = preg_replace_callback(
|
||||
'/(?<! (as|AS) )\b(\w+\.)?(' . $encryptedColumn . ')\b/',
|
||||
function($matches) {
|
||||
$aliased_column = $matches[2] . $matches[3];
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$aliased_column,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
);
|
||||
},
|
||||
$query
|
||||
);
|
||||
}
|
||||
@@ -1106,14 +1109,17 @@ class DB_Model extends CI_Model
|
||||
{
|
||||
// Find and replace all the occurrences of the provided encrypted columns
|
||||
// with the postgresql decryption function
|
||||
$where = preg_replace(
|
||||
'/\b' . $encryptedColumn . '\b/',
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
),
|
||||
$where = preg_replace_callback(
|
||||
'/(?<! (as|AS) )\b(\w+\.)?(' . $encryptedColumn . ')\b/',
|
||||
function($matches) {
|
||||
$aliased_column = $matches[2] . $matches[3];
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$aliased_column,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
);
|
||||
},
|
||||
$where
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user