From 403ab49716c8bc7d93fc33bbf810e0814e3de049 Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Mon, 17 Mar 2014 15:54:28 +0530 Subject: [ticket/9040] Count HTML entities as single in custom profile fields Currently when an user adds a HTML entity to a custom profile field, the length gets incremented by 4 since the code reads > instead of <. However, the length is presentational and not DB storage so it should be treated as a single character even if it takes four lengths in the DB by being stored as a HTML entity. Work around this by decoding html entities before counting. Also, added unit tests for string field type PHPBB3-9040 --- phpBB/phpbb/profilefields/type/type_string_common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/profilefields') diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index 0738cbdafd..78e219a61f 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -65,7 +65,7 @@ abstract class type_string_common extends type_base { return $this->user->lang('FIELD_TOO_SHORT', (int) $field_data['field_minlen'], $this->get_field_name($field_data['lang_name'])); } - else if ($field_data['field_maxlen'] && utf8_strlen($field_value) > $field_data['field_maxlen']) + else if ($field_data['field_maxlen'] && utf8_strlen(html_entity_decode($field_value)) > $field_data['field_maxlen']) { return $this->user->lang('FIELD_TOO_LONG', (int) $field_data['field_maxlen'], $this->get_field_name($field_data['lang_name'])); } -- cgit v1.2.1