html-agility-pack icon indicating copy to clipboard operation
html-agility-pack copied to clipboard

Attributes with spaces are not quoted if the attribute was loaded without quotes

Open dylanstreb opened this issue 1 year ago • 1 comments

1. Description

Attributes with spaces are not quoted if the attribute was loaded without quotes

3. Fiddle or Project

Fiddle: https://dotnetfiddle.net/qj0Iav

The output from HAP includes <div class=test cls>Text</div>. This should be <div class="test cls">Text</div>. The browser will interpret the current output as <div class="test" cls>Text</div> - i.e. the class is only "test", then there's a new cls attribute with no value.

This is an issue with minified input. The quotes around attributes are stripped if it is valid to do so. When HAP loads a minified attribute, it attempts to preserve the quotation style. However, if the value is then changed, it does not check to make sure that the quotation style is still legal.

The example uses addClass but it should apply to anything that modifies attribute values. I believe other characters besides just space will require quotations. I don't know the exact list but probably any non-word character.

4. Any further technical details

  • HAP version: Occurs in HAP 1.11.63 and 1.11.64

dylanstreb avatar Aug 27 '24 15:08 dylanstreb

Hello @dylanstreb ,

Thank you for reporting. We will look at it.

Best Regards,

Jon

JonathanMagnan avatar Aug 27 '24 16:08 JonathanMagnan

Hello @dylanstreb ,

The v1.11.65 has been released, fixing this issue.

Let me know if everything is now working correctly.

Best Regards,

Jon

JonathanMagnan avatar Aug 30 '24 18:08 JonathanMagnan

1.11.65 fixes the issue. Thank you!

dylanstreb avatar Sep 04 '24 18:09 dylanstreb