I created a simple scriptable npapi plugin. It works fine to pass string between JavaScript and plugin on FireFox. But it will generate some extra random characters on Google chrome if the string contains hyphen (-) symbol. For example, in my JavaScript code, I have
plugin.method("a-b");
on my npapi code, I have
bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) {
char* outString = args[0].value.stringValue.UTF8Characters;
char* npOutString = (char *)NPN_MemAlloc(strlen(outString) + 1);
strcpy(npOutString, outString);
STRINGZ_TO_NPVARIANT(npOutString, *result);
return true;
}
On Firefox, it returns "a-b", on Chrome, I will see "a-b*[-.." with some extra random symbols. I tried with placing npplugin.dll in "plugins" directory under Mozilla or using Chrome extension tutorial(http://code.google.com/chrome/extensions/npapi.html), both way gave me the same strange behavior. The code is compiled with xulrunner-10.0.2.en-US.win32.sdk, using xulrunner-1.9.0.17.en-US.win32.sdk also has the same problem.
Does anyone have any clues?