New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLD - Missing escaped characters when converting OGC propertyIsLike to Regex #5658

Closed
pmauduit opened this Issue Sep 5, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@pmauduit
Contributor

pmauduit commented Sep 5, 2018

Using the following getmap request:

/usr/lib/cgi-bin/mapserv QUERY_STRING='MAP=/root/resources/version-shapefile/mapfile.map&
SERVICE=WMS&
VERSION=1.3.0&
REQUEST=GetMap&
FORMAT=image%2Fpng&
TRANSPARENT=true&
LAYERS=surval_30140_all_point_19_12_2017&
SLD=http://host-where-my-sld-is-located/sld-shapefile.xml&
CRS=EPSG%3A3857&
STYLES=&
WIDTH=2036&
HEIGHT=686&
BBOX=-79555169.84223041%2C-33479467.308605302%2C79555169.84223041%2C33479467.308605302'

The SLD used as parameter above, containing a filter which has the following form (truncated XML content):

          <ogc:Filter xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <ogc:PropertyIsLike escapeChar="\" matchCase="false" singleChar="?" wildCard="*">
              <ogc:PropertyName>SUPPORTS_N</ogc:PropertyName>
              <ogc:Literal>*Support : Eau - Niveau : Surface (0-1m)*</ogc:Literal>
            </ogc:PropertyIsLike>
          </ogc:Filter>

Mapserver will parse the SLD and generate a temporary mapfile to produce the actual output, this mapfile will translate the previous PopertyIsLike property into the following expression:

    CLASS
      NAME "Unknown"
      EXPRESSION (("[SUPPORTS_N]" ~* ".*Support : Eau - Niveau : Surface (0-1m).*"))
      STYLE
        COLOR 0 92 230
        SIZE 6
        SYMBOL "sld_mark_symbol_circle_filled"
      END # STYLE
    END # CLASS

The wildcard character (*) is correctly escaped (-> .* ) as a REGEXP, but the parenthesis are not ((0-1m) instead of \(0-1m\)). The expected expression should have every REGEXP control characters escaped when generating the temporary mapfile.

Note: The issue was encountered on a oracle spatial datasource but adapted to a shapefile source to simplify its reproduction. In case of an Oracle datasource, another part of the temporary mapfile might be affected by a similar issue, about the FILTER directive as below:

 LAYER
    CONNECTION "aaa/bbb@oracle"
    CONNECTIONTYPE ORACLESPATIAL
    DATA "..."
    DEBUG 5
    ENCODING "UTF-8"
    EXTENT -180 -90 180 90
    FILTER (((("[SUPPORTS_NIVEAUX_PRELEVEMENT]" ~* ".*Support : Eau - Niveau : Surface (0-1m).*"))))
 [...]

rouault added a commit to rouault/mapserver that referenced this issue Sep 7, 2018

@rouault rouault closed this in b023c9c Sep 7, 2018

rouault added a commit that referenced this issue Sep 7, 2018

Merge pull request #5660 from rouault/fix_propertyislike_escaping
SLD / Filter encoding: fix escaping of REGEX special characters (fixes #5658)
@pmauduit

This comment has been minimized.

Contributor

pmauduit commented Sep 7, 2018

thanks @rouault !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment