Skip to content

Commit cefa5f0

Browse files
committed
simplify query, escape regex special chars
1 parent e5a00f9 commit cefa5f0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

install/tpl/mysql-virtual_outgoing_bcc.cf.master

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
44
hosts = {mysql_server_ip}
55
query = SELECT sender_cc FROM (
6-
SELECT @num_sender_cc := 1 + LENGTH(sender_cc) - LENGTH(REPLACE(sender_cc, ',', '')) AS num_sender_cc,
7-
SUBSTRING_INDEX(sender_cc, ',', 1) AS sender_cc
6+
SELECT SUBSTRING_INDEX(sender_cc, ',', 1) AS sender_cc
87
FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND sender_cc != '' AND server_id = {server_id}
98
UNION
10-
SELECT @num_sender_cc := 1 + LENGTH(u.sender_cc) - LENGTH(REPLACE(u.sender_cc, ',', '')) AS num_sender_cc,
11-
SUBSTRING_INDEX(u.sender_cc, ',', 1) AS sender_cc
9+
SELECT SUBSTRING_INDEX(u.sender_cc, ',', 1) AS sender_cc
1210
FROM mail_user u, mail_forwarding f
13-
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*', u.email, '[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
11+
WHERE f.destination REGEXP CONCAT( '(^|\\n)[[:blank:]]*,?[[:blank:]]*',
12+
REPLACE( REPLACE(u.email, '+', '\\+'), '.', '\\.' ),
13+
'[[:blank:]]*,?[[:blank:]]*(\\r?\\n|$)' )
1414
AND u.disablesmtp = 'n' AND u.sender_cc != '' AND u.server_id = {server_id}
1515
AND f.source = '%s' AND f.allow_send_as = 'y' AND f.active = 'y' AND f.server_id = {server_id}
1616
) table1 WHERE sender_cc != '' LIMIT 1

0 commit comments

Comments
 (0)