]> git.mxchange.org Git - friendica.git/commitdiff
Added casts to binary for regexp comparison in mysql. mysql rejects comparison of...
authorcluster15 <cluster15web.de>
Fri, 23 May 2025 07:56:28 +0000 (09:56 +0200)
committercluster15 <cluster15web.de>
Fri, 23 May 2025 07:56:28 +0000 (09:56 +0200)
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.

src/Module/Contact.php
src/Security/PermissionSet/Repository/PermissionSet.php
src/Security/Security.php

index e99816084526505ff6bc93795578aa536553c603..28b0bed37971bc9285a7ccaa7b60af794688337a 100644 (file)
@@ -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;
index 42b6219e9c49031f54e1057a4741685a420a12f7..8eca294662f9115c2ec466dc705d7ca3174b0488 100644 (file)
@@ -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];
                        }
 
index f04af4206119da9b06ecf288b5fcf699a84abb14..96e3386141b0cd1807665d564836e9fffb64135b 100644 (file)
@@ -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),