Added casts to binary for regexp comparison in mysql. mysql rejects comparison of UTF with binary strings.
see https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html#mysqld-8-0-22-feature The SQL statements also work for mariadb.
This commit is contained in:
parent
8e0a3d00bb
commit
6e84c0ade7
3 changed files with 9 additions and 7 deletions
|
@ -254,7 +254,9 @@ class Contact extends BaseModule
|
|||
$searching = true;
|
||||
$search_hdr = $search;
|
||||
$search_txt = preg_quote(trim($search, ' @!'));
|
||||
$sql_extra .= " AND (`name` REGEXP ? OR `url` REGEXP ? OR `nick` REGEXP ? OR `addr` REGEXP ? OR `alias` REGEXP ?)";
|
||||
$sql_extra .= " AND (CAST(`name` AS BINARY) REGEXP BINARY ? OR CAST(`url` AS BINARY) REGEXP BINARY ?";
|
||||
$sql_extra .= " OR CAST(`nick` AS BINARY) REGEXP BINARY ? OR CAST(`addr` AS BINARY) REGEXP BINARY ?";
|
||||
$sql_extra .= " OR CAST(`alias` AS BINARY) REGEXP BINARY ?)";
|
||||
$sql_values[] = $search_txt;
|
||||
$sql_values[] = $search_txt;
|
||||
$sql_values[] = $search_txt;
|
||||
|
|
|
@ -132,13 +132,13 @@ class PermissionSet extends BaseRepository
|
|||
}
|
||||
|
||||
if (!empty($user_contact_str)) {
|
||||
$condition = ["`uid` = ? AND (NOT (LOCATE(?, `deny_cid`) OR LOCATE(?, `deny_cid`) OR deny_gid REGEXP ?)
|
||||
AND (LOCATE(?, allow_cid) OR LOCATE(?, allow_cid) OR allow_gid REGEXP ? OR (allow_cid = '' AND allow_gid = '')))",
|
||||
$condition = ["`uid` = ? AND (NOT (LOCATE(?, `deny_cid`) OR LOCATE(?, `deny_cid`) OR CAST(deny_gid AS BINARY) REGEXP BINARY ?)
|
||||
AND (LOCATE(?, allow_cid) OR LOCATE(?, allow_cid) OR CAST(allow_gid AS BINARY) REGEXP BINARY ? OR (allow_cid = '' AND allow_gid = '')))",
|
||||
$uid, $user_contact_str, $public_contact_str, $circle_str,
|
||||
$user_contact_str, $public_contact_str, $circle_str];
|
||||
} else {
|
||||
$condition = ["`uid` = ? AND (NOT (LOCATE(?, `deny_cid`) OR deny_gid REGEXP ?)
|
||||
AND (LOCATE(?, allow_cid) OR allow_gid REGEXP ? OR (allow_cid = '' AND allow_gid = '')))",
|
||||
$condition = ["`uid` = ? AND (NOT (LOCATE(?, `deny_cid`) OR CAST(deny_gid AS BINARY) REGEXP BINARY ?)
|
||||
AND (LOCATE(?, allow_cid) OR CAST(allow_gid AS BINARY) REGEXP BINARY ? OR (allow_cid = '' AND allow_gid = '')))",
|
||||
$uid, $public_contact_str, $circle_str, $public_contact_str, $circle_str];
|
||||
}
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ class Security
|
|||
}
|
||||
|
||||
$sql = sprintf(
|
||||
" AND (NOT (deny_cid REGEXP '<%d>' OR deny_gid REGEXP '%s')
|
||||
AND (allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s'
|
||||
" AND (NOT (CAST(deny_cid AS BINARY) REGEXP BINARY '<%d>' OR CAST(deny_gid AS BINARY) REGEXP BINARY '%s')
|
||||
AND (CAST(allow_cid AS BINARY) REGEXP BINARY '<%d>' OR CAST(allow_gid AS BINARY) REGEXP BINARY '%s'
|
||||
OR (allow_cid = '' AND allow_gid = ''))" . $acc_sql . ") ",
|
||||
intval($remote_contact),
|
||||
DBA::escape($circleIds),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue