Revert r53534 (bug 15745, Make the edit summary link parser detect links more like...
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 27 Aug 2009 22:27:42 +0000 (22:27 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 27 Aug 2009 22:27:42 +0000 (22:27 +0000)
RELEASE-NOTES
includes/Linker.php
maintenance/parserTests.txt

index e8caad0..dd456bf 100644 (file)
@@ -348,8 +348,6 @@ this. Was used when mwEmbed was going to be an extension.
 * (bug 17374) Special:Export no longer exports multiple copies of pages
 * (bug 19818) Edits to user CSS/JS subpages can now be marked as patrolled by
   users who can't edit them
-* (bug 15745) The edit summary link parser now handles mismatched brackets
-  better
 * (bug 19839) Comments in log items are no more double escaped
 * (bug 18161) Fix inconsistent separators in watchlist link toolbars with
   "enhanced recent changes"
index 7a86100..fbc4a83 100644 (file)
@@ -1012,22 +1012,10 @@ class Linker {
        public function formatLinksInComment( $comment, $title = null, $local = false ) {
                $this->commentContextTitle = $title;
                $this->commentLocal = $local;
-               # Borrowed from Parser::replaceInternalLinks2
-               $parts = StringUtils::explode( '[[', ' ' . $comment );
-               $start = $parts->current();
-               $parts->next();
-               $line = $parts->current();
-               $html = substr( $start, 1 );
-               for ( ; $line !== false && $line !== null ; $parts->next(), $line = $parts->current() ) {                       
-                       $linked = preg_replace_callback(
-                               '/^:?(.*?)(\|(.*?))*\]\]([^[]*)/',
-                               array( $this, 'formatLinksInCommentCallback' ),
-                               $line, -1, $count );
-                       if( !$count ) { // No valid link found, put the brackets back
-                               $linked = '[[' . $linked;
-                       }
-                       $html .= $linked;
-               }
+               $html = preg_replace_callback(
+                       '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/',
+                       array( $this, 'formatLinksInCommentCallback' ),
+                       $comment );
                unset( $this->commentContextTitle );
                unset( $this->commentLocal );
                return $html;
@@ -1056,7 +1044,7 @@ class Linker {
                $thelink = null;
                if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
                        # Media link; trail not supported.
-                       $linkRegexp = '/^(.*?)\]\]/';
+                       $linkRegexp = '/\[\[(.*?)\]\]/';
                        $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
                        $thelink = $this->makeMediaLinkObj( $title, $text );
                } else {
@@ -1066,7 +1054,7 @@ class Linker {
                        } else {
                                $trail = "";
                        }
-                       $linkRegexp = '/^(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
+                       $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
                        if (isset($match[1][0]) && $match[1][0] == ':')
                                $match[1] = substr($match[1], 1);
                        list( $inside, $trail ) = Linker::splitTrail( $trail );
index f020094..8359126 100644 (file)
@@ -7515,17 +7515,6 @@ title=[[Main Page]]
 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
 !! end
 
-!! test
-Edit comment with mismatched brackets (bug 15745)
-!! options
-comment
-title=[[Main Page]]
-!!input
-Some text, a [[broken link|bad and a [[good link|good]]
-!! result
-Some text, a [[broken link|bad and a <a href="/index.php?title=Good_link&amp;action=edit&amp;redlink=1" class="new" title="Good link (page does not exist)">good</a>
-!! end
-
 TODO:
 more images
 more tables