From 3d1dbd4c4887c329efdb4cc9b80a9ffdd452d0af Mon Sep 17 00:00:00 2001 From: "This, that and the other" Date: Sun, 29 Nov 2015 21:30:17 +1100 Subject: [PATCH] Handle links with multiple pipes correctly in edit summaries Bug: T99346 Change-Id: I459b0027c7703b2379e024d88fab74b17ebb11e9 --- includes/Linker.php | 8 ++++---- tests/parser/parserTests.txt | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 8682991bf8..9011f177de 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1311,10 +1311,10 @@ class Linker { :? # ignore optional leading colon ([^\]|]+) # 1. link target; page names cannot include ] or | (?:\| - # 2. a pipe-separated substring; only the last is captured - # Stop matching at | and ]] without relying on backtracking. - ((?:]?[^\]|])*+) - )* + # 2. link text + # Stop matching at ]] without relying on backtracking. + ((?:]?[^\]])*+) + )? \]\] ([^[]*) # 3. link trail (the text up until the next link) /x', diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 2c8b163a5f..1e511f67f5 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -20905,6 +20905,26 @@ Id starting with underscore !! end +!! test +Edit comment with link with more than one pipe (T99346) +!! options +comment +!! wikitext +[[Main Page|Many|pipes]] +!! html +Many|pipes +!! end + +!! test +Complex edit comment with link with more than one pipe (T99346) +!! options +comment +!! wikitext +Created page with "[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]] === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..." +!! html +Created page with "<noinclude>{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}</noinclude> === User:MineoBot 8=== {{Request for permissions/links|Mineo..." +!! end + !! test Space normalisation on autocomment (bug 22784) !! options -- 2.20.1