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

PreMailer is encoding URLs with base64-encoded querystrings, which is breaking links #172

Open
davidkeaveny opened this issue May 13, 2019 · 3 comments

Comments

@davidkeaveny
Copy link

davidkeaveny commented May 13, 2019

I am currently using PreMailer.NET 2.0.1 with AngleSharp 0.9.11. If I start from a source HTML document like this:

<img src="https://mysite.com/images/render.aspx?width=230&height=100&path=c%2BMSWoLAkkaX9MuWPh3OJYPQ8yJdCI6GoS80sywIaDgWYBpoq4FU6pmpOL5Ve1keh7yYqHAF9mBMrMrLYtx4xQ%3D%3D" />

That gets rendered by PreMailer as:

<img src="https://mysite.com/images/render.aspx?width=230&amp;height=100&amp;path=c%2BMSWoLAkkaX9MuWPh3OJYPQ8yJdCI6GoS80sywIaDgWYBpoq4FU6pmpOL5Ve1keh7yYqHAF9mBMrMrLYtx4xQ%3D%3D" />

which when clicked on from the mail client, causes the web server to not correctly display the image, as it cannot parse the path parameter correctly.

How can I stop PreMailer from encoding the & in the URL? From what I've seen of other encoding issues, it may actually be a problem with AngleSharp, but I've a) yet to see any documentation on how to stop that behaviour in AngleSharp, and b) no idea how that would be controlled from PreMailer anyway.

@jordanwallwork
Copy link

This is the correct output. Per user @FlorianRappl on the relevant AngleSharp issue AngleSharp/AngleSharp#348:

This is by specification, see the string escaping that needs to be applied on attribute values..

@CaptainStack
Copy link

CaptainStack commented Feb 21, 2020

This is the correct output. Per user @FlorianRappl on the relevant AngleSharp issue AngleSharp/AngleSharp#348:

This is by specification, see the string escaping that needs to be applied on attribute values..

@jordanwallwork - this is not the correct output even if the HTML standard says attribute values need to be string escaped. PreMailer.Net is a CSS inliner, it is not an HTML validator or sanitizer. This side effect is completely blocking some of my work and I need a workaround. I don't have any control over the URLs in the HTML, but I am not allowed to change them. I need to inline the CSS without changing the URLs.

Additionally, it encodes these values even when they are not an HTML attribute value, which is definitely wrong.

<p>Ben & Jerry's</p>

This is not required to be encoded by the HTML specification but PreMailer.Net encodes it anyway. Result:

<p>Ben &amp; Jerry's</p>

@mirkomaty
Copy link

mirkomaty commented Aug 16, 2021

EDIT: Sorry, I haven't seen this solution:
#198

So, I'm going to try to write a formatter.
Maybe somebody might find this comment helpful.
-mm

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

No branches or pull requests

4 participants