From: This, that and the other Date: Sun, 29 Nov 2015 10:30:17 +0000 (+1100) Subject: Handle links with multiple pipes correctly in edit summaries X-Git-Tag: 1.31.0-rc.0~5361^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=3d1dbd4c4887c329efdb4cc9b80a9ffdd452d0af Handle links with multiple pipes correctly in edit summaries Bug: T99346 Change-Id: I459b0027c7703b2379e024d88fab74b17ebb11e9 --- 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