Fixed trackable link conversion that had other attributes with href #1429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
If the HTML of an email is copied out of another editor, data attributes may result in a link not getting converted to Mautic's trackables. For example, a link like
<a data-mce-href="http://mylink.com" href="http://mylink.com">Click</a>
Would result in data-mce-href's value being replaced with the click tracking URL but not the actual href. This PR fixes this by adjusting the preg_replace pattern and replacement to only match the true href attribute.
Testing
Create an list email with the above link and send it to the list. The emails received will be the raw URL and not the trackable. But if looking at the message source, you'll see data-mce-href was replaced with the trackable. Apply the PR and repeat. This time the true href tag will be converted and thus clicks tracked.