URI Encoding"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

Line 1: Line 1:
 
By default some servers use the ISO-8859-1 encoding for request parameters and request body. What is more, changing the encoding for request body on such servers has no influence on the encoding of the request parameters. This may cause problems if you want to use international file names with '''CKFinder which expects request body and parameters to be encoded in UTF-8'''.  To overcome this issue you can either set UTF-8 URI encoding on the server or if you do not have enough privileges to do that, you can adjust CKFinder to use same URI encoding as your server. <br />
 
By default some servers use the ISO-8859-1 encoding for request parameters and request body. What is more, changing the encoding for request body on such servers has no influence on the encoding of the request parameters. This may cause problems if you want to use international file names with '''CKFinder which expects request body and parameters to be encoded in UTF-8'''.  To overcome this issue you can either set UTF-8 URI encoding on the server or if you do not have enough privileges to do that, you can adjust CKFinder to use same URI encoding as your server. <br />
 
You will find more detailed instructions below.
 
You will find more detailed instructions below.
 
===JBOSS 6===
 
JBOSS 6 is one of the servers that use ISO-8859-1 for parameter encoding. In order to change this value to UTF-8 you have to modify the <code>server.xml</code> file for the configuration you use. <br />
 
As you probably know, JBOSS 6 comes with five different server configurations. To simplify the example let us assume that configuration '''<code>"all"</code>''' is used and you want to set UTF-8 only for that particular configuration. To achieve that you have to edit the <code><nowiki>JBOSS_HOME/server/all/deploy/jbossweb.sar/server.xml</nowiki></code> file and add the <code>URIEncoding="UTF-8"</code> attribute in the <code>Connector</code> element.
 
 
<source lang="xml">
 
<Connector URIEncoding="UTF-8" protocol="HTTP/1.1" port="${jboss.web.http.port}"
 
address="${jboss.bind.address}" redirectPort="${jboss.web.https.port}" />
 
</source>
 
  
 
===JBOSS 7===
 
===JBOSS 7===
Line 65: Line 56:
  
 
===Jetty===  
 
===Jetty===  
All supported Jetty versions (7,8 and 9) use UTF-8 by default. Jetty [http://wiki.eclipse.org/Jetty/Howto/International_Characters#Characters_included_in_HTTP_requests documentation] states if no overriding character encoding is set on a request, Jetty uses UTF-8 encoding.
+
The Jetty server uses UTF-8 by default. Jetty [http://wiki.eclipse.org/Jetty/Howto/International_Characters#Characters_included_in_HTTP_requests documentation] states if no overriding character encoding is set on a request, Jetty uses UTF-8 encoding.
  
 
===Alternative Solution (CKFinder Adjustment)===
 
===Alternative Solution (CKFinder Adjustment)===

Revision as of 17:43, 2 November 2015

By default some servers use the ISO-8859-1 encoding for request parameters and request body. What is more, changing the encoding for request body on such servers has no influence on the encoding of the request parameters. This may cause problems if you want to use international file names with CKFinder which expects request body and parameters to be encoded in UTF-8. To overcome this issue you can either set UTF-8 URI encoding on the server or if you do not have enough privileges to do that, you can adjust CKFinder to use same URI encoding as your server.
You will find more detailed instructions below.

JBOSS 7

By default this server uses ISO-8859-1 for parameter encoding. To change this to UTF-8, you have to modify the configuration file appropriate for the mode and configuration used.
As you probably know, JBOSS 7 can run in two modes ("domain" and "standalone") and can use various configurations. To simplify the example let us assume that the server uses the standalone mode and default configuration. In order to set UTF-8 for URI encoding you have to edit the JBOSS_HOME/standalone/configuration/standalone.xml file and add a system property named org.apache.catalina.connector.URI_ENCODING,(with value set to UTF-8) to the system-properties element.
Below is the code that needs to be added to the configuration file you use:

<system-properties>
    <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
</system-properties>

GlassFish 3.0

According to Glassfish 3.0 documentation default parameter encoding for requests is ISO-8859-1. To change this encoding to UTF-8 you have to use the sun-web.xml file with xml parameter-encoding element. This file has to be placed in the WEB-INF folder of your web application.
CKFinder sample web application comes with such a file. If you are using Glassfish 3.0, want to use UTF-8, and to integrate CKFinder in to your application then apart from files mentioned in the Integration section, copy sun-web.xml as well.
Below is the code for the sun-web.xml file:

<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"
 "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app>
	<parameter-encoding default-charset="UTF-8" />
</sun-web-app>

GlassFish 3.1+

By default this server uses ISO-8859-1 for parameter encoding. In order to change this to UTF-8, you have to use the glassfish-web.xml file with xml parameter-encoding element. This file has to be placed in the WEB-INF folder of the web application.
CKFinder sample web application comes with such a file. If you are using Glassfish 3.1 or 4.0, want to use UTF-8, and to integrate CKFinder in to your application then apart from files mentioned in the Integration section, copy glassfish-web.xml as well.
Below is the code for the glassfish-web.xml file:

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" 
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <parameter-encoding default-charset="UTF-8" />
</glassfish-web-app>

Tomcat

According to Tomcat FAQ, for handling HTTP requests by default Tomcat uses the ISO-8859-1 encoding.

Starting with version 5 for all GET requests, when the encoding type used is different from the default one, the query parameters are not encoded in the same way as the request body. To be more specific, if you want to use the encoding other than the default ISO-8859-1 (like UTF-8, for example), the HttpServletRequest.setCharacterEncoding("UTF-8") method will only be applied to the request body, and not the URI.

In order to encode the query parameters just like the requests, you should use the URIEncoding="UTF-8" attribute in the Connector element of the Server.xml file:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"  redirectPort="8443" URIEncoding="UTF-8" />

Weblogic

This server follows J2EE specification when it comes to encoding. This means that if no encoding is specified then default ISO-8859-1 is set for everything (Servlets, JSP, Tag Files) except for XML format files.
Weblogic documentation provides a couple of ways for setting the encoding you want (UTF-8 in this case). There are server typical methods as well as general Servlet API methods. It seems the best way to set encoding in the WLS server is using setCharacterEncoding("UTF-8"); for requests and setCharacterEncoding("UTF-8"); or setContentType("UTF-8"); for responses.

Please see this link (Web Components section) for more details on setting appropriate encoding on the server-side.

Jetty

The Jetty server uses UTF-8 by default. Jetty documentation states if no overriding character encoding is set on a request, Jetty uses UTF-8 encoding.

Alternative Solution (CKFinder Adjustment)

By default, CKFinder uses the UTF-8 encoding, so you should stick to the guidelines presented above in order to make it work properly.

If you cannot or do not want to set this parameter in the server configuration file, CKFinder will try to address this problem for you. This is why the uriEncoding configuration element was created in the config.xml<code> file. This parameter accepts the encoding of your query parameters.
For example, for Tomcat, JBoss, Glassfish, and Weblogic with their default configuration set (which is ISO-8859-1) you should set uriEncoding to ISO-8859-1 and CKFinder will convert the query parameters for you.

<uriEncoding>ISO-8859-1</uriEncoding>