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

Minified attributes seem to be double encoded #148

Open
Kajakske opened this issue Aug 19, 2022 · 4 comments
Open

Minified attributes seem to be double encoded #148

Kajakske opened this issue Aug 19, 2022 · 4 comments

Comments

@Kajakske
Copy link

Kajakske commented Aug 19, 2022

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)

@Taritsyn
Copy link
Owner

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
Copy link
Owner

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

@Taritsyn
Copy link
Owner

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.

@Kajakske
Copy link
Author

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 ;-)

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

2 participants