From 495227621745a89a81eacf23842bc5ffd2510ba6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 13 Jun 2014 08:44:53 +1200 Subject: [PATCH] CRM-14842 decode utf prior to checking strlen --- api/v3/utils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index 87e28954bc..849f70677d 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1817,8 +1817,8 @@ function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $enti _civicrm_api3_api_match_pseudoconstant($params, $entity, $fieldName, $fieldInfo); } // Check our field length - elseif (is_string($value) && !empty($fieldInfo['maxlength']) && strlen($value) > $fieldInfo['maxlength']) { - throw new API_Exception("Value for $fieldName is " . strlen($value) . " characters - This field has a maxlength of {$fieldInfo['maxlength']} characters.", + elseif (is_string($value) && !empty($fieldInfo['maxlength']) && strlen(utf8_decode($value)) > $fieldInfo['maxlength']) { + throw new API_Exception("Value for $fieldName is " . strlen(utf8_decode($value)) . " characters - This field has a maxlength of {$fieldInfo['maxlength']} characters.", 2100, array('field' => $fieldName) ); } -- 2.25.1