Page MenuHomePhabricator

VisualEditor doesn't cope gracefully with line-breaking whitespace in a ref name
Closed, ResolvedPublic


See the very informative comments at by @Jhertel and @Weblars. Until you make an edit such as to remove these characters from the ref name (which you can't do in the visual editor right now), then the visual editor won't save the page.


  1. Visit this page with the console open:
  2. Type some extra text anywhere in the document
  3. Attempt to switch to wikitext

Obervered: An exception is thrown, switching fails
Expected: No exception thrown, switching succeeds

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 23 2020, 10:21 PM

The character ends up in the JS as "\u2028" and breaks the regex:

> ["literal/foo", index: 0, input: "literal/foo
bar", groups: undefined]

Note that the .* stops matching after foo

Esanders renamed this task from VisualEditor doesn't cope gracefully with ö and similar characters in a ref name to VisualEditor doesn't cope gracefully with line-breaking whitespace in a ref name.Sep 24 2020, 12:07 PM

Change 629670 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/Cite@master] Match line-breaking whitespace in reference names

Esanders updated the task description. (Show Details)
Esanders moved this task from To Triage to Triaged on the VisualEditor board.
matmarex added a subscriber: matmarex.

There's probably a Parsoid issue here. If you type a regular newline in a ref name, it's replaced with a space when parsing – the same should probably happen to this character, and any similar newline-like things (probably just U+2028 and U+2029?). But it won't hurt to also handle this in VE.

test<ref name="a

blah<ref name="a
b" />

test<ref name="a

blah<ref name="a
b" />

<references />

Exception for reference, in case this comes up in error logging or someone files duplicates:


Uncaught TypeError: listKeyParts is null
    toDomElements jQuery
    getDomElementsFromDataElement ...:313
    getDomSubtreeFromData ...:337
    getDomSubtreeFromModel ...:329
    getDomFromModel ...:328
    getDom ...:227
    getDom ...:657
    createDocToSave ...:19
    getDocToSave ...:19
    getWikitextDataPromiseForDoc ...:36
    switchToWikitextEditor ...:36
    switchToWikitextEditor ...:952
    editSource ...:19
    switch ...:48
    onSelect ...:1553
    jQuery 4
    <anonymous> self-hosted:935
    jQuery 2
    <anonymous> self-hosted:935
    jQuery 15
    setup ...:681
    setupToolbar ...:67
    setupToolbar ...:29
    setupToolbar ...:926
    setSurface ...:66
    setSurface ...:1043
    setSurface ...:931
    addSurface ...:1043
    addSurface ...:925
    setupSurface ...:1042
    (Async: setTimeout handler)
    setupSurface ...:1042
    (Async: setTimeout handler)
    setupSurface ...:1042
    documentReady ...:1040
    documentReady ...:8
    loadSuccess ...:6
    loadSuccess ...:928
    <anonymous> self-hosted:935
    jQuery 2
    load ...:18
    activate ...:930
    activateTarget ...:13
    jQuery 19


Uncaught TypeError: Cannot read property '1' of null
    at (...:669)
    at (...:313)
    at (...:337)
    at (...:329)
    at (...:328)
    at (...:227)
    at (...:657)
    at (...:19)
    at (...:19)
    at (...:36)

Change 629670 merged by jenkins-bot:
[mediawiki/extensions/Cite@master] Match line-breaking whitespace in reference names

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

Is this resolved on the VE side? I will open a separate ticket for T263698#6492289.

matmarex edited projects, added Skipped QA; removed Editing QA.
ppelberg closed this task as Resolved.Sat, Nov 21, 3:02 AM
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptSat, Nov 21, 3:02 AM