From b0179a3d15f966608c6fff5e1088224046759c8e Mon Sep 17 00:00:00 2001 From: Deepak Bhole Date: Fri, 1 Jun 2012 16:05:18 -0400 Subject: Fixed PR863: Error passing strings to applet methods in Chromium --- ChangeLog | 13 +++++++++++++ NEWS | 1 + plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | 4 ++-- plugin/icedteanp/IcedTeaNPPlugin.cc | 12 ++++++++++-- plugin/icedteanp/IcedTeaPluginRequestProcessor.cc | 4 ++-- plugin/icedteanp/IcedTeaPluginUtils.cc | 12 ++++++------ 6 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7187a82..6e22822 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2012-06-01 Deepak Bhole + + 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 Enabled multiple certificates and extracted variables diff --git a/NEWS b/NEWS index 11c6d48..e039502 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ New in release 1.3 (2012-XX-XX): - 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 diff --git a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc index 675934c..1431bcc 100644 --- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc +++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc @@ -905,9 +905,9 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id) { 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)) { diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc index ea15ba3..52c1793 100644 --- a/plugin/icedteanp/IcedTeaNPPlugin.cc +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc @@ -1094,11 +1094,16 @@ plugin_get_documentbase (NPP instance) 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 @@ plugin_get_documentbase (NPP instance) // 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); diff --git a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc index df8128d..6505333 100644 --- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc +++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc @@ -842,12 +842,12 @@ _eval(void* data) 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); diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc index 3210b1d..2cbfd6e 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.cc +++ b/plugin/icedteanp/IcedTeaPluginUtils.cc @@ -662,9 +662,9 @@ IcedTeaPluginUtilities::printNPVariant(NPVariant variant) 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 @@ IcedTeaPluginUtilities::NPVariantToString(NPVariant variant, std::string* result 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 @@ IcedTeaPluginUtilities::isObjectJSArray(NPP instance, NPObject* object) 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()); -- cgit v1.2.3