Skip to content

Commit

Permalink
Allow hyphens in URL tracking for 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 ee55b52
Show file tree
Hide file tree
Showing 2 changed files with 5 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,10 @@ 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 hyphen
'<p><a href=\'https://sub.example.com/foo-bar.php?whiz=%2Fbang%2F&pie[fruit]=apple\'>Foo</a></p>',
'<p><a href=\'tracking(https://sub.example.com/foo-bar.php?whiz=%2Fbang%2F&pie[fruit]=apple)\' rel=\'nofollow\'>Foo</a></p>',
return $exs;
}

Expand Down

0 comments on commit ee55b52

Please sign in to comment.