Mapscript - tricky save map problem when DATA containes quotes

Frank Warmerdam fwarmerdam at GMAIL.COM
Fri Apr 29 10:06:24 EDT 2005


On 4/29/05, Daniel Caldeweyher <calde at gmx.net> wrote:
> Hi,
> 
> I have encountered a bit of a tricky situation. My mapping application
> allows users to dynamically add layers using a wizard (similar to MS-ACCESS
> Report Wizard, where the user can select fields from different tables). The
> application generates SQL from this selection, more precise, the truncated
> SQL part which forms the DATA element of a layer. To be on the safe side
> with table and column names (I use PostGIS) I put all names in quotes.
> However when I then dynamically save the mapobj to a mapfile, mapscript
> places quotes around the DATA statement, which when trying to load that file
> again, will cause problems as the parse thinks the the first quote is the
> end of the DATA element, which it obviously isn't.
> 
> I noticed that with EXPRESSION's when putting the expression inside
> parantheses () it will not enclose the expression with quotes, however
> trying to do so with DATA doesn't work.
> 
> Since I keep the meta-information of my layer wizard, I can just simply set
> DATA to an empty string before saving the map, and use that meta-information
> (stored in the file as METADATA) I can re-generate my DATA string when
> loading the file. However I don't like this solution and was wondering if
> there is a better solution for cases when the DATA string itself contains
> quotes (as well as single quotes).

Daniel, 

I believe if you submit a bug report on this topic we could try and
alter the map writer to use single quotes if the DATA string has
double quotes, but no single quotes.  I'm not sure if there is a more
general escaping mechanism for the case where string constants
need both single and double quotes but if there is then the map saving
logic should use it. 

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-users mailing list