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


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)


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.


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:

bzimport set Reference to bz54332.
Thryduulf created this task.Via LegacySep 19 2013, 3:51 PM
Esanders added a comment.Via ConduitSep 19 2013, 4:01 PM

I think you mean bug 51442

Thryduulf added a comment.Via ConduitSep 19 2013, 4:04 PM

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:

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

(In reply to comment #1)

I think you mean bug 51442

I do. Dyslexia strikes again :(

Elitre added a comment.Via ConduitSep 19 2013, 6:35 PM

(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.)

Thryduulf added a comment.Via ConduitSep 19 2013, 6:54 PM

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.

Elitre added a comment.Via ConduitSep 19 2013, 7:19 PM

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.]] .

Jdforrester-WMF added a comment.Via ConduitSep 24 2013, 11:33 PM

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

gerritbot added a comment.Via ConduitSep 27 2013, 10:31 AM

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

Krinkle added a comment.Via ConduitSep 27 2013, 12:06 PM

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>).

gerritbot added a comment.Via ConduitSep 30 2013, 11:21 PM

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

Add Comment