I'm using Debian 10, php 7.3 and using exim4 to send emails from php. After upgrading, Cacti stopped sending emails to any destination and when I tried to send test message I received "Error: You must provide at least one recipient email address".
In /var/log/cacti/cacti.log I found "ERROR PHP WARNING: preg_match(): Compilation failed: invalid range in character class at offset 28 in file: /usr/share/cacti/site/lib/functions.php on line: 3684". I edited this file to dump the contents of the variables involved and it was true, nothing came from a preg_match function that uses a regular expression declared before. The regular expression is:
Code: Select all
$sPattern = '/([\w\s\'\"\+]+[\s]+)?(<)?(([\w-\.\+]+)@((?:[\w\-]+\.)+)([a-zA-Z]{2,4}))?(>)?/';
Also I've read that this issue dissapeared when using php7.2 and lower versions, so I asked to myself (and to google, )"what's the difference in preg_match in php7.2 and php7.3?". The first result shows what I've been looking for!
Source: https://hackernoon.com/deprecations-and ... 5c4dbeaa8bPSRE2 is more strict in the pattern validations, so after the upgrade, some of your existing patterns could not compile anymore.
Here is the simple snippet used in php.net
preg_match('/[\w-.]+/', ''); // this will not work in PHP7.3
preg_match('/[\w\-.]+/', ''); // the hyphen need to be escaped
As you can see from the example above there is a little but substantial difference between the two lines.
So I've changed the regular expression in line from
Code: Select all
$sPattern = '/([\w\s\'\"\+]+[\s]+)?(<)?(([\w-\.\+]+)@((?:[\w\-]+\.)+)([a-zA-Z]{2,4}))?(>)?/';
Code: Select all
$sPattern = '/([\w\s\'\"\+]+[\s]+)?(<)?(([\w\-\.\+]+)@((?:[\w\-]+\.)+)([a-zA-Z]{2,4}))?(>)?/';
Hope it helps anyone as helped me.
Best regards.