Page MenuHomePhabricator

Should Parsoid\Wt2Html\PP\Processors\Linter::getNextMatchingNode() be testing nextNonSepSibling() rather than nextSibling?
Closed, ResolvedPublic

Description

See code review at https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/505778/6/src/Wt2Html/PP/Processors/Linter.php#136

		if ( $node->nextSibling ) { // TODO: Should this be testing DOMUtils::nextNonSepSibling() instead?
			return $this->leftMostDescendent( DOMUtils::nextNonSepSibling( $node ), $match );
		}
		return $this->getNextMatchingNode( $node->parentNode, $match );

Quoting @ssastry,

Good question. As it stands, if nextSibling is a separator elt, getNextMatchingNode would return null instead of going up the parent and looking there. Probably an edge case. But, worth fixing later. Maybe file a phab task for this?

Event Timeline

ssastry triaged this task as Medium priority.May 14 2019, 4:24 AM
ssastry edited projects, added Parsoid-Linter; removed Parsoid-PHP.

So, it was obvious that for reasons of code clarity and consistency, we should use DOMUtils::nextNonSepSibling($node) there, but I was curious if it actually led to poorer linting results which is why I punted on this originally when this first showed up during code review. It took a little effort cleaning up code, document, unbreaking some tools and debugging utilities and then some tinkering before I arrived at a test case (edge case of course) whose linter output is improved by the change. Patch coming shortly.

<div>
* <span>foo

</div>
</span>y

Without the change, Linter reports this as 2 lint errors (missing-end-tag + stripped-tag) which is usually an indication that it is a misnested tag. With the change, Linter now reports it as a misnested-tag lint error which is better.

ssastry lowered the priority of this task from Medium to Low.Apr 3 2020, 9:52 PM
ssastry moved this task from Needs Investigation to Bugs & Crashers on the Parsoid board.

Change 585828 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Linter: Fix edge case in misnested-tag lint detection

https://gerrit.wikimedia.org/r/585828

Change 585828 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Linter: Fix edge case in misnested-tag lint detection

https://gerrit.wikimedia.org/r/585828

Change 585888 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/vendor@master] Bump Parsoid to 0.12.0-a9

https://gerrit.wikimedia.org/r/585888

Change 585888 merged by jenkins-bot:
[mediawiki/vendor@master] Bump Parsoid to 0.12.0-a9

https://gerrit.wikimedia.org/r/585888