In ContextFilter, the character encoding (aka charset) of every http
*request* object is set using the WebAppUtil.setCharacterEncoding(...)
method (see its logic here [*]).
It is wrong to override the character encoding if already specified by the
http request: in fact it doesn't make any sense to try to decode an http
request, whose body content is encoded for example with ISO-8859-1, using
the OFBiz system's default of UTF-8.
I propose instead to set the character encoding to the system default (e.g.
UTF-8) if and only if it is not set already by the client.
Any comments before I commit this change?
Kind regards,
Jacopo
[*] the logic of WebAppUtil.setCharacterEncoding(...):
public static void setCharacterEncoding(ServletRequest request) {
String charset = request.getServletContext().getInitParameter("charset");
if (UtilValidate.isEmpty(charset)) charset = request.getCharacterEncoding();
if (UtilValidate.isEmpty(charset)) charset = "UTF-8";
if (!"none".equals(charset)) {
request.setCharacterEncoding(charset);
}
}