Page MenuHomePhabricator

VE breaks on faked section edit links
Closed, DeclinedPublic

Description

I have a userscript that adds an extra link next to each section. To style this link the same way as the edit-section links, it sets the class mw-editsection for the surrounding span.

When my script happens to be loaded before VE, the setupSectionLinks tries to work on the fake links and an error is thrown ('Bad constructor arguments' from mediawiki.Uri).

While this certainly is an issue with my script, I hope that something is changed in MediaWiki to counter this, as I don't see a good workaround. Either VE should ignore links which don't look like real edit links, work only on the first link for each section, or a new class should be introduced with the same styles as mw-editsection to discourage abuse like my script.

Event Timeline

Schnark raised the priority of this task from to Needs Triage.
Schnark updated the task description. (Show Details)
Schnark added a project: VisualEditor.
Schnark subscribed.

For a short while I thought adding the link to the existing mw-editsection-span would fix the issue. This actually would work, but not on pages with __NOEDITSECTION__.

You can reproduce the issue by adding <span class="mw-editsection">[[#foo]]</span> to any page. While this actually should never be added to the contents of a page, VisualEditor shouldn't throw a JS-error, either.

Jdforrester-WMF claimed this task.
Jdforrester-WMF subscribed.

These aren't an API and we won't be retaining them for that long, so pouring effort into this ultra-edge case is not worthwhile, sorry.

or a new class should be introduced with the same styles as mw-editsection to discourage abuse like my script.

There is one, .mw-editsection-like.