From 901e3227fba75181001fd674a8886934ffc505a8 Mon Sep 17 00:00:00 2001
From: Jerome Guelfucci <jeromeg@xfce.org>
Date: Tue, 7 Jul 2009 21:56:01 +0000
Subject: [PATCH] Fix ZimageZ login with UTF-8 characters.

g_strreverse should not be used with UTF-8 strings! Also fix the error
checking for the logout method, which is by the way broken (upstream
has been contacted for this).


(Old svn revision: 7691)
---
 ChangeLog                   |  8 ++++++++
 lib/screenshooter-zimagez.c | 15 ++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fb307edf..05c368ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-07-07 jeromeg
 
+Fix ZimageZ login with UTF-8 characters.
+
+g_strreverse should not be used with UTF-8 strings! Also fix the error
+checking for the logout method, which is by the way broken (upstream
+has been contacted for this).
+
+2009-07-07 jeromeg
+
 Use libsoup instead of XMLRPC-C.
 
 Add libsoup as a dependency, remove the XMLRPC-C stuff. Factorize the
diff --git a/lib/screenshooter-zimagez.c b/lib/screenshooter-zimagez.c
index 5545e6d4..6b47e276 100644
--- a/lib/screenshooter-zimagez.c
+++ b/lib/screenshooter-zimagez.c
@@ -378,7 +378,7 @@ zimagez_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **e
           continue;
         }
 
-      encoded_password = g_strdup (g_strreverse (rot13 (password)));
+      encoded_password = g_utf8_strreverse (rot13 (password), -1);
 
       TRACE ("User: %s", user);
       TRACE ("Encoded password: %s", encoded_password);
@@ -598,10 +598,8 @@ zimagez_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **e
              G_TYPE_STRING, login_response,
              G_TYPE_INVALID);
 
-  if (tmp_error)
-    g_error_free (tmp_error);
-
-  g_value_unset (&response_value);
+  if (G_IS_VALUE (&response_value))
+    g_value_unset (&response_value);
 
   /* Clean the soup session */
   soup_session_abort (session);
@@ -610,6 +608,13 @@ zimagez_upload_job (ScreenshooterJob *job, GValueArray *param_values, GError **e
 
   screenshooter_job_image_uploaded (job, online_file_name);
 
+  if (tmp_error)
+    {
+      g_propagate_error (error, tmp_error);
+
+      return FALSE;
+    }
+
   return TRUE;
 }
 
-- 
GitLab