From b3051a6aae446e063c3b6fa4a6a600357a9f24af Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 20 Dec 2016 11:06:22 +0100 Subject: Fixes presence of empty tags for private tags and in search results * Private tags: make sure empty tags are properly filtered * Search results: * Use preg_split instead of function combination * Add normalize_spaces to remove extra whitespaces displaying empty tags search --- application/Utils.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'application/Utils.php') diff --git a/application/Utils.php b/application/Utils.php index 62902341..35d65224 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -257,3 +257,16 @@ function generate_api_secret($username, $salt) return str_shuffle(substr(hash_hmac('sha512', uniqid($salt), $username), 10, 12)); } + +/** + * Trim string, replace sequences of whitespaces by a single space. + * PHP equivalent to `normalize-space` XSLT function. + * + * @param string $string Input string. + * + * @return mixed Normalized string. + */ +function normalize_spaces($string) +{ + return preg_replace('/\s{2,}/', ' ', trim($string)); +} -- cgit v1.2.3