r55644 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55643‎ | r55644 | r55645 >
Date:22:27, 27 August 2009
Author:demon
Status:ok (Comments)
Tags:
Comment:
Revert r53534 (bug 15745, Make the edit summary link parser detect links more like the real parser). Causes preg_replace_callback bug in 5.2.8 and below, crashes lots of things. See bug 19845 and http://bugs.php.net/bug.php?id=48501
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -7515,17 +7515,6 @@
75167516 <a href="https://www.mediawiki.org/wiki/Main_Page#section" title="Main Page">#section</a>
75177517 !! end
75187518
7519 -!! test
7520 -Edit comment with mismatched brackets (bug 15745)
7521 -!! options
7522 -comment
7523 -title=[[Main Page]]
7524 -!!input
7525 -Some text, a [[broken link|bad and a [[good link|good]]
7526 -!! result
7527 -Some text, a [[broken link|bad and a <a href="https://www.mediawiki.org/index.php?title=Good_link&amp;action=edit&amp;redlink=1" class="new" title="Good link (page does not exist)">good</a>
7528 -!! end
7529 -
75307519 TODO:
75317520 more images
75327521 more tables
Index: trunk/phase3/includes/Linker.php
@@ -1012,22 +1012,10 @@
10131013 public function formatLinksInComment( $comment, $title = null, $local = false ) {
10141014 $this->commentContextTitle = $title;
10151015 $this->commentLocal = $local;
1016 - # Borrowed from Parser::replaceInternalLinks2
1017 - $parts = StringUtils::explode( '[[', ' ' . $comment );
1018 - $start = $parts->current();
1019 - $parts->next();
1020 - $line = $parts->current();
1021 - $html = substr( $start, 1 );
1022 - for ( ; $line !== false && $line !== null ; $parts->next(), $line = $parts->current() ) {
1023 - $linked = preg_replace_callback(
1024 - '/^:?(.*?)(\|(.*?))*\]\]([^[]*)/',
1025 - array( $this, 'formatLinksInCommentCallback' ),
1026 - $line, -1, $count );
1027 - if( !$count ) { // No valid link found, put the brackets back
1028 - $linked = '[[' . $linked;
1029 - }
1030 - $html .= $linked;
1031 - }
 1016+ $html = preg_replace_callback(
 1017+ '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/',
 1018+ array( $this, 'formatLinksInCommentCallback' ),
 1019+ $comment );
10321020 unset( $this->commentContextTitle );
10331021 unset( $this->commentLocal );
10341022 return $html;
@@ -1056,7 +1044,7 @@
10571045 $thelink = null;
10581046 if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
10591047 # Media link; trail not supported.
1060 - $linkRegexp = '/^(.*?)\]\]/';
 1048+ $linkRegexp = '/\[\[(.*?)\]\]/';
10611049 $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
10621050 $thelink = $this->makeMediaLinkObj( $title, $text );
10631051 } else {
@@ -1066,7 +1054,7 @@
10671055 } else {
10681056 $trail = "";
10691057 }
1070 - $linkRegexp = '/^(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
 1058+ $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
10711059 if (isset($match[1][0]) && $match[1][0] == ':')
10721060 $match[1] = substr($match[1], 1);
10731061 list( $inside, $trail ) = Linker::splitTrail( $trail );
Index: trunk/phase3/RELEASE-NOTES
@@ -348,8 +348,6 @@
349349 * (bug 17374) Special:Export no longer exports multiple copies of pages
350350 * (bug 19818) Edits to user CSS/JS subpages can now be marked as patrolled by
351351 users who can't edit them
352 -* (bug 15745) The edit summary link parser now handles mismatched brackets
353 - better
354352 * (bug 19839) Comments in log items are no more double escaped
355353 * (bug 18161) Fix inconsistent separators in watchlist link toolbars with
356354 "enhanced recent changes"

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53534(bug 15745) Make the edit summary link parser detect links more like the real...mrzman06:29, 20 July 2009

Comments

#Comment by Simetrical (talk | contribs)   17:13, 28 August 2009

Confirmed that this stops segfaults I was getting on my site.

Status & tagging log