diff --git a/common.php b/common.php index 615977e1f..78bc16ed4 100644 --- a/common.php +++ b/common.php @@ -264,6 +264,20 @@ function clean_filename($fname) return str_replace($s, '_', str_compact($fname)); } +/** + * Convert special characters to HTML entities + * + * @param $txt + * @param bool $double_encode + * @param int $quote_style + * @param ?string $charset + * @return string + */ +function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTES, ?string $charset = 'UTF-8'): string +{ + return (string)htmlspecialchars($txt ?? '', $quote_style, $charset, $double_encode); +} + /** * @param string $str * @return string diff --git a/library/includes/functions.php b/library/includes/functions.php index b57c96c9e..a90fd7fd5 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -787,20 +787,6 @@ function wbr($text, $max_word_length = HTML_WBR_LENGTH) return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . "})/ui", '$1', $text); } -/** - * Convert special characters to HTML entities - * - * @param $txt - * @param bool $double_encode - * @param int $quote_style - * @param ?string $charset - * @return string - */ -function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTES, ?string $charset = 'UTF-8'): string -{ - return (string)htmlspecialchars($txt ?? '', $quote_style, $charset, $double_encode); -} - function generate_user_info($row, bool $have_auth = IS_ADMIN): array { global $userdata, $lang, $images, $bb_cfg;