From e4a08873ac4ca0af95ba9d4cc424cdb5c0f95692 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Sun, 26 Aug 2018 13:44:18 +0200 Subject: [PATCH] remove line breaks method --- bl-kernel/helpers/text.class.php | 6 ++++++ bl-kernel/pages.class.php | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bl-kernel/helpers/text.class.php b/bl-kernel/helpers/text.class.php index fd15d378..fa1b423a 100644 --- a/bl-kernel/helpers/text.class.php +++ b/bl-kernel/helpers/text.class.php @@ -126,6 +126,11 @@ class Text { return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string); } + public static function removeLineBreaks($string) + { + return str_replace(array("\r", "\n"), '', $string); + } + // Convert unicode characters to utf-8 characters // Characters that cannot be converted will be removed from the string // This function can return an empty string @@ -137,6 +142,7 @@ class Text { $string = self::lowercase($string); $string = trim($string, $separator); $string = self::removeSpecialCharacters($string, $separator); + $string = self::removeLineBreaks($string); $string = trim($string, $separator); return $string; } diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index 7e5a7d3c..f722e3c3 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -606,8 +606,7 @@ class Pages extends dbJSON { // Returns string without HTML tags and truncated private function generateSlug($text, $truncateLength=60) { $tmpslug = Text::removeHTMLTags($text); - // Remove break lines - $tmpslug = str_replace(array("\r", "\n"), '', $tmpslug); + $tmpslug = Text::removeLineBreaks($tmpslug); return Text::truncate($tmpslug, $truncateLength, ''); }