From: Andrew Garrett Date: Sat, 31 Jan 2009 11:43:42 +0000 (+0000) Subject: Fix r46628 -- I'd misunderstood the nature of the hack. People wanted to append the... X-Git-Tag: 1.31.0-rc.0~43103 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=cff78fbda1e167043323c9baf0184fcf3e3cf937;p=lhc%2Fweb%2Fwiklou.git Fix r46628 -- I'd misunderstood the nature of the hack. People wanted to append the string to be truncated to an empty string, not the reverse. --- diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 1045fad2a0..fba3d5faf0 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -381,7 +381,11 @@ 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; + + // Thwart attempts to use this function to truncate strings. + // We don't want people implementing ParserFunctions in template, + // for performance and usability reasons. + if ($lengthOfPadding > $length && $string == '') return $string; # The remaining length to add counts down to 0 as padding is added $length = min( $length, 500 ) - mb_strlen( $string );