diff --git a/app/bundles/CoreBundle/Helper/UrlHelper.php b/app/bundles/CoreBundle/Helper/UrlHelper.php index 6b5fffb05dd..c323dbf493a 100644 --- a/app/bundles/CoreBundle/Helper/UrlHelper.php +++ b/app/bundles/CoreBundle/Helper/UrlHelper.php @@ -179,7 +179,7 @@ public static function getUrlsFromPlaintext($text, array $contactUrlFields = []) // We don't want to match URLs in token default values // like {contactfield=website|http://ignore.this.url} - if (preg_match_all("#{(.*?)\|".preg_quote($url).'}#', $text, $matches)) { + if (preg_match_all("/{(.*?)\|".preg_quote($url, '/').'}/', $text, $matches)) { unset($urls[$key]); // We know this is a URL due to the default so let's include it as a trackable diff --git a/app/bundles/CoreBundle/Tests/unit/Helper/UrlHelperTest.php b/app/bundles/CoreBundle/Tests/unit/Helper/UrlHelperTest.php index a728e9c1fb3..fba8cdcec6e 100644 --- a/app/bundles/CoreBundle/Tests/unit/Helper/UrlHelperTest.php +++ b/app/bundles/CoreBundle/Tests/unit/Helper/UrlHelperTest.php @@ -124,6 +124,7 @@ public function testGetUrlsFromPlaintextWithSymbols() 'https://example.org/with/query?utm_campaign=hello', 'https://example.org/with/tokenized-query?foo={contactfield=bar}&bar=foo', 'https://example.org/with/just-tokenized-query?foo={contactfield=bar}', + 'https://example.org/with/query?utm_campaign=_hello#_underscore-test', ], UrlHelper::getUrlsFromPlaintext( <<