Page MenuHomePhabricator

VisualEditor: Inserting into a link with a trailing (linked) non-alphanumeric character causes link pre-annotation to fail
Closed, ResolvedPublic

Description

Following on from the reports at bug 51142 comments 5-9

In every case where the last character of a link is non-alphanumeric and any text is inserted before that character. It seems that the underscore behaves as an alphanumeric character, and that script is irrelevant. It doesn't matter if the link was added in the current editing session or not.

e.g. [[Link|Link.]] → [[Link]]<nowiki />s[[Link|.]]
but [[Links]] → [[Linkers]] (this is the expected behaviour for all situations)

See https://en.wikipedia.org/w/index.php?title=User%3AThryduulf%2Fsandbox3&diff=573654600&oldid=573653290

If due to this a non-alphanumeric character that was previously mid-link but now becomes the last character of the link, adding any character before it triggers the bug again.

See https://en.wikipedia.org/w/index.php?title=User:Thryduulf/sandbox3&diff=573655981&oldid=573654600

In VE it is easy to include trailing punctuation (particularly commas and full stops) in a link without realising it (this is a side-effect of the WYSIWYG), meaning this occurs more often than might be expected (see comments at bug 51142).


Version: unspecified
Severity: minor
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=51442

Details

Reference
bz54332

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:01 AM
bzimport set Reference to bz54332.

How to reproduce

  1. Load any page in VE
  2. Type any sequence of characters ending in one or more non-space characters followed by any non-alphanumeric character except space or underscore. For example: Foo?
  3. Link what you have written, including the last character, to any target (e.g. [[Wikipedia]].
  4. add any text immediately before the last character. eg. change Foo? to Fooish?
  5. Save and look at the diff.

Expected wikitext:
[[Wikipedia|Fooish?]]

Actual wikitext:
[[Wikipedia|Foo]]<nowiki />ish[[Wikipedia|?]]

(In reply to comment #1)

I think you mean bug 51442

I do. Dyslexia strikes again :(

(I'd add that, at least for me, there is a desired outcome, which is that VE puts the non-alphanumeric character outside the link - of course, I am not sure this is doable or desirable, but this is why I had added my report to 51442.)

In some cases the non-alphnumeric is desired - [[Fun.]], [[Westward Ho!]] and [[C++]] are cases that spring immediately to mind.

I think it is best that VE does what you ask it to, whether that is what you wanted or not. Anything typed in the middle of a link should be included in that link in all cases, which would make spotting that trailing punctuation is limited easier.

You are right, Chris. I just thought VE could easily recognize cases in which punctuation could just be included by mistake, because the wikilink would be something like [[Fun.]], not [[Fun|Fun.]] .

Yeah, this looks like an off-by-one error in the code for link annotations to not span "word break" characters.

Change 86235 had a related patch set uploaded by Esanders:
Typing into an annotation next to a word break

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

btw, the <nowiki/> is inserted by Parsoid to make sure the document we have (<a>Foo/a>ish<a>?</a>) is translated properly into what the PHP parser understands as by default the PHP parser treats "<a> + adjecent text" as a shortcut to extend the lable (e.g. [[book]]s becomes <a href="book">books</a>).

Change 86235 merged by jenkins-bot:
Typing into an annotation next to a word break keeps annotation

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