Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space in url not handled well #8597

Closed
vdavid opened this issue Mar 26, 2020 · 11 comments · Fixed by #8345
Closed

Space in url not handled well #8597

vdavid opened this issue Mar 26, 2020 · 11 comments · Fixed by #8345
Labels
bug Issues or PR's relating to bugs ready-to-test PR's that are ready to test T1 Low difficulty to fix (issue) or test (PR)

Comments

@vdavid
Copy link

vdavid commented Mar 26, 2020

Bug Description

If there is a space at the beginning or end of the URL of a link href, Mautic shows a 404 error page when a user clicks on the link in the email.

Note: Adding a space to the beginning or end of the URL is a user error. But users of the Mautic front end is not only technical people, and simple users tend not to care too much about whitespaces. Mautic could be prepared for this scenario.

Here is an example email: https://www.screencast.com/t/J0QAXqvwjm
Here is the source of the example email: https://www.screencast.com/t/07jeK3kY9
Here is the code in Mautic 2.16.0 that handles this URL: https://www.screencast.com/t/MTyAd2jhBq

This code uses PHP's filter_var() function, namely: filter_var($url, FILTER_VALIDATE_URL) in PublicController::redirectAction. But filter_var() will return false for any URL that has a space at its end. :(

Suggestion: apply a trim() on the $url before the filter_var() call.

Q A
Mautic version 2.16.0
PHP version 7.2.16
Browser latest Chrome

Steps to reproduce

  1. Create an email in Mautic which includes a link. In the URL part, add e.g. http://google.com (note the space at the end.)
  2. Send the email with the tracking settings on. It will correctly replace the URL and add Mautic's tracking URL, so the mistake will be accepted silently.
  3. Receive the email and click on the link in it. You'll see a 404 page.

Log errors

(No errors in the log.)

Thanks a lot for your work btw, we love you guys.

@RCheesley
Copy link
Sponsor Member

Thanks for reporting this @vdavid, would you be up for submitting a PR to implement the suggestions you've made? If so, please ensure you mention that it resolves this issue so that the two get linked up :)

@RCheesley RCheesley added bug Issues or PR's relating to bugs T1 Low difficulty to fix (issue) or test (PR) labels Mar 27, 2020
@vdavid
Copy link
Author

vdavid commented Mar 28, 2020

Thanks for your response @RCheesley!
I'd be happy to do that, but I don't have the tools (PHP) at hand to test my changes.
Also, while I was a PHP dev for years, my PHP is rusty. Considering this, would it be fine and helpful to submit an untested PR as well? Because that I'd be happy to do.

@RCheesley
Copy link
Sponsor Member

@vdavid any PR requires two community testers before it is merged, so if you can submit something which you believe resolves the issue, we'll handle the testing :)

@kuzmany
Copy link
Member

kuzmany commented Apr 22, 2020

This should fixed it #8345
Can you test it?

@npracht npracht added the ready-to-test PR's that are ready to test label Apr 22, 2020
@vdavid
Copy link
Author

vdavid commented May 12, 2020

Thanks a lot for your PR @kuzmany! I had on my roadmap to respond with a PR, but I kept on pushing it to later. Unfortunately, as ai mentioned before, I don't have a PHP environment now so I can't really test it. I hope someone can review soon and it can be merged.

@kuzmany
Copy link
Member

kuzmany commented May 12, 2020

@vdavid you can test it by Mautibox

http://m3.mautibox.com/8345

Emails are fake and you can find it http://m3.mautibox.com/mail after queue command triggering

@vdavid
Copy link
Author

vdavid commented May 12, 2020 via email

@dennisameling
Copy link
Member

@vdavid I can't seem to reproduce this issue on Mautic 3.

I added http://google.com (including the space at the end) to an email, enabled tracking, and the URL is replaced by the tracking URL correctly.

image

I'm getting redirected to Google without problems:

image

Can you please try to reproduce the issue on Mautic 3?

@kuzmany
Copy link
Member

kuzmany commented Jun 27, 2020

@dennisameling which PR do you comment? this is issue

@dennisameling
Copy link
Member

dennisameling commented Jun 27, 2020

@kuzmany no PR, just trying to reproduce the issue that's described in the issue description :) can't seem to reproduce the issue on M3

@RCheesley RCheesley added this to the 3.1.1 milestone Aug 16, 2020
@RCheesley RCheesley modified the milestones: 3.1.1, 3.1.2 Sep 21, 2020
@npracht npracht modified the milestones: 3.1.2, 3.2 Oct 19, 2020
@npracht npracht removed this from the 3.2.0 milestone Nov 23, 2020
@npracht
Copy link
Member

npracht commented Nov 24, 2020

@kuzmany brought several enhancement on that in 3.x. We can close

@npracht npracht closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs ready-to-test PR's that are ready to test T1 Low difficulty to fix (issue) or test (PR)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants