Page MenuHomePhabricator

mw:Placeholder elements are editable in VE
Closed, ResolvedPublicBUG REPORT

Description

When creating a node that has a typeof="mw:Placeholder" element, the expectation from Parsoid is that these nodes are not modified by clients (as per spec https://www.mediawiki.org/wiki/Specs/HTML/2.4.0#Expectations_of_editing_clients). However, this doesn't seem to be the case.

The problem can be displayed on https://patchdemo.wmflabs.org/wikis/6871284e64/wiki/Test?veaction=edit - where the content between the <translate> nodes is wrapped inside a <div> with that attribute, and where that part of the content stays editable.

A (convoluted) way to test this behaviour on a local installation:

  • run MW with Parsoid patch https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/769071/2 (test failures are irrelevant to the issue - tests haven't been updated yet for the new behaviour introduced by the patch)
  • declare some annotation (for instance by activating the Translate extension)
  • create wikitext content with said annotation, in a way that the annotation doesn't wrap a well-nested range, for instance
* hello <translate> world

some paragraph</translate> and some more

Related Objects

StatusSubtypeAssignedTask
OpenReleaseNone
OpenNone
OpenNone
OpenNone
OpenFeatureNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
ResolvedEsanders
OpenFeatureNone
Resolvedihurbain
Resolvedihurbain
ResolvedFeatureihurbain
ResolvedBUG REPORTmatmarex

Event Timeline

Change 769112 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[VisualEditor/VisualEditor@master] ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches

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

Change 769113 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] Pull through changes for Id4296736

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

This seemed like an obvious bug to me at first, but fixing it caused some test failures, so we might want to be a little more careful and think about whether this behavior was intentional.

The current behavior is that VE only makes nodes with typeof="mw:Placeholder" (or any other unrecognized rel, typeof or property) uneditable if they also have a rel, typeof or property that is recognized.

The MediaWiki DOM spec says:

A typeof="mw:Placeholder" protects DOM structures from any editing. Clients are expected to preserve / protect subtrees marked as such. Clients are also expected to preserve any DOM subtrees marked up with typeof, rel, property in the http://mediawiki.org/rdf/ namespace they don't understand. This decouples clients from Parsoid development, and lets them concentrate on editing constructs whose special semantics they understand without having to implement all possible content elements.

It's worth noting the <span typeof="bogus"> is valid wikitext. VE doesn't check the "in the mw: namespace." part, but Parsoid handles this by escaping all user-generated types (eg <span data-x-typeof="foo">) . So if VE sees a typeof, then it can depend on the fact that this was generated by Parsoid. We should probably amend the DOM spec to discuss this detail.

The DOM spec also discusses renaming mw:Placeholder to mw:Uneditable. Once @matmarex's patch lands, Parsoid should be able to do that freely, since both of these names will be equally "unknown" to VE. There won't be any 'special' behavior to the mw:Placeholder name in particular.

In practice, Parsoid used mw:Placeholder for two different purposes: initially it was to mark wikitext features that "VE didn't support yet". The use was then expanded to also mark HTML subtree that contains "uneditable wikitext". We expect to continue the latter use. But if a new wikitext feature was added to Parsoid's output, we'd expect that we'd only need to add a unique (not known to VE) typeof to the subtree; we wouldn't "also" have to tag it explicitly as placeholder/uneditable as we'd done in the past.

Test wiki created on Patch demo by IHurbainPalatin (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/48e84ba4ae/w/

Test wiki on Patch demo by IHurbainPalatin (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/48e84ba4ae/w/

Change 769112 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches

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

Hi @matmarex - quick question: is the above-merged patch a partial/complete solution to this issue? I created a patchdemo with that patch and mine - https://patchdemo.wmflabs.org/wikis/e26b32870e/wiki/Test - and I was expecting the first two elements of the list to be uneditable (because they're enclosed in a mw:Placeholder <div>) - am I missing something, or is this to be expected? Thanks!!

@ihurbain It is a complete solution – I think this is a problem with patchdemo, as I'm not seeing the new version of the code in https://patchdemo.wmflabs.org/wikis/e26b32870e/w/load.php?debug=2&lang=en&modules=ext.visualEditor.core. I don't know what happened there. Sorry D:

When trying to merge the submodule update (https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/769113), we were stopped by some test failures – it looks like we might need to update code in other extensions for this change. Basically, any ve.dm class that specifies matchTagNames or matchFunction, but not matchRdfaTypes, might require allowedRdfaTypes = null to be added to preserve existing behavior.

To be reviewed: https://codesearch.wmcloud.org/search/?q=static%5C.(matchTagNames%7CmatchFunction%7CmatchRdfaTypes)&i=nope&files=&excludeFiles=&repos=

I've reviewed the list and I haven't found anything that looks like it requires updates in extensions (only possibly ve.dm.AlienMetaItem in VE core). Suspicious classes either inherit matchRdfaTypes, or they are not supposed to match nodes with a type. In CX in particular, there is ve.dm.CXSentenceSegmentAnnotation with no matchRdfaTypes, but I think it's not supposed to match nodes with a type.

Unfortunately this means I don't know why the tests in CX are failing.

OK I found it!

The test for mw.cx.TranslationTracker.static.getSectionNodeValidationTokens includes some sample HTML that should have resulted in ve.dm.CXSectionNode matches, but that JS code was not being loaded in unit tests, so it was instead matching ve.dm.SectionNode… until now, when the lack of allowedRdfaTypes on that class resulted in it no longer matching.

Change 774974 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/ContentTranslation@master] tests: mw.cx.TranslationTracker: Fix for changes in VE

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

Change 774973 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[VisualEditor/VisualEditor@master] Allow unknown types for ve.dm.AlienMetaItem

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

Change 774974 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@master] tests: mw.cx.TranslationTracker: Fix for changes in VE

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

@matmarex thanks a lot!!

I actually finally faced the music and tested the patch on my local wiki and it worked as expected. (Now I'll need to polish the UX a bit, but I think that's on Translate side.) I was also going to ask for 1.38 backport, but I saw you took care of putting the tag already :) Thanks!!

Change 775361 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (cda4ec127)

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

Change 774973 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] Allow unknown types for ve.dm.AlienMetaItem

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

Change 769113 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (38b8213b5)

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

Change 775361 abandoned by Bartosz Dziewoński:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (cda4ec127)

Reason:

Duplicate

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

Change 775440 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[VisualEditor/VisualEditor@REL1_38] ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches

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

Change 775441 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[VisualEditor/VisualEditor@REL1_38] Allow unknown types for ve.dm.AlienMetaItem

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

Change 775440 merged by jenkins-bot:

[VisualEditor/VisualEditor@REL1_38] ve.dm.ModelRegistry: Disallow unknown types on tag and tag+func matches

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

Change 775441 merged by jenkins-bot:

[VisualEditor/VisualEditor@REL1_38] Allow unknown types for ve.dm.AlienMetaItem

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

Change 775864 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@REL1_38] Update VE core submodule to REL1_38

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

Change 775442 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/ContentTranslation@REL1_38] tests: mw.cx.TranslationTracker: Fix for changes in VE

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

Change 775864 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@REL1_38] Update VE core submodule to REL1_38

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

Change 775442 merged by jenkins-bot:

[mediawiki/extensions/ContentTranslation@REL1_38] tests: mw.cx.TranslationTracker: Fix for changes in VE

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

matmarex edited projects, added Skipped QA; removed Patch-For-Review.

I think that's everything merged and backported.

Change 884538 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to origin/REL1_38

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

Change 884538 abandoned by Reedy:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to origin/REL1_38

Reason:

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