From d6cdc846d8dec7c8e873fc66bb792f87d7a5711a Mon Sep 17 00:00:00 2001
From: andryyy <andre.peters@debinux.de>
Date: Wed, 8 Mar 2017 18:17:42 +0100
Subject: [PATCH] Fix alias regex

---
 data/web/inc/functions.inc.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php
index 39e0fe35..87bed9b9 100644
--- a/data/web/inc/functions.inc.php
+++ b/data/web/inc/functions.inc.php
@@ -1467,7 +1467,7 @@ function user_get_alias_details($username) {
   try {
     $data['address'] = $username;
     $stmt = $pdo->prepare("SELECT IFNULL(GROUP_CONCAT(`address` SEPARATOR ', '), '&#10008;') AS `aliases` FROM `alias`
-      WHERE `goto` LIKE :username_goto
+      WHERE `goto` REGEXP :username_goto
       AND `address` NOT LIKE '@%'
       AND `address` != :username_address");
     $stmt->execute(array(':username_goto' => '(^|,)'.$username.'($|,)', ':username_address' => $username));
@@ -1495,8 +1495,8 @@ function user_get_alias_details($username) {
     while ($row = array_shift($run)) {
       $data['aliases_send_as_all'] = $row['send_as'];
     }
-    $stmt = $pdo->prepare("SELECT IFNULL(GROUP_CONCAT(`address` SEPARATOR ', '), '&#10008;') as `address` FROM `alias` WHERE `goto` LIKE :username AND `address` LIKE '@%';");
-    $stmt->execute(array(':username' => '%' . $username . '%'));
+    $stmt = $pdo->prepare("SELECT IFNULL(GROUP_CONCAT(`address` SEPARATOR ', '), '&#10008;') as `address` FROM `alias` WHERE `goto` REGEXP :username AND `address` LIKE '@%';");
+    $stmt->execute(array(':username' => '(^|,)'.$username.'($|,)'));
     $run = $stmt->fetchAll(PDO::FETCH_ASSOC);
     while ($row = array_shift($run)) {
       $data['is_catch_all'] = $row['address'];
@@ -4878,7 +4878,7 @@ function mailbox_get_sender_acl_handles($mailbox) {
   
   try {
     // Fixed addresses
-    $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` LIKE :goto AND `address` NOT LIKE '@%'");
+    $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` REGEXP :goto AND `address` NOT LIKE '@%'");
     $stmt->execute(array(':goto' => '(^|,)'.$mailbox.'($|,)'));
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     while ($row = array_shift($rows)) {