Page MenuHomePhabricator

Self-closing HTML tags shouldn't be accepted
Closed, DeclinedPublic


According to the HTML5 spec, normal elements must have a start and end tag, but for some exceptions. Currently Parsoid accepts these tags as valid, as seen in the test: "Handling html with a div self-closing tag" in parserTests.txt:

<div title />
<div title/>
<div title/ >
<div title=bar />
<div title=bar/>
<div title=bar/ >

results in

<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
<div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
<div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
<div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
<div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>

PHP parser renders them as text:

<p>&lt;div title /&gt;
&lt;div title/&gt;
<p>&lt;div title=bar /&gt;
&lt;div title=bar/&gt;
<div title="bar/"></div>

Event Timeline

ssastry created this task.Dec 7 2014, 5:38 AM
ssastry raised the priority of this task from to Medium.
ssastry updated the task description. (Show Details)
ssastry added a project: Parsoid.
ssastry changed Security from none to None.
ssastry assigned this task to marcoil.Dec 17 2014, 10:39 PM
marcoil renamed this task from Self-closing HTML tags are being accepted to Self-closing HTML tags shouldn't be accepted.Dec 29 2014, 5:35 PM
marcoil updated the task description. (Show Details)
marcoil removed marcoil as the assignee of this task.Jun 9 2015, 2:06 PM
ssastry lowered the priority of this task from Medium to Low.Dec 18 2017, 10:21 PM
ssastry added a subscriber: ssastry.

Both PHP Parser and Parsoid now render self-closed HTML tags as <tag></tag>. Separately, we have created a high priority linter category to have editors fix up these incorrect uses of self-closing tags.

At some point in the future once Tidy is replaced and this category is sufficiently sparse across all wikis, we'll probably stop accepting them altogether.

Izno added a subscriber: Izno.Sep 3 2018, 10:39 PM
LGoto moved this task from Needs Triage to Backlog on the Parsoid board.Feb 17 2020, 4:43 PM
ssastry closed this task as Declined.Feb 19 2020, 11:04 PM

This is no longer a Parsoid-specific issue. Whether such invalid tags should parse as text or the way it is rendering now is left for future cleanup discussion.