[Geoserver-devel] [jira] Created: (GEOS-3326) Character encoding problem in WFS requests

Character encoding problem in WFS requests
------------------------------------------

                 Key: GEOS-3326
                 URL: http://jira.codehaus.org/browse/GEOS-3326
             Project: GeoServer
          Issue Type: Bug
          Components: WFS
    Affects Versions: 1.7.3
         Environment: Windows XP Professional SP 3, locale: Poland; Java 1.6.0_13; default GEOS 1.7.3 installation (Jetty)
            Reporter: Ralf Wagner
            Assignee: Andrea Aime
            Priority: Minor

WFS query (GetFeature, Update) containing national characters does not work properly.

Steps to reproduce on demo GEOS data (States shapefile):

1. To enable national characters in Shapefile we should add states.cpg and set charset in 'GeoServer Feature Data Set Configuration' for 'Feature Data Set ID' "states_shapefile". In our case it is "Windows-1250".

2. Let's perform simple query through GeoServer Demo Request web page:

<?xml version="1.0" ?>
<wfs:GetFeature
service="WFS"
version="1.1.0"
outputFormat="text/xml; subtype=gml/3.1.1"
xmlns:myns="http://www.someserver.com/myns&quot;
xmlns:wfs="http://www.opengis.net/wfs&quot;
xmlns:ogc="http://www.opengis.net/ogc&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd">
<wfs:Query typeName="topp:states">
  <wfs:PropertyName>STATE_NAME</wfs:PropertyName>
  <ogc:Filter>
    <ogc:GmlObjectId id="states.2"/>
  </ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

3. Such query returns something like that:

<wfs:FeatureCollection numberOfFeatures="1" timeStamp="2009-08-06T10:16:05.760+02:00" xsi:schemaLocation="http://www.openplans.org/topp http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=topp:states http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd&quot;&gt;
  <gml:featureMembers>
    <topp:states gml:id="states.2">
      <topp:STATE_NAME>District of Columbia</topp:STATE_NAME>
    </topp:states>
  </gml:featureMembers>
</wfs:FeatureCollection>

4. Now we can update "STATE_NAME":

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;&gt;
  <wfs:Update typeName="topp:states">
    <wfs:Property>
      <wfs:Name>STATE_NAME</wfs:Name>
      <wfs:Value>XYZ</wfs:Value>
    </wfs:Property>
    <ogc:Filter>
      <ogc:GmlObjectId id="states.2"/>
    </ogc:Filter>
  </wfs:Update>
</wfs:Transaction>

5. We can issue request from step 2 again - as we can expect "STATE_NAME" is set to "XYZ". Till now everything works fine.

6. Now we are updating "STATE_NAME" with national characters value:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;&gt;
  <wfs:Update typeName="topp:states">
    <wfs:Property>
      <wfs:Name>STATE_NAME</wfs:Name>
      <wfs:Value>&#379;ó&#322;win</wfs:Value>
    </wfs:Property>
    <ogc:Filter>
      <ogc:GmlObjectId id="states.2"/>
    </ogc:Filter>
  </wfs:Update>
</wfs:Transaction>

Value of "STATE_NAME" should be now "&#379;ó&#322;win" (three leading characters are polish characters).

7. We can issue request from step 2 again - in our case value of "STATE_NAME" is set to "??win". This is BUG we are struggling with!

8. Note: if we are updating "STATE_NAME" with national characters value but encoded using numeric character references:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;&gt;
  <wfs:Update typeName="topp:states">
    <wfs:Property>
      <wfs:Name>STATE_NAME</wfs:Name>
      <wfs:Value>&#379;&#243;&#322;win</wfs:Value>
    </wfs:Property>
    <ogc:Filter>
      <ogc:GmlObjectId id="states.2"/>
    </ogc:Filter>
  </wfs:Update>
</wfs:Transaction>

"STATE_NAME" is properly set to "&#379;ó&#322;win".

9. BTW: we observed above effect using uDig - we prepared above procedure to simplify testing.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira