[Geoserver-users] Geoserver - problem with CQL filter, when value contains single quote and there are no results

Hello,

I have a problem with filtering a layer, when filter value contains a single quote (which I replace with two single quotes – according to a specification: https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html#ecql-literal).

Values are filtered correctly when there are some results. If the result should be empty layer – I get following exception in the response:

<?xml version="1.0" encoding="UTF-8"?>

Could not parse CQL filter list.

Encountered "ongnam" at line 1, column 115.

Was expecting one of:

"and" …

"or" …

")" …

"/" …

"*" …

"+" …

"-" …

Parsing : (1 = 1) AND (1 = 1 AND (region = 'JAPAC') AND (country = 'South Korea') AND (state = 'Chungcheongnamdo [Ch''ungch'ongnam-do]')).

And here is a request that I send:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20'JAPAC')%20AND%20(country%20%3D%20'South%20Korea')%20AND%20(state%20%3D%20'Chungcheongnamdo%20[Ch''ungch'ongnam-do]'))&TIME_=1583319334693&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C5009377.085697312%2C15028131.257091932%2C10018754.171394624

If there is at least one result (on the whole layer), I get a correct image as a response. Here is a sample request that works fine:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20'JAPAC')%20AND%20(country%20%3D%20'South%20Korea')%20AND%20(state%20%3D%20'Daegu%20Gwang''yeogsi%20[Taegu-Kwangyokshi]'))&TIME_=1583320599330&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C0%2C15028131.257091932%2C5009377.085697311

Any ideas, how could I configure my filter, so it works in all cases?

Best Regards

Martyna Kolaczek

Hi,
if I URL-decode the first filter, it looks like this:

(1 = 1) AND (1 = 1 AND (region = ‘JAPAC’) AND (country = ‘South Korea’) AND (state = ‘Chungcheongnamdo [Ch’'ungch’ongnam-do]’))

Only one of the single quotes has been doubled. If also the second is repeated, as expected, then there is no error:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20%27JAPAC%27)%20AND%20(country%20%3D%20%27South%20Korea%27)%20AND%20(state%20%3D%20%27Chungcheongnamdo%20%5BCh%27%27ungch%27%27ongnam-do%5D%27))&TIME_=1583319334693&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C5009377.085697312%2C15028131.257091932%2C10018754.171394624

Hope this helps

Cheers
Andrea

···

Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Hi,

You are right. With all the quotes doubled it works fine.

Thank you for a prompt response!

Best Regards

Martyna

···

Hi,

if I URL-decode the first filter, it looks like this:

(1 = 1) AND (1 = 1 AND (region = ‘JAPAC’) AND (country = ‘South Korea’) AND (state = ‘Chungcheongnamdo [Ch’'ungch’ongnam-do]’))

Only one of the single quotes has been doubled. If also the second is repeated, as expected, then there is no error:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20%27JAPAC%27)%20AND%20(country%20%3D%20%27South%20Korea%27)%20AND%20(state%20%3D%20%27Chungcheongnamdo%20%5BCh%27%27ungch%27%27ongnam-do%5D%27))&TIME_=1583319334693&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C5009377.085697312%2C15028131.257091932%2C10018754.171394624

Hope this helps

Cheers

Andrea

On Wed, Mar 4, 2020 at 12:46 PM Kolaczek, Martyna Julia <martyna.kolaczek@…10329…> wrote:

Hello,

I have a problem with filtering a layer, when filter value contains a single quote (which I replace with two single quotes – according to a specification: https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html#ecql-literal).

Values are filtered correctly when there are some results. If the result should be empty layer – I get following exception in the response:

<?xml version="1.0" encoding="UTF-8"?>

Could not parse CQL filter list.

Encountered "ongnam" at line 1, column 115.

Was expecting one of:

"and" …

"or" …

")" …

"/" …

"*" …

"+" …

"-" …

Parsing : (1 = 1) AND (1 = 1 AND (region = 'JAPAC') AND (country = 'South Korea') AND (state = 'Chungcheongnamdo [Ch''ungch'ongnam-do]')).

And here is a request that I send:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20%27JAPAC%27)%20AND%20(country%20%3D%20%27South%20Korea%27)%20AND%20(state%20%3D%20%27Chungcheongnamdo%20%5BCh%27%27ungch%27ongnam-do%5D%27))&TIME_=1583319334693&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C5009377.085697312%2C15028131.257091932%2C10018754.171394624

If there is at least one result (on the whole layer), I get a correct image as a response. Here is a sample request that works fine:

https://abbvie-ows.omnilocation-iot.com/geoserver/abbvie/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=asset_site&TILED=true&CQL_FILTER=(1%20%3D%201)%20AND%20(1%20%3D%201%20AND%20(region%20%3D%20%27JAPAC%27)%20AND%20(country%20%3D%20%27South%20Korea%27)%20AND%20(state%20%3D%20%27Daegu%20Gwang%27%27yeogsi%20%5BTaegu-Kwangyokshi%5D%27))&TIME_=1583320599330&viewparams=&WIDTH=512&HEIGHT=512&CRS=EPSG%3A3857&STYLES=&BBOX=10018754.17139462%2C0%2C15028131.257091932%2C5009377.085697311

Any ideas, how could I configure my filter, so it works in all cases?

Best Regards

Martyna Kolaczek

DXC Technology Company – This message is transmitted to you by or on behalf of DXC Technology Company or one of its affiliates. It is intended exclusively for the addressee. The substance of this message, along with any attachments, may contain proprietary, confidential or privileged information or information that is otherwise legally exempt from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate any part of this message. If you have received this message in error, please destroy and delete all copies and notify the sender by return e-mail. Regardless of content, this e-mail shall not operate to bind DXC Technology Company or any of its affiliates to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. --.


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.