Unicode in scriptable plugin IDL still get called with ansi strings




10 years ago
6 years ago


(Reporter: danikenan, Unassigned)


Firefox Tracking Flags

(Not tracked)




10 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022; InfoPath.2)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20080623 Firefox/

I use IDL and nsClassInfo on a scriptable object to get calls from JS. I have created a similar ansi plugin in the past and it works ok. I now need to support unicode in another, new plugin.
It seems to work fine except that I get ANSI characters comming in when called from JS code no matter what is declared in the IDL. I tried defining severarl string types (string, wstring, AString, DOMString) and checked what I get. The interface code generated from the IDL exposes the extpected string variable types (const char *, const PRUnichar* and nsAString& respectively) so the method signiture are correct.
However, the actual DATA that comes in from the browser is wrong: e.g. when looking at the PRUnichar* in the debugger, it looks garbage. If I cast to char * it is OK and I see the value correctly. 

Somewhere along the way, the browser or some intermediate layer, igonre the string type in the idl and passes in a const char*. This is then being casted into a wide char type by some other layer, but casting is not enough. It is still const char* and any function that treat it as a wide char type, simply gets a memomry General Protection Fault.

I will now describe the plugin structure:

I am using an IDL and a scriptable peer inheriting from nsClassInfoMixin like in the scriptable example. 

When asked for the NPPVpluginScriptableInstance and NPPVpluginScriptableIID in getvalue I provide the values of the scriptable and the iid of what is declared in the IDL.

Reproducible: Always

Steps to Reproduce:
1. create a scriptable plugin
2. declare a method that gets a wstring in the idl.
3. debug the plugin and see that the PRUnichar* you get is garbage and when cast to char * to see the actuatl value.


6 years ago
Last Resolved: 6 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.