Opened 18 years ago

Last modified 17 years ago

#1549 closed defect

Parsing error when loading maps with quoted connection strings — at Version 8

Reported by: szekerest Owned by: sdlime
Priority: high Milestone: 5.0 release
Component: MapServer C Library Version: 4.6
Severity: critical Keywords:
Cc: unicoletti, dmorissette, tamas

Description (last modified by sdlime)

Some data sources require to quote identifiers with special characters like 
table names. Connections strings containing double quotes produce parsing 
error. However setting this type of connection string at run time seems to be 
working correctly.

Tamas Szekeres

Change History (8)

comment:1 by sdlime, 18 years ago

Can you post some examples?

Steve

comment:2 by szekerest, 18 years ago

Here is the layer definition that could not be parsed. The connection 
parameter was set at run time usig mapscript, and the map file was saved using 
mapObj.save()

LAYER
    CONNECTION "host=localhost port=5433 dbname=GISData user='postgres'"
    CONNECTIONTYPE POSTGIS
    DATA "wkb_geometry from "Gráf/lines wkt" using unique ogc_fid using 
SRID=4326"
      METADATA
      END
    NAME "Gráf/lines wkt"
    PROJECTION
      "init=EPSG:4326"
    END
    SIZEUNITS PIXELS
    STATUS ON
    TOLERANCEUNITS PIXELS
    TYPE LINE
    UNITS METERS
    CLASS
      NAME "Gráf/lines wkt"
      LABEL
        SIZE MEDIUM
        TYPE BITMAP
        BUFFER 0
        COLOR 0 0 0
        FORCE TRUE
        MINDISTANCE -1
        MINFEATURESIZE -1
        OFFSET 0 0
        PARTIALS TRUE
        POSITION CC
      END
      METADATA
      END
      STYLE
        ANGLE 360
          COLOR 42 254 188
          OUTLINECOLOR 69 75 171
        SYMBOL 0
      END
      TEMPLATE "query.html"
    END
  END


Tamas Szekeres

comment:3 by sdlime, 18 years ago

The problem isn't the parser then, it should break on the example you sent. The 
problem is the map file writer. It should be smarter in choosing the quote type 
to use when writing that element. Can you use single qoutes in the DATA element 
when it is originally defined as a workaround?

Steve 

comment:4 by szekerest, 18 years ago

PostgreSQL supports only double quotes with idetifiers. This applies to MSSQL 
as well.

Tamas

comment:5 by szekerest, 18 years ago

I think the parser should utilize escape characters with strings, or read the 
string until the next newline.

Tamas


comment:6 by sdlime, 18 years ago

Escaping quotes is a good idea and has been on my todo list for ages. It never 
seems to be a big enough deal to work on. Just making the writer smarter would 
help you in this case. 

Reading to the next newline isn't a good idea in my opinion.

Steve

comment:7 by dmorissette, 18 years ago

Cc: dmorissette@… added
Milestone: 4.10 release
Setting target milestone to 4.10 as this seems important to fix for this release.

Tamas, I think what Steve meant was that in your mapfile def'n you could have
used single quotes as teh mapfile string delimiter:

  DATA 'wkb_geometry from "Gráf/lines wkt" using unique ogc_fid using SRID=4326'

and a quick fix for this specific case would be to modify writeLayer()
(mapfile.c) to write the DATA statement this way (untested code):

  if(layer->data) { 
    if (strchr(layer->data, '\"') != NULL)
      fprintf(stream, "    DATA '%s'\n", layer->data);
    else
      fprintf(stream, "    DATA \"%s\"\n", layer->data);
  } 

The same should probably be done for the CONNECTION parameter.

Of course, introducing a syntax to properly escape quotes would be best, the
above is just a quick fix until escaping is in place.

comment:8 by sdlime, 17 years ago

Description: modified (diff)

Tamas: Is this still an issue? If so we can try to squeeze in for 5.0.

Steve

Note: See TracTickets for help on using tickets.