CRM-14842 decode utf prior to checking strlen
authorEileen McNaughton <eileen@fuzion.co.nz>
Thu, 12 Jun 2014 20:44:53 +0000 (08:44 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Thu, 12 Jun 2014 20:44:53 +0000 (08:44 +1200)
api/v3/utils.php

index 87e28954bc7b8bbed2dc38b59304602b6b43a596..849f70677d1815148391e268c2fcd1aa3470f058 100644 (file)
@@ -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)
       );
     }