Taritsyn / WebMarkupMin

The Web Markup Minifier (abbreviated WebMarkupMin) - a .NET library that contains a set of markup minifiers. The objective of this project is to improve the performance of web applications by reducing the size of HTML, XHTML and XML code.
Apache License 2.0
440 stars 48 forks source link

Unclosed td / th tags on PartialView #166

Closed danFbach closed 7 months ago

danFbach commented 7 months ago

In an existing <table> that i intend to inject rows (<tr>) into. I call an action with javascript, the action returns a PartialView, what is returned looked something like:

<tr>
    <td>cell 1
    <td>cell 2
</tr>
<tr>
    <td>cell 1
    <td>cell 2
</tr>

with no closing tags.

When unclosed <td> or <th> tags as a inside complete <table> element, browsers seem to have no problem parsing it into a valid table, but when the unclosed tags a returned and injected with javascript, no parsing occurs and broken html is the result.

Taritsyn commented 7 months ago

Hello, Dan!

Optional tags are defined by HTML specification. There is a good article on this theme.

You can disable this behavior by using the RemoveOptionalEndTags and PreservableOptionalTagList options (see the documentation for details).

danFbach commented 7 months ago

Hey @Taritsyn, I apologize for reporting this. After testing with <!--wmm:ignore--> around my view code, i found that the unminified html produced the same result, which helped me localize my problem to my method of injection in javascript. Thanks for responding, anyway!