From bb38c70f17159a98aed9987e76cf21a2f350d893 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 2 Feb 2012 17:34:49 +0100 Subject: [PATCH] Trim non-breaking-whitespace as well --- wcfsetup/install/files/lib/util/StringUtil.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index 52bf7d7c42..d6a7f160c1 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -113,13 +113,17 @@ class StringUtil { } /** - * alias to php trim() function + * Swallowes whitespace from beginnung and end of the string. * * @param string $string * @return string $string */ - public static function trim($text) { - return trim($text); + public static function trim($text, $) { + // Whitespace + (narrow) non breaking spaces. + // No one can triforce now. + $text = preg_replace('/^(\s|'.chr(226).chr(128).chr(175).'|'.chr(194).chr(160).')+/', '', $text); + $text = preg_replace('/(\s|'.chr(226).chr(128).chr(175).'|'.chr(194).chr(160).')+$/', '', $text); + return $text; } /** -- 2.20.1