WebMarkupMin icon indicating copy to clipboard operation
WebMarkupMin copied to clipboard

Minified attributes seem to be double encoded

Open Kajakske opened this issue 2 years ago • 4 comments

When WebMarlupMin minifies something like this: span class="button close" data-icon="&#xe614" aria-hidden="true" it comes out with the ampersand encoded like this: span class="button close" data-icon="&#xe614" aria-hidden="true" (opening and closing html tag removed since github filters them out)

Kajakske avatar Aug 19 '22 14:08 Kajakske

Hello, Tom!

It seems to me that there should be a semicolon in the value of this attribute:

<span class="button close" data-icon="&#xe614;" aria-hidden="true">…</span>

Taritsyn avatar Aug 19 '22 16:08 Taritsyn

I will try to fix this error during the next week.

Taritsyn avatar Aug 20 '22 06:08 Taritsyn

Hello, Tom!

In the beginning, I thought that I could quickly fix this problem by simply editing one line of code, but it turned out to be much more complicated. System.Net.WebUtility.HtmlDecode method that I'm using to decode does not support HTML entities without a semicolon. Unfortunately, there is no ready-made analogue of the he library for .NET, so it will take quite a long time to implement such functionality. In general, usage of the HTML entities without a semicolon is a rather controversial thing (see the “Are there some valid HTML entities without the semicolon?” discussion on Stack Overflow).

I can't exclude the &&amp; conversion either, because the minified code will no longer be compatible with older versions of HTML. In one of the future releases, I plan to add a OutputLanguage property to the settings, with which it will be possible to specify the supported version of language. Already in the longer term, I plan to write my own HTML decoder, but it seems to me that it will be several times slower than the System.Net.WebUtility.HtmlDecode.

At the moment I recommend that you manually add semicolons to the HTML entities.

Taritsyn avatar Aug 22 '22 13:08 Taritsyn

Hey Andrey,

You've already pointed me in an excellent direction. I'll look into using the semicolon, which is fine if our code works with it, that's a fixable situation. I'm also quite pleased with the speed of your response .. So big kuddos to you ;-)

Kajakske avatar Aug 22 '22 13:08 Kajakske