Skip to content

Commit

Permalink
allow hyphens in tracked URLs in text emails
Browse files Browse the repository at this point in the history
  • Loading branch information
larssandergreen committed Dec 13, 2022
1 parent 2c9990b commit 8b13a9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/flexmailer/src/ClickTracker/TextClickTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function replaceTextUrls($text, $replace) {
};
// 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public function getHrefExamples() {
'<p><a href="http://example.com/1">First</a><a href="http://example.com/2">Second</a><a href=\'http://example.com/3\'>Third</a><a href="http://example.com/4">Fourth</a></p>',
'<p><a href="tracking(http://example.com/1)" rel=\'nofollow\'>First</a><a href="tracking(http://example.com/2)" rel=\'nofollow\'>Second</a><a href=\'tracking(http://example.com/3)\' rel=\'nofollow\'>Third</a><a href="tracking(http://example.com/4)" rel=\'nofollow\'>Fourth</a></p>',
];

$exs[] = [
// Messy looking URL, including hyphens
'<p><a href=\'https://sub.example-url.com/foo-bar.php?whiz=%2Fbang%2F&pie[fruit]=apple-pie\'>Foo</a></p>',
'<p><a href=\'tracking(https://sub.example-url.com/foo-bar.php?whiz=%2Fbang%2F&pie[fruit]=apple-pie)\' rel=\'nofollow\'>Foo</a></p>',
];
return $exs;
}

Expand Down

0 comments on commit 8b13a9f

Please sign in to comment.