From: Andrew Garrett Date: Sat, 31 Jan 2009 00:46:38 +0000 (+0000) Subject: Don't allow padding parser functions to be used to truncate strings. This breaks... X-Git-Tag: 1.31.0-rc.0~43111 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=8d6213da2a881319a45c524c14a468db0f33ef94;p=lhc%2Fweb%2Fwiklou.git Don't allow padding parser functions to be used to truncate strings. This breaks in some situations, and also encourages its use to reconstruct StringFunctions with core parser functions, which is undesirable for performance and usability reasons. --- diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 8e7914dc90..cbeb144228 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -333,6 +333,7 @@ class CoreParserFunctions { static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { $lengthOfPadding = mb_strlen( $padding ); if ( $lengthOfPadding == 0 ) return $string; + if ( $length < mb_strlen( $string ) ) return $string; # The remaining length to add counts down to 0 as padding is added $length = min( $length, 500 ) - mb_strlen( $string );