Page MenuHomePhabricator

0002-Add-comments-to-Linker-formatLinksInComment.patch

Authored By
bzimport
Nov 22 2014, 12:45 AM
Size
1 KB
Referenced Files
None
Subscribers
None

0002-Add-comments-to-Linker-formatLinksInComment.patch

From 6fc7a1d707023cc180481639c940cf7784f295b8 Mon Sep 17 00:00:00 2001
From: Kevin Israel <pleasestand@live.com>
Date: Mon, 29 Oct 2012 21:49:15 -0400
Subject: [PATCH] Add comments to Linker::formatLinksInComment()
Per Tim Starling's suggestion, added comments to the regex in
Linker::formatLinksInComment().
Change-Id: If85567e5a2e57dd56f5f263f3512e9ed2f9c940c
---
includes/Linker.php | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/includes/Linker.php b/includes/Linker.php
index 66cb7e7..e711ff5 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1373,7 +1373,18 @@ class Linker {
self::$commentContextTitle = $title;
self::$commentLocal = $local;
$html = preg_replace_callback(
- '/\[\[:?([^\]|]+)(?:\|((?:]?[^\]|])*+))*\]\]([^[]*)/',
+ '/
+ \[\[
+ :? # 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.
+ ((?:]?[^\]|])*+)
+ )*
+ \]\]
+ ([^[]*) # 3. link trail (the text up until the next link)
+ /x',
array( 'Linker', 'formatLinksInCommentCallback' ),
$comment );
self::$commentContextTitle = null;
--
1.8.0

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9073
Default Alt Text
0002-Add-comments-to-Linker-formatLinksInComment.patch (1 KB)

Event Timeline