Page MenuHomePhabricator

Internal copy/paste can cause an unbalanced transaction
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce:

  1. In VisualEditor standalone, edit <h1>AB</h1><p>C</p>
  2. Select from B to C (inclusive), then press CTRL+C
  3. Move the cursor to inside the end of the heading (just after the B), then press CTRL+V

Expected behaviour:

A balanced transaction is appended to the history AND the document data stays balanced.

Observed behaviour:

An unbalanced transaction is appended, which would insert the following content:

[
    { type: 'paragraph' },
    'B',
    { type: '/heading' },  // UNBALANCED
    { type: 'paragraph' },
    'C',
    { type: '/paragraph' }
]

However, the document data stays balanced.

Event Timeline

Change 908678 had a related patch set uploaded (by Divec; author: Divec):

[VisualEditor/VisualEditor@master] TreeModifier: Check for inserting unbalanced open-close tag sequence

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

The above patch set fixes the case described above. More generally, is it correct that the paste code should pass arbitrary unbalanced content to the TransactionProcessor, and rely on an error being thrown to switch to "safer" processing? Or is that something we wish to change?

I think we assumed fixUpinsertion would fix it?

dchan updated the task description. (Show Details)

Change 908678 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] TreeModifier: Check for inserting unbalanced open-close tag sequence

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

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

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

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

Change 910809 merged by jenkins-bot:

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

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