Fix handling of apostrophes in the capitalize modifier.

Thanks to asmecher from the forums for reporting this and providing a partial solution.
This commit is contained in:
boots
2006-06-14 14:14:23 +00:00
parent 25e2139f8f
commit 5f26404987
2 changed files with 4 additions and 2 deletions

2
NEWS
View File

@@ -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

View File

@@ -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];