From: larssandergreen Date: Tue, 13 Dec 2022 02:36:48 +0000 (-0700) Subject: allow hyphens in tracked URLs in text emails X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8b13a9ff357510f5c769d6456fc81352f90641f8;p=civicrm-core.git allow hyphens in tracked URLs in text emails --- diff --git a/ext/flexmailer/src/ClickTracker/TextClickTracker.php b/ext/flexmailer/src/ClickTracker/TextClickTracker.php index 63a14a0955..1fdea53e8b 100644 --- a/ext/flexmailer/src/ClickTracker/TextClickTracker.php +++ b/ext/flexmailer/src/ClickTracker/TextClickTracker.php @@ -37,7 +37,7 @@ class TextClickTracker implements ClickTrackerInterface { }; // Find any HTTP(S) URLs in the text. // return preg_replace_callback('/\b(?:(?:https?):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i', $callback, $tex - return preg_replace_callback('/\b(?:(?:https?):\/\/)[\w+&@#\/%=~_|$?!:,.{}\[\];]*[\w+&@#\/%=~_|${}\[\];]/iu', + return preg_replace_callback('/\b(?:(?:https?):\/\/)[\w+&@#\/%=~_|$?!:,.{}\[\];\-]*[\w+&@#\/%=~_|${}\[\];\-]/iu', $callback, $text); } diff --git a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php index db96537485..14da23dd78 100644 --- a/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php +++ b/ext/flexmailer/tests/phpunit/Civi/FlexMailer/ClickTracker/TextClickTrackerTest.php @@ -69,7 +69,11 @@ class TextClickTrackerTest extends \CiviUnitTestCase { '

FirstSecondThirdFourth

', '

FirstSecondThirdFourth

', ]; - + $exs[] = [ + // Messy looking URL, including hyphens + '

Foo

', + '

Foo

', + ]; return $exs; }