mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding charset/encoding settings to h(), closes #4040
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6541 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
98831d27fe
commit
c40bead47c
1 changed files with 9 additions and 2 deletions
|
@ -274,13 +274,20 @@ if (!function_exists('clone')) {
|
||||||
* Convenience method for htmlspecialchars.
|
* Convenience method for htmlspecialchars.
|
||||||
*
|
*
|
||||||
* @param string $text Text to wrap through htmlspecialchars
|
* @param string $text Text to wrap through htmlspecialchars
|
||||||
|
* @param string $charset Character set to use when escaping. Defaults to config value in 'App.encoding' or 'UTF-8'
|
||||||
* @return string Wrapped text
|
* @return string Wrapped text
|
||||||
*/
|
*/
|
||||||
function h($text) {
|
function h($text, $charset = null) {
|
||||||
if (is_array($text)) {
|
if (is_array($text)) {
|
||||||
return array_map('h', $text);
|
return array_map('h', $text);
|
||||||
}
|
}
|
||||||
return htmlspecialchars($text);
|
if (empty($charset)) {
|
||||||
|
$charset = Configure::read('App.encoding');
|
||||||
|
}
|
||||||
|
if (empty($charset)) {
|
||||||
|
$charset = 'UTF-8';
|
||||||
|
}
|
||||||
|
return htmlspecialchars($text, ENT_QUOTES, $charset);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns an array of all the given parameters.
|
* Returns an array of all the given parameters.
|
||||||
|
|
Loading…
Reference in a new issue