changeset 411:8c087e1b5c6b

Fixed PR863: Error passing strings to applet methods in Chromium
author Deepak Bhole <dbhole@redhat.com>
date Fri, 01 Jun 2012 16:05:18 -0400
parents d302c51bd619
children 73f6e7fd1446
files ChangeLog NEWS plugin/icedteanp/IcedTeaJavaRequestProcessor.cc plugin/icedteanp/IcedTeaNPPlugin.cc plugin/icedteanp/IcedTeaPluginRequestProcessor.cc plugin/icedteanp/IcedTeaPluginUtils.cc
diffstat 6 files changed, 34 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 30 13:36:41 2012 +0200
+++ b/ChangeLog	Fri Jun 01 16:05:18 2012 -0400
@@ -1,3 +1,16 @@
+2012-06-01  Deepak Bhole <dbhole@redhat.com>
+
+	PR863: Error passing strings to applet methods in Chromium
+	* plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
+	(createJavaObjectFromVariant): Account for length of the characters.
+	* plugin/icedteanp/IcedTeaNPPlugin.cc (plugin_get_documentbase): Same.
+	* plugin/icedteanp/IcedTeaPluginRequestProcessor.cc (_eval): Print the
+	string's c_str rather than utf8characters/
+	* plugin/icedteanp/IcedTeaPluginUtils.cc (printNPVariant): Account for
+	length of the characters.
+	(NPVariantToString): Same.
+	(isObjectJSArray): Same.
+
 2012-05-30  Jiri Vanek  <jvanek@redhat.com>
 
 	Enabled multiple certificates and extracted variables
--- a/NEWS	Wed May 30 13:36:41 2012 +0200
+++ b/NEWS	Fri Jun 01 16:05:18 2012 -0400
@@ -14,6 +14,7 @@
   - PR811: javaws is not handling urls with spaces (and other characters needing encoding) correctly
 * Plugin
   - PR820: IcedTea-Web 1.1.3 crashing Firefox when loading Citrix XenApp
+  - PR863: Error passing strings to applet methods in Chromium
   - PR895: IcedTea-Web searches for missing classes on each loadClass or findClass
 * Common
   - PR918: java applet windows uses a low resulution black/white icon
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc	Wed May 30 13:36:41 2012 +0200
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc	Fri Jun 01 16:05:18 2012 -0400
@@ -905,9 +905,9 @@
     {
     	className = "java.lang.String";
 #if MOZILLA_VERSION_COLLAPSED < 1090200
-    	stringArg += NPVARIANT_TO_STRING(variant).utf8characters;
+    	stringArg.append(NPVARIANT_TO_STRING(variant).utf8characters, NPVARIANT_TO_STRING(variant).utf8length);
 #else
-    	stringArg += NPVARIANT_TO_STRING(variant).UTF8Characters;
+    	stringArg.append(NPVARIANT_TO_STRING(variant).UTF8Characters, NPVARIANT_TO_STRING(variant).UTF8Length);
 #endif
     } else if (NPVARIANT_IS_OBJECT(variant))
     {
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Wed May 30 13:36:41 2012 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Jun 01 16:05:18 2012 -0400
@@ -1094,11 +1094,16 @@
                                href_id, &href);
 
   // Strip everything after the last "/"
+  char *href_str;
 #if MOZILLA_VERSION_COLLAPSED < 1090200
-  gchar** parts = g_strsplit (NPVARIANT_TO_STRING(href).utf8characters, "/", -1);
+  href_str = (char*) malloc(sizeof(char)*NPVARIANT_TO_STRING(href).utf8length + 1);
+  snprintf(href_str, NPVARIANT_TO_STRING(href).utf8length+1, "%s", NPVARIANT_TO_STRING(href).utf8characters);
 #else
-  gchar** parts = g_strsplit (NPVARIANT_TO_STRING(href).UTF8Characters, "/", -1);
+  href_str = (char*) malloc(sizeof(char)*NPVARIANT_TO_STRING(href).UTF8Length + 1);
+  snprintf(href_str, NPVARIANT_TO_STRING(href).UTF8Length+1, "%s", NPVARIANT_TO_STRING(href).UTF8Characters);
 #endif
+
+  gchar** parts = g_strsplit (href_str, "/", -1);
   guint parts_sz = g_strv_length (parts);
 
   std::string location_str;
@@ -1113,6 +1118,9 @@
   // Release references.
   browser_functions.releasevariantvalue(&href);
   browser_functions.releasevariantvalue(&location);
+  g_strfreev(parts);
+  free(href_str);
+  href_str = NULL;
  cleanup_done:
   PLUGIN_DEBUG ("plugin_get_documentbase return\n");
   PLUGIN_DEBUG("plugin_get_documentbase returning: %s\n", documentbase_copy);
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Wed May 30 13:36:41 2012 +0200
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Fri Jun 01 16:05:18 2012 -0400
@@ -842,12 +842,12 @@
     script.utf8characters = script_str->c_str();
     script.utf8length = script_str->size();
 
-    PLUGIN_DEBUG("Evaluating: %s\n", script.utf8characters);
+    PLUGIN_DEBUG("Evaluating: %s\n", script_str->c_str());
 #else
     script.UTF8Characters = script_str->c_str();
     script.UTF8Length = script_str->size();
 
-    PLUGIN_DEBUG("Evaluating: %s\n", script.UTF8Characters);
+    PLUGIN_DEBUG("Evaluating: %s\n", script_str->c_str());
 #endif
 
     ((AsyncCallThreadData*) data)->call_successful = browser_functions.evaluate(instance, window_ptr, &script, eval_variant);
--- a/plugin/icedteanp/IcedTeaPluginUtils.cc	Wed May 30 13:36:41 2012 +0200
+++ b/plugin/icedteanp/IcedTeaPluginUtils.cc	Fri Jun 01 16:05:18 2012 -0400
@@ -662,9 +662,9 @@
     else if (NPVARIANT_IS_STRING(variant))
     {
 #if MOZILLA_VERSION_COLLAPSED < 1090200
-    	PLUGIN_DEBUG("STRING: %s\n", NPVARIANT_TO_STRING(variant).utf8characters);
+    	PLUGIN_DEBUG("STRING: %s (length=%d)\n", NPVARIANT_TO_STRING(variant).utf8characters, NPVARIANT_TO_STRING(variant).utf8length);
 #else
-    	PLUGIN_DEBUG("STRING: %s\n", NPVARIANT_TO_STRING(variant).UTF8Characters);
+    	PLUGIN_DEBUG("STRING: %s (length=%d)\n", NPVARIANT_TO_STRING(variant).UTF8Characters, NPVARIANT_TO_STRING(variant).UTF8Length);
 #endif
     }
     else
@@ -704,11 +704,11 @@
   else if (NPVARIANT_IS_STRING(variant))
   {
 #if MOZILLA_VERSION_COLLAPSED < 1090200
-    size_t buffersize = sizeof(char)*NPVARIANT_TO_STRING(variant).utf8length;
+    size_t buffersize = sizeof(char)*NPVARIANT_TO_STRING(variant).utf8length+1;
     largestr = (char*) malloc(buffersize);
     snprintf(str, buffersize, "%s", NPVARIANT_TO_STRING(variant).utf8characters);
 #else
-    size_t buffersize = sizeof(char)*NPVARIANT_TO_STRING(variant).UTF8Length;
+    size_t buffersize = sizeof(char)*NPVARIANT_TO_STRING(variant).UTF8Length+1;
     largestr = (char*) malloc(buffersize);
     snprintf(str, buffersize, "%s", NPVARIANT_TO_STRING(variant).UTF8Characters);
 #endif
@@ -864,9 +864,9 @@
     std::string constructor_name = std::string();
 
 #if MOZILLA_VERSION_COLLAPSED < 1090200
-    constructor_name.append(NPVARIANT_TO_STRING(constructor_str).utf8characters);
+    constructor_name.append(NPVARIANT_TO_STRING(constructor_str).utf8characters, NPVARIANT_TO_STRING(constructor_str).utf8length);
 #else
-    constructor_name.append(NPVARIANT_TO_STRING(constructor_str).UTF8Characters);
+    constructor_name.append(NPVARIANT_TO_STRING(constructor_str).UTF8Characters, NPVARIANT_TO_STRING(constructor_str).UTF8Length);
 #endif
 
     PLUGIN_DEBUG("Constructor for NPObject is %s\n", constructor_name.c_str());