milkshakesoftware/PreMailer.Net

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

Opened this issue · 3 comments

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.

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..

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>

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