r56894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56893‎ | r56894 | r56895 >
Date:20:51, 24 September 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
avoid use of non-mb-safe strrev() function (this fixes Bug 20795)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -339,17 +339,14 @@
340340 }
341341
342342 /**
343 - * Replace the last two space characters with unbreakable spaces
 343+ * Replace the last two space characters with unbreakable spaces for beautification.
344344 *
345345 * @param[in] $text string Text to be transformed. Does not need to have spaces
346346 * @return string Transformed text
347347 */
348348 private function unbreak($text) {
349 - // replace the last two whitespaces in the relation name with
350 - // non-breaking spaces. Since there seems to be no PHP-replacer
351 - // for the last two, a strrev ist done twice to turn it around.
352 - // That's why nbsp is written backwards.
353 - return strrev(preg_replace('/[\s]/u', ';psbn&', strrev($text), 2) );
 349+ $text = preg_replace('/[\s]/u', ' ', $text, -1, $count);
 350+ return $count>2?preg_replace('/( )/u', ' ', $text, max(0,$count-2)):$text;
354351 }
355352
356353 }

Status & tagging log