Page MenuHomePhabricator

JavaScript pages should not be put in Category:Pages using invalid self-closed HTML tags
Open, MediumPublic

Description

Right now all the pages in Category:Pages using invalid self-closed HTML tags are JavaScript pages. That's because $("<div />") is perfectly valid in JavaScript (and commonly used). The Sanitizer function that puts pages in that category, removeHTMLtags(), is intended to be sanitizing for HTML5, not JavaScript. JS pages should either be exempt from that function entirely or at least the deprecated-self-close-category parts.

Event Timeline

kaldari created this task.Sep 21 2017, 12:10 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 21 2017, 12:10 AM

A Javascript to insert such kinds of <div/>s into wikitext is trivial to create. I am unsure that this shouldn't be sanitized.

That aside, @ssastry , Linter doesn't pick these up in its own self-closing test. Does Linter already do it this way?

Also, why are there two systems doing the same thing? 😃

$("<div />") actually inserts <div></div> into the HTML, so there's nothing wrong with it. Regardless, we shouldn't be applying HTML sanitization to JavaScript code.

Izno added a comment.Sep 21 2017, 1:41 AM

$("<div />") actually inserts <div></div> into the HTML, so there's nothing wrong with it. Regardless, we shouldn't be applying HTML sanitization to JavaScript code.

I don't need to use jquery on Mediawiki wikis to do something...

The root cause here is probably T18683: User CSS/JS should not be parsed for link tables without rendering.

By the way, it is entirely unnecessary to do $("<div />") when you can just do $("<div>"). We recommend the latter in our coding conventions: https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Creating_elements. It might be easier to just edit the affected pages.

That aside, @ssastry , Linter doesn't pick these up in its own self-closing test. Does Linter already do it this way?

Linter only processes pages having the wikitext content model.

Also, why are there two systems doing the same thing? 😃

The category preceded linter extension coming online ... and we didn't disable this category since some users were actually relying on it. At this point, we'll let this run its course, and once we replace Tidy, we'll disable this category.

ssastry assigned this task to cscott.Sep 22 2017, 8:53 PM
ssastry triaged this task as Medium priority.
ssastry edited projects, added MediaWiki-Parser; removed MediaWiki-General, JavaScript.
cscott added a comment.Oct 3 2017, 3:13 PM

Can I redirect the existing category pages to an appropriate linter page? Can someone work out what that linter URL would be?

Can I redirect the existing category pages to an appropriate linter page? Can someone work out what that linter URL would be?

[[Special:LintErrors/self-closed-tag]]

For the benefits of other subscribers of this ticket, here is the plan.

Since this category predated the linter extension and is no longer required, the plan is stop adding pages to this category and instead redirect that category page to the linter page since the linter output already handles this tag and also deals with content model constraints.

Izno added a comment.EditedSep 22 2018, 4:07 PM

I would prefer to stop populating the category alone rather than stop populating + a redirect as this will be more confusing to editors ("a Category page that redirects to a Special page?").

Leave a note in tech notices for admins to delete the category because it will no longer be filled, or run a Mediawiki maintenance script to delete it.

Aklapper removed cscott as the assignee of this task.Jun 19 2020, 4:20 PM
Aklapper added a subscriber: cscott.

This task has been assigned to the same task owner for more than two years. Resetting task assignee due to inactivity, to decrease task cookie-licking and to get a slightly more realistic overview of plans. Please feel free to assign this task to yourself again if you still realistically work or plan to work on this task - it would be welcome!

For tips how to manage individual work in Phabricator (noisy notifications, lists of task, etc.), see https://phabricator.wikimedia.org/T228575#6237124 for available options.
(For the records, two emails were sent to assignee addresses before resetting assignees. See T228575 for more info and for potential feedback. Thanks!)