From 09d8a73eceba11ed021a697b3b8e283c5bc2dc6a Mon Sep 17 00:00:00 2001
From: Robin Millette <millette@controlyourself.ca>
Date: Sat, 7 Feb 2009 19:33:18 +0000
Subject: [PATCH] trac #1155 ++ replace strlen with mb_strlen for all utf8
 strings.

---
 actions/editgroup.php         | 6 +++---
 actions/finishopenidlogin.php | 2 +-
 actions/newgroup.php          | 6 +++---
 actions/profilesettings.php   | 6 +++---
 actions/register.php          | 6 +++---
 actions/twitapiaccount.php    | 2 +-
 actions/updateprofile.php     | 8 ++++----
 actions/userauthorization.php | 8 ++++----
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/actions/editgroup.php b/actions/editgroup.php
index 98ebcb87ac..e7e79040a4 100644
--- a/actions/editgroup.php
+++ b/actions/editgroup.php
@@ -191,13 +191,13 @@ class EditgroupAction extends Action
                                         array('http', 'https')))) {
             $this->showForm(_('Homepage is not a valid URL.'));
             return;
-        } else if (!is_null($fullname) && strlen($fullname) > 255) {
+        } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
             $this->showForm(_('Full name is too long (max 255 chars).'));
             return;
-        } else if (!is_null($description) && strlen($description) > 140) {
+        } else if (!is_null($description) && mb_strlen($description) > 140) {
             $this->showForm(_('description is too long (max 140 chars).'));
             return;
-        } else if (!is_null($location) && strlen($location) > 255) {
+        } else if (!is_null($location) && mb_strlen($location) > 255) {
             $this->showForm(_('Location is too long (max 255 chars).'));
             return;
         }
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index bc91511207..1e7b73a7f3 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -242,7 +242,7 @@ class FinishopenidloginAction extends Action
             }
         }
 
-        if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
+        if ($sreg['fullname'] && mb_strlen($sreg['fullname']) <= 255) {
             $fullname = $sreg['fullname'];
         }
 
diff --git a/actions/newgroup.php b/actions/newgroup.php
index 42fd380dfe..cbd8dfeec5 100644
--- a/actions/newgroup.php
+++ b/actions/newgroup.php
@@ -142,13 +142,13 @@ class NewgroupAction extends Action
                                         array('http', 'https')))) {
             $this->showForm(_('Homepage is not a valid URL.'));
             return;
-        } else if (!is_null($fullname) && strlen($fullname) > 255) {
+        } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
             $this->showForm(_('Full name is too long (max 255 chars).'));
             return;
-        } else if (!is_null($description) && strlen($description) > 140) {
+        } else if (!is_null($description) && mb_strlen($description) > 140) {
             $this->showForm(_('description is too long (max 140 chars).'));
             return;
-        } else if (!is_null($location) && strlen($location) > 255) {
+        } else if (!is_null($location) && mb_strlen($location) > 255) {
             $this->showForm(_('Location is too long (max 255 chars).'));
             return;
         }
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 82e6c3c82f..60f7c0796e 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -198,13 +198,13 @@ class ProfilesettingsAction extends AccountSettingsAction
                    !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
             $this->showForm(_('Homepage is not a valid URL.'));
             return;
-        } else if (!is_null($fullname) && strlen($fullname) > 255) {
+        } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
             $this->showForm(_('Full name is too long (max 255 chars).'));
             return;
-        } else if (!is_null($bio) && strlen($bio) > 140) {
+        } else if (!is_null($bio) && mb_strlen($bio) > 140) {
             $this->showForm(_('Bio is too long (max 140 chars).'));
             return;
-        } else if (!is_null($location) && strlen($location) > 255) {
+        } else if (!is_null($location) && mb_strlen($location) > 255) {
             $this->showForm(_('Location is too long (max 255 chars).'));
             return;
         }  else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
diff --git a/actions/register.php b/actions/register.php
index 01d94f4884..5d7a8ce690 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -167,13 +167,13 @@ class RegisterAction extends Action
                                         array('http', 'https')))) {
             $this->showForm(_('Homepage is not a valid URL.'));
             return;
-        } else if (!is_null($fullname) && strlen($fullname) > 255) {
+        } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
             $this->showForm(_('Full name is too long (max 255 chars).'));
             return;
-        } else if (!is_null($bio) && strlen($bio) > 140) {
+        } else if (!is_null($bio) && mb_strlen($bio) > 140) {
             $this->showForm(_('Bio is too long (max 140 chars).'));
             return;
-        } else if (!is_null($location) && strlen($location) > 255) {
+        } else if (!is_null($location) && mb_strlen($location) > 255) {
             $this->showForm(_('Location is too long (max 255 chars).'));
             return;
         } else if (strlen($password) < 6) {
diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php
index dc8e2e798b..b7c09cc9dc 100644
--- a/actions/twitapiaccount.php
+++ b/actions/twitapiaccount.php
@@ -56,7 +56,7 @@ class TwitapiaccountAction extends TwitterapiAction
 
         $location = trim($this->arg('location'));
 
-        if (!is_null($location) && strlen($location) > 255) {
+        if (!is_null($location) && mb_strlen($location) > 255) {
 
             // XXX: But Twitter just truncates and runs with it. -- Zach
             $this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
diff --git a/actions/updateprofile.php b/actions/updateprofile.php
index c79112dace..898c535432 100644
--- a/actions/updateprofile.php
+++ b/actions/updateprofile.php
@@ -93,22 +93,22 @@ class UpdateprofileAction extends Action
         }
         # optional stuff
         $fullname = $req->get_parameter('omb_listenee_fullname');
-        if ($fullname && strlen($fullname) > 255) {
+        if ($fullname && mb_strlen($fullname) > 255) {
             $this->clientError(_("Full name is too long (max 255 chars)."));
             return false;
         }
         $homepage = $req->get_parameter('omb_listenee_homepage');
-        if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
+        if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
             $this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
             return false;
         }
         $bio = $req->get_parameter('omb_listenee_bio');
-        if ($bio && strlen($bio) > 140) {
+        if ($bio && mb_strlen($bio) > 140) {
             $this->clientError(_("Bio is too long (max 140 chars)."));
             return false;
         }
         $location = $req->get_parameter('omb_listenee_location');
-        if ($location && strlen($location) > 255) {
+        if ($location && mb_strlen($location) > 255) {
             $this->clientError(_("Location is too long (max 255 chars)."));
             return false;
         }
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index 58fc96c0eb..7455a41a6f 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -469,19 +469,19 @@ class UserauthorizationAction extends Action
         }
         # optional stuff
         $fullname = $req->get_parameter('omb_listenee_fullname');
-        if ($fullname && strlen($fullname) > 255) {
+        if ($fullname && mb_strlen($fullname) > 255) {
             throw new OAuthException("Full name '$fullname' too long.");
         }
         $homepage = $req->get_parameter('omb_listenee_homepage');
-        if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
+        if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
             throw new OAuthException("Invalid homepage '$homepage'");
         }
         $bio = $req->get_parameter('omb_listenee_bio');
-        if ($bio && strlen($bio) > 140) {
+        if ($bio && mb_strlen($bio) > 140) {
             throw new OAuthException("Bio too long '$bio'");
         }
         $location = $req->get_parameter('omb_listenee_location');
-        if ($location && strlen($location) > 255) {
+        if ($location && mb_strlen($location) > 255) {
             throw new OAuthException("Location too long '$location'");
         }
         $avatar = $req->get_parameter('omb_listenee_avatar');
-- 
2.39.5