[gnome-shell/gnome-3-2] browser-plugin: Make sure to use the UTF8Length parameter



commit e890674e491518ce9dd897473e9bc588ab5fa90e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Nov 16 23:47:35 2011 -0500

    browser-plugin: Make sure to use the UTF8Length parameter
    
    Some plugin hosts may have junk after the UTF8Characters that we need to strip
    off. No current browsers that I know of do this, but it still helps to be
    correct.

 browser-plugin/browser-plugin.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/browser-plugin/browser-plugin.c b/browser-plugin/browser-plugin.c
index 385550c..e9f9950 100644
--- a/browser-plugin/browser-plugin.c
+++ b/browser-plugin/browser-plugin.c
@@ -455,7 +455,7 @@ plugin_enable_extension (PluginObject *obj,
                          NPString      uuid,
                          gboolean      enabled)
 {
-  const gchar *uuid_str = uuid.UTF8Characters;
+  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -468,6 +468,8 @@ plugin_enable_extension (PluginObject *obj,
                      NULL, /* callback */
                      NULL /* user_data */);
 
+  g_free (uuid_str);
+
   return TRUE;
 }
 
@@ -476,7 +478,7 @@ plugin_install_extension (PluginObject *obj,
                           NPString      uuid,
                           NPString      version_tag)
 {
-  const gchar *uuid_str = uuid.UTF8Characters;
+  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -491,6 +493,8 @@ plugin_install_extension (PluginObject *obj,
                      NULL, /* callback */
                      NULL /* user_data */);
 
+  g_free (uuid_str);
+
   return TRUE;
 }
 
@@ -501,9 +505,9 @@ plugin_uninstall_extension (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -516,6 +520,8 @@ plugin_uninstall_extension (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to uninstall extension: %s", error->message);
@@ -533,9 +539,9 @@ plugin_get_info (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -547,6 +553,8 @@ plugin_get_info (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to retrieve extension metadata: %s", error->message);
@@ -564,9 +572,9 @@ plugin_get_errors (PluginObject *obj,
 {
   GError *error = NULL;
   GVariant *res;
-  const gchar *uuid_str;
+  gchar *uuid_str;
 
-  uuid_str = uuid.UTF8Characters;
+  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
   if (!uuid_is_valid (uuid_str))
     return FALSE;
 
@@ -578,6 +586,8 @@ plugin_get_errors (PluginObject *obj,
                                 NULL, /* cancellable */
                                 &error);
 
+  g_free (uuid_str);
+
   if (!res)
     {
       g_warning ("Failed to retrieve errors: %s", error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]