Created attachment 698818 [details] hello-world ui plugin with utf8 chars Description of problem: I see question marks (?) instead of real characters. /etc/ovirt-engine/ui-plugins/hello-world-config.json has: { "config": { "oVirtLink": "http://www.example.com/", "MainTabString": "печатарската и типографската", "HostSubTabString": "ტიპოგრაფიული ინდუსტრიის", "VMActionString": "מבוססת שדעתו" } } Source of the web page shows: <!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><script type="text/javascript">var applicationMode = { value: "255" };var pluginDefinitions = [ { name: "HelloWorld", url: "/webadmin/webadmin/plugin/HelloWorld/start.html", config: {"oVirtLink":"http://www.example.com/","MainTabString":"???????????? ? ?????????????","HostSubTabString":"???????????? ??????????","VMActionString":"?????? ?????"}, enabled: true } ];</script></head><body><iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe><script type="text/javascript" src="webadmin.nocache.js?nocache=1361183247765"></script></body></html> Version-Release number of selected component (if applicable): sf7 How reproducible: 100% Steps to Reproduce: 1. "Install" my test ui plugin from attachment 2. Load Administration Portal 3. Check Ctrl-u for source/log in Administration portal Actual results: bogus characters Expected results: valid characters/utf8 working Additional info: nothing in engine.log
It seems the problem relates to parsing UI plugin JSON files (descriptor/configuration), whose data is embedded into WebAdmin HTML page. Jiri, can you also test displaying unicode characters within plugin host page (e.g. start.html), e.g. api.addMainTab(label-with-unicode-chars,'test','') ?
You meant something like this? # grep config\. hello-files/start.html var config = api.configObject(); api.addMainTab(config.ტიპოგრაფიული, 'ovirt-tab', config.oVirtLink); api.addSubTab('Host', config.HostSubTabString, 'my-host-subtab', ''); api.addMainTabActionButton('VirtualMachine', config.VMActionString, { var url = config.oVirtLink + '?search=' + encodeURIComponent(name); # cat /etc/ovirt-engine/ui-plugins/hello-world-config.json { "config": { "ტიპოგრაფიული": "i18n Tab" } } The tab has no title, nothing special in logs about parsing.... The source for tab is here... <div class="GE2Q1TJNYC GE2Q1TJAYC"> <a class="GE2Q1TJCYC" href="#ovirt-tab"> <div class="GE2Q1TJJYC GE2Q1TJFYC"></div> <div class="GE2Q1TJMYC GE2Q1TJIYC"></div> <div class="GE2Q1TJKYC GE2Q1TJGYC"> <div class="gwt-Label GE2Q1TJLYC GE2Q1TJHYC"></div> </div> <div class="GE2Q1TJDYC GE2Q1TJEYC"></div> <div style="clear: both;"></div> </a> </div>
Actually, I meant something like this: # grep hello-files/start.html api.addMainTab('ტიპოგრაფიული', 'ovirt-tab', config.oVirtLink); Can you please test the above?
Jiri - can you please take a look at Comment #4? thanks.
Ad comment #4: # grep api.addMainTab\( /usr/share/ovirt-engine/ui-plugins/hello-files/start.html api.addMainTab('ტიპოგრაფიული', 'ovirt-tab', config.oVirtLink); This works ok, i can see - ტიპოგრაფიული - as title of the tab in Admin portal.
Thanks Jiri, so the only problem seems to be parsing UI plugin JSON files (descriptor/configuration), whose data is embedded into WebAdmin HTML page (as mentioned in comment #2). Steps to reproduce/verify: 1. use unicode characters in either descriptor [hello-world.json] or configuration [hello-world-config.json] file 2. open WebAdmin in your favorite browser 3. see WebAdmin HTML source, look for [pluginDefinitions] JS array embedded within HTML source - it should contain correct unicode characters 4. log into WebAdmin, see unicode characters in action - should be displayed correctly (e.g. main tab title)
Created attachment 735988 [details] Sample UI plugin with unicode characters
Uploaded my own sample UI plugin to verify this issue. Couldn't reproduce the issue using neither of the two patches, i.e. unicode characters are always displayed correctly in the browser. As per JSON specification, only valid encodings are UTF-8, UTF-16 and UTF-32. No other encodings can be used. Because of this, encoding auto-detection is done automatically by the JSON parser [1]. [1] http://stackoverflow.com/questions/10004241/jackson-objectmapper-with-utf-8-encoding/10016086#10016086 Jiri, isn't this issue caused by declaring something like "<meta http-equiv="Content-Type" content="text/html;charset=xxx" />" explictly in plugin HTML page? If so, it's a plugin issue, not UI Plugin infrastructure issue.
Example ui plugin Looks good (got 3 popup with unicode string and 3 main tabs titled with unicode string).
Jiri, is there any conclusion for this issue? Did you have a chance to verify the original "hello-world ui plugin with utf8 chars" recently? One potential cause for this issue is saving JSON files using non-UTF-{8|16|32} encoding (i.e. invalid encoding according to JSON specification). In this case, JSON parser should reject parsing the file, which should be reflected in Engine logs with something like "Cannot read/parse JSON file ... invalid encoding". Can you please verify this? [Except for manual "Content-Type" meta-tag override, and invalid JSON file encoding, I couldn't reproduce the issue with any of the attached sample plugins.]
Cannot reproduce with sf13.1, it's possible the issue was files encoding, not sure, anyway my example ui plugin works OK now. Thus closing the BZ.