gvSIG bugs #984

WFS: Bad encoding for requests with Filter set

Added by Francisco José Peñarrubia almost 12 years ago. Updated over 10 years ago.

Status:Fixed% Done:

100%

Priority:Normal
Assignee:Francisco José Peñarrubia
Category:-
Target version:-
Severity: Add-on name:Unknown
gvSIG version:1.12.0 Add-on version:
gvSIG build: Add-on build:
Operative System: Add-on resolve version:
Keywords:wfs, filter, encoding Add-on resolve build:
Has patch:Yes

Description

There is a problem if WFS attribute filter contains special characters like åäöÅÄÖ
This is how my attribute filter looks in the Query area of the WFS Filter tab

"kunta_ni1" = 'Saarijärvi'

This is the request that gvSIG is sending

http://188.64.1.61/cgi-bin/mapserver_wfs?REQUEST=GetFeature&SERVICE=WFS&TYPENAME=municipalities&FILTER=<Filter%20xmlns:ogc="http://www.opengis.net/ogc"%20xmlns:gml="http://www.opengis.net/gml"%20xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"%20xsi:schemaLocation="http://www.opengis.net/ogc%20../filter/1.0.0/filter.xsd%20http://www.opengis.net/gml%20../gml/2.1.2/geometry.xsd"><PropertyIsEqualTo><PropertyName>kunta_ni1</PropertyName><Literal>Saarij%E4rvi</Literal></PropertyIsEqualTo></Filter>&VERSION=1.1.0&EXCEPTIONS=XML&MAXFEATURES=10000

There is wrong URL-encoding in <Literal>Saarij%E4rvi</Literal>
Letter "ä" as correctly URL-encoded is %C3%A4
If I edit the GetFeature request above accordingly to contain <Literal>Saarij%C3%E4rvi</Literal>it works

http://188.64.1.61/cgi-bin/mapserver_wfs?REQUEST=GetFeature&SERVICE=WFS&TYPENAME=municipalities&FILTER=&lt;Filter%20xmlns:ogc="http://www.opengis.net/ogc"%20xmlns:gml="http://www.opengis.net/gml"%20xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"%20xsi:schemaLocation="http://www.opengis.net/ogc%20../filter/1.0.0/filter.xsd%20http://www.opengis.net/gml%20../gml/2.1.2/geometry.xsd"&gt;&lt;PropertyIsEqualTo&gt;&lt;PropertyName&gt;kunta_ni1&lt;/PropertyName&gt;&lt;Literal&gt;Saarij%C3%A4rvi&lt;/Literal&gt;&lt;/PropertyIsEqualTo&gt;&lt;/Filter&gt;&VERSION=1.1.0&EXCEPTIONS=XML&MAXFEATURES=10000

gvSIG seems to do the URL-encoding wrong for other characters do. If I place this string into the filter

test_åäöÅÄÖ_test
it comes out as
<Literal>test_%E5%E4%F6%C5%C4%D6_test</Literal>
but it should come like
<Literal>test_%C3%A5%C3%A4%C3%B6%C3%85%C3%84%C3%96_test</Literal>

I am using gvSIG 1.12 RC2 on Windows XP. Java version is 1.7.0_02 and I did installation from
http://downloads.gvsig.org/download/gvsig-desktop/dists/1.12.0/builds/1414/gvSIG-desktop-1.12.0-1414-RC2-win-x86-standard.exe

Locale is Finland-Finnish.

Regards,

Jukka Rahkonen

History

#1 Updated by Francisco José Peñarrubia almost 12 years ago

It seems the correct encoding for http requests is UTF-8, not Latin1.
This patch will correct the problem (the only change is substitute 8859-1 for UTF-8:

Index: src/com/iver/cit/gvsig/gui/panels/WFSFilterPanel.java ===================================================================
--- src/com/iver/cit/gvsig/gui/panels/WFSFilterPanel.java (revision 37921)
+++ src/com/iver/cit/gvsig/gui/panels/WFSFilterPanel.java (working copy)
@ -743,7 +743,10 @
text = text.substring(1, text.length() -1);

// Convert the string to ISO 8859_1 codification
- text = URLEncoder.encode(text, "8859_1");
// text = URLEncoder.encode(text, "8859_1");
// Convert the string to UTF codification (requests are expected to go in this encoding.
+ // See: http://listserv.gva.es/pipermail/gvsig_internacional/2012-August/008559.html
+ text = URLEncoder.encode(text, "UTF-8");
// Change ' (%27 code) to '' for the SQL parser (before send the query)
text = text.replaceAll("\\%27", "\\'\\'");

I think this change will not break nothing and it's safe to put it in SVN. I do and fix it.

#2 Updated by Francisco José Peñarrubia almost 12 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

Applied in changeset r38762.

#3 Updated by Francisco Puga almost 12 years ago

The change seems good to me. I pass the persistence test related to WFS and all works.

#4 Updated by Álvaro Anguix over 10 years ago

  • Project changed from Application: gvSIG desktop to | gvSIG desktop 1
  • Category deleted (WFS)
  • Target version deleted (1.12.0-final)

Also available in: Atom PDF