From 8d6213da2a881319a45c524c14a468db0f33ef94 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Sat, 31 Jan 2009 00:46:38 +0000 Subject: [PATCH] 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. --- includes/parser/CoreParserFunctions.php | 1 + 1 file changed, 1 insertion(+) 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 ); -- 2.20.1