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

Link converter truncating link #115

Closed
iammattmartin opened this issue May 7, 2017 · 22 comments
Closed

Link converter truncating link #115

iammattmartin opened this issue May 7, 2017 · 22 comments
Labels

Comments

@iammattmartin
Copy link

We used a link:

http://static.tp-link.com/TD-W9970(EU)_V2_Quick_Installation_Guide_1482286347761d.pdf

but the link converter changed to:

https://link.domain.com/xxxxx/EgoNq30c(EU)_V2_Quick_Installation_Guide_1482286347761d.pdf

Looks like () break that. Any way to ensure that the whole string is changed when there is no space?

@adamcooke
Copy link
Contributor

adamcooke commented May 7, 2017

We should be able to update the regex used on the link replacer to avoid a) breaking things like this when there's an invalid character and b) support brackets in URLs. I'll take a look tomorrow.

@adamcooke adamcooke added the bug label May 7, 2017
@adamcooke adamcooke self-assigned this May 7, 2017
@iammattmartin
Copy link
Author

Just another example, although this was more where the link went than the link itself.

Original: https://xxxxx/xxxx/views.php?action=view&id=12345
Converted: https://xxxxx/xxxx/views.php?action=view&id=12345

Causes the software behind it to error because it is expecting to see the &.

@adamcooke
Copy link
Contributor

Was that from an HTML email or a plain text one?

@iammattmartin
Copy link
Author

HTML.

@adamcooke
Copy link
Contributor

adamcooke commented May 8, 2017

I see. The link is likely being presented with & in the HTML and is just being copied into the links table as is. I'll see if I can reproduce.

@adamcooke
Copy link
Contributor

I've been looking into this. It's actually not quite as simple as I would have hoped. We need to look at the regular expression used to detect links to avoid the situation. We want to make sure that links like this are terminated properly.

Please see our website (http://somesite.com) for full details.

If we were to allow brackets in the URL the final bracket closure would be included in the link and not included in the email. Postal has actually done exactly what it was supposed to do with that URL (even though it's not really desirable).

Unfortunately, links aren't always followed by a space which is why this occurs.

We'll need to look at this regex in a little more details to resolve this.

@adamcooke adamcooke removed their assignment May 12, 2017
@iammattmartin
Copy link
Author

Maybe allowing ( and ) in the URL string but to ensure that ) is always after a ( if included after a http*://*/

It shouldn't then fall foul of the scenario you've mentioned.

It may still miss the odd use case where a URL string only has ( or ) instead of both but that could be few and far between and then wouldn't cause any issues with a lone ) at the end due to the requirement of having a ( before it after a final slash (as it would never be part of a domain name).

@catphish
Copy link
Contributor

Any fix should be tested against the duplicate tickets referenced.

@afanjul
Copy link

afanjul commented Jun 15, 2017

I think that "non commun" characteres in url like "(" or ")" or even "]", etc. is not a priority, but a character like the query parameters separator "&" should be a priority to solve this bug because most of the urls in emails will have some kind of utm/tracking parameter...

@iammattmartin
Copy link
Author

This also happens to links with ports.

https://server.com:1234

gets turned in to:

https://link.domain.com/ref345/sasgsf:1234

@willpower232
Copy link
Collaborator

I think I've managed to resolve this issue, see the screenshot for all the testing links mentioned so far being intact in the database.

capture

Are there any additional testable links or should I make a pull request?

@catphish
Copy link
Contributor

catphish commented Aug 5, 2017

Thanks! If you've tested this against all links mentioned in these tickets, please go ahead and make a pull request and I'll get this in. Even if it's not perfect (i'm sure someone will find a new way to break it), I'm happy to commit it as an incremental improvement.

@afanjul
Copy link

afanjul commented Aug 5, 2017

Yes please! many thanks!

@iammattmartin
Copy link
Author

Yes please too. Thanks for your work on this @willpower232!

@willpower232
Copy link
Collaborator

I've discovered its not a complete solution but theres only one fail for plain text messages when the URL is surrounded by brackets but its a vast improvement if it matches everything else.

@willpower232
Copy link
Collaborator

and no worries! We rely a lot on postal so getting the key issues fixed is important

@alkanna
Copy link

alkanna commented Sep 22, 2020

@willpower232 I made those changed manually in our codebase and restarted postal, but the problem still persists. Our "&" are converted into "&" and thus rendered invalid. Any solution to this?
Thanks.

@willpower232
Copy link
Collaborator

@alkanna can you share an example of a link that isn't working?

@alkanna
Copy link

alkanna commented Sep 29, 2020

I get & converted to &. Furthermore:
This kind of link ends up stripped near the end, I couldn't figure out where exactly since we do not store the original anywhere (it's a jwt token): https://xxx.xx.com/ticket/approve/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHByb3Zlcl9pZCI6NCwicmVxdWVzdG9yX2lkIjo3MTExLCJ0aWNrZXRfaWRzIjpbNjg1M10sImxpbWl0IjoiMjAyMDA5MjVUMDU1MjAwIiwiYXBwcm92ZWQiOmZhbHNlfQ.vzjOqRHzSlxe4zzOcbxIDh_nQq-W9_RoGJ_tF-QI

@willpower232
Copy link
Collaborator

The example you've posted is very long so its likely getting clipped by the database if your Postal is older than the merging of #683, you might have to manually apply converting that database field to a text type for the extra character length.

Regarding &, you can see them being converted successfully in my much older screenshot, is it possible they got encoded to & before Postal processed them?

@rocramer
Copy link

rocramer commented Oct 3, 2020

Same problem. E-Mails in my Laravel app are not working properly. & is converting to &. Seems there are several open issues around this problem. Is there a known workaround for that?

@nateh777
Copy link

nateh777 commented Feb 8, 2023

We too are experiencing the issue with & being stored in the tracking links table in the database. The issue is that the tools that send them to Postal first encode all characters within links, specifically HTML email. A link of https://test.com/test?test=1&parameter=1 will get html encoded to https://test.xx/testing?test=1&parameter=1 before sending to Postal via SMTP or API, then Postal takes that URL and stores it as such with Track Clicks being enabled. Which then the link is invalid if you were to visit a URL with & in it instead of just &.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants