The WFS KVP Filter parser fails to set an encoding for its SAX InputSource. On non UTF-8 platforms (not using -Dfile.encoding=UTF-8), this results in a mismatch between the platform encoding and an assumed UTF-8 encoding and consequently a MalformedByteSequenceException when a Filter contains a non-ASCII character, even when that character is correctly percent-encoded as UTF-8 octets in the request.
The reported exception can be reproduced on a UTF-8 platform by starting GeoServer with -Dfile.encoding=ISO-8859-15 and visiting this link:
http://localhost:8080/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&typenames=topp:states&filter=%3Cfes:Filter%20xmlns:fes=%22http://www.opengis.net/fes/2.0%22%3E%3Cfes:PropertyIsLike%20wildCard=%22*%22%20singleChar=%22%25%22%20escapeChar=%22!%22%3E%3Cfes:ValueReference%3Etopp:STATE_NAME%3C/fes:ValueReference%3E%3Cfes:Literal%3E%C3%BC*%3C/fes:Literal%3E%3C/fes:PropertyIsLike%3E%3C/fes:Filter%3E
%C3%BC is a percent-encoded “ü”.
Workaround is to start GeoServer with: -Dfile.encoding=UTF-8
-------- Forwarded Message --------
Subject: Re: [Geoserver-users] Exception with Filter 2.0 and matchCase=“false” on PropertyIsLike
Date: Fri, 22 Jan 2016 10:04:12 +0100
From: Nhan Vo
To: Ben Caradoc-Davies
CC: geoserver-users@anonymised.comsourceforge.net
Hi Ben,
Thanks again for the response. Under my Geoserver’s
Settings/Global/Character Set the value is UTF-8 but I still I had the
parsing problem with “Ü”. Then I restart my server adding
-Dfile.encoding=UTF-8 to Java options the problem goes away. Perhaps
somewhere in the code the Parser was constructed without explicitly
specifying an encoding. I post the stack trace here just in case it
could help locate the culprit.
Unable to parse filter: <fes:Filter
xmlns:fes=“http://www.opengis.net/fes/2.0”><fes:PropertyIsLike
wildCard="" singleChar=“#”
escapeChar=“!”><fes:ValueReference>topp:STATE_NAME</fes:ValueReference><fes:Literal>�?</fes:Literal></fes:PropertyIsLike></fes:Filter>
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:
Ung�ltiges Byte 2 von 2-Byte-UTF-8-Sequenz.
at
com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)
[…]
org.geoserver.wfs.kvp.FilterKvpParser.parse(FilterKvpParser.java:84)
[…]
|