Skip to content

Commit

Permalink
Merge pull request #7169 from kuzmany/fix-trackable-url-with-hash
Browse files Browse the repository at this point in the history
Fix issue with regex with  underscore in URL
  • Loading branch information
alanhartless committed Mar 11, 2019
2 parents 89071ba + b590cc1 commit 0f58765
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/bundles/CoreBundle/Helper/UrlHelper.php
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/bundles/CoreBundle/Tests/unit/Helper/UrlHelperTest.php
Expand Up @@ -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(
<<<STRING
Expand All @@ -143,6 +144,7 @@ public function testGetUrlsFromPlaintextWithSymbols()
Checkout my UTM tags https://example.org/with/query?utm_campaign=hello.
Hey what about https://example.org/with/tokenized-query?foo={contactfield=bar}&bar=foo.
What happens with this https://example.org/with/just-tokenized-query?foo={contactfield=bar}?
Underscore test https://example.org/with/query?utm_campaign=_hello#_underscore-test
STRING
)
);
Expand Down

0 comments on commit 0f58765

Please sign in to comment.