character encoding in history - fatal error

Post Reply
jszpyrka
Posts: 13
Joined: 06 Dec 2012, 11:28

Hello,

I have simple object in my repository:

Code: Select all

<simple_instance>
	<name>ra_1_imported_data_p638_Class5</name>
	<type>Application_Capability</type>
	<own_slot_value>
		<slot_reference>name</slot_reference>
		<value value_type="string">&#324;&#324;&#324;&#324;</value>
	</own_slot_value>
</simple_instance>
If I display page with this capability and go to any other page I get the error: "net.sf.saxon.trans.XPathException: Illegal HTML character: decimal 132" in tomcat console

After some investigation the problem I can see is in file core_page_history.xsl in line

Code: Select all

<xsl:value-of select="$aLabel"></xsl:value-of>
so the parameter 'breadcrumbs' which is copied from xsl parameter 'pageHistory' is bad.

After changing the line to :

Code: Select all

<xsl:value-of select="string-to-codepoints($aLabel)"></xsl:value-of>
it does not raise java exception and in history I see "65 112 112 108 105 99 97 116 105 111 110 32 67 97 112 97 98 105 108 105 116 121 32 83 117 109 109 97 114 121 32 45 197 132 197 132 197 132 197 132"

As You can see four characters from name "&#324;&#324;&#324;&#324;" are represented by eight characters with decimal codes "197 132 197 132 197 132 197 132"

It seems that java code inproperly translates utf-8 codes into some one-byte encoding (in my windows default encoding is windows-1250 - maybe somewhere default encoding is used) and puts that value into transformation as pageHistory parameter.

Best Regards
Jacek Szpyrka
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Thanks for posting about this.
We have also just found and now resolved this in the forthcoming release of the Essential Viewer, which takes an improved approach for the page history - including proper support for UTF-8.

The fix updates both the Essential Viewer Engine and the page history rendering template.

We'll look to get a temporary release of this out via the Share area as soon as we can.

Jonathan
Essential Project Team
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

I forgot to mention that there is a work-around for this bug.

What you need to do is tell the Application Server (e.g. Tomcat) to accept UTF-8 in the HTTP GET messages. By default, HTTP GET requests are received encoded in ISO-8859-1, so even though the rest of the application is Unicode-enabled, the history label parameter which is sent in the request gets mangled.
We have re-worked this in the new version.

For now, you can resolve this by getting your application server to encode URIs in UTF-8. For example, in Tomcat:

- open the conf/server.xml file
- Find the connector definition for port 8080 or 80
- In the Connector tag, add the following attribute at the end - URIEncoding="UTF-8"

This should look something like:

Code: Select all

<Connector
               port="8080"  maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25"
               maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"
	       maxPostSize="0"
	       URIEncoding="UTF-8"/>
- Save server.xml
- Restart Tomcat

Jonathan
Essential Project Team
jszpyrka
Posts: 13
Joined: 06 Dec 2012, 11:28

It works :)
I made the same workaround for AJP connector and it works too.

pozdrawiam
Jacek Szpyrka
User avatar
jonathan.carter
Posts: 1087
Joined: 04 Feb 2009, 15:44

Thanks for posting back.
Great to hear.

We've got that fixed properly in the next release of Essential Viewer
:)
Essential Project Team
Post Reply