Bug 912298 - [Admin Portal] UI plugin does not display unicode characters correctly
Summary: [Admin Portal] UI plugin does not display unicode characters correctly
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-webadmin-portal
Version: 3.2.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.2.0
Assignee: Vojtech Szocs
QA Contact: Jiri Belka
URL:
Whiteboard: ux
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-02-18 10:33 UTC by Jiri Belka
Modified: 2015-09-22 13:09 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-04-24 08:11:18 UTC
oVirt Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
hello-world ui plugin with utf8 chars (1.06 KB, application/x-tar)
2013-02-18 10:33 UTC, Jiri Belka
no flags Details
Sample UI plugin with unicode characters (792 bytes, application/x-tar)
2013-04-15 17:11 UTC, Vojtech Szocs
no flags Details

Description Jiri Belka 2013-02-18 10:33:40 UTC
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

Comment 2 Vojtech Szocs 2013-03-04 11:43:26 UTC
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','') ?

Comment 3 Jiri Belka 2013-03-05 14:54:34 UTC
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>

Comment 4 Vojtech Szocs 2013-03-07 16:37:18 UTC
Actually, I meant something like this:

# grep hello-files/start.html

api.addMainTab('ტიპოგრაფიული', 'ovirt-tab', config.oVirtLink);

Can you please test the above?

Comment 5 Einav Cohen 2013-04-10 14:06:38 UTC
Jiri - can you please take a look at Comment #4? thanks.

Comment 6 Jiri Belka 2013-04-11 07:54:24 UTC
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.

Comment 7 Vojtech Szocs 2013-04-11 10:40:16 UTC
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)

Comment 8 Vojtech Szocs 2013-04-15 17:11:06 UTC
Created attachment 735988 [details]
Sample UI plugin with unicode characters

Comment 9 Vojtech Szocs 2013-04-15 17:19:02 UTC
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.

Comment 10 Jiri Belka 2013-04-16 10:33:30 UTC
Example ui plugin Looks good (got 3 popup with unicode string and 3 main tabs titled with unicode string).

Comment 11 Vojtech Szocs 2013-04-23 16:44:01 UTC
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.]

Comment 12 Jiri Belka 2013-04-24 08:11:18 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.