From 5f26404987727b274f46e1e78ab456189e29771d Mon Sep 17 00:00:00 2001 From: boots Date: Wed, 14 Jun 2006 14:14:23 +0000 Subject: [PATCH] Fix handling of apostrophes in the capitalize modifier. Thanks to asmecher from the forums for reporting this and providing a partial solution. --- NEWS | 2 ++ libs/plugins/modifier.capitalize.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 605fa40a..06878567 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- fix handling of apostrophes in capitalize modifier (Alec Smecher, boots) + Version 2.6.14 (May 28th, 2006) ------------------------------- - fix compiler bug allowing php tags in secure templates diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php index bca951a0..4a611d9f 100644 --- a/libs/plugins/modifier.capitalize.php +++ b/libs/plugins/modifier.capitalize.php @@ -21,7 +21,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false) { smarty_modifier_capitalize_ucfirst(null, $uc_digits); - return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string); + return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string); } function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null) @@ -33,7 +33,7 @@ function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null) return; } - if(!preg_match('!\d!',$string[0]) || $_uc_digits) + if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits) return ucfirst($string[0]); else return $string[0];