[mapserver-dev] Quote escaping in mapfile strings

thomas bonfort thomas.bonfort at gmail.com
Wed Jan 12 04:13:11 EST 2011


Yes, it seems Steve has added that very recently, but I haven't tested it yet.

Steve has chosen C style \ escaping and am supportive of this idea. I
would be -0 on the second escaping technique as to me it seems more
convoluted and less intuitive: imho taking a burden off windows users
is fine unless it puts a burden on traditional *nix users.

best regards,
thomas

On Wed, Jan 12, 2011 at 09:25, Umberto Nicoletti
<umberto.nicoletti at gmail.com> wrote:
> Daniel,
> I think we are already using the first approach in the mapfile to
> escape quotes, see maplexer.l lines 534 to 577.
>
> Regards,
> Umberto
>
> On Wed, Jan 12, 2011 at 5:10 AM, Daniel Morissette
> <dmorissette at mapgears.com> wrote:
>> An issue that keeps coming back every once in a while is the lack of a
>> mechanism to escape quotes (') and double quotes (") inside strings in
>> mapfiles.
>>
>> 6.0 would be a good time to address this in case the fix implies new mapfile
>> rules or limitations.
>>
>> The first step is to decide on the syntax to escape quotes. Can anyone think
>> of a magic solution to this problem that will make everybody happy?
>>
>> Here are a few thoughts:
>>
>> 1- An obvious approach could be to use C escaping: \' , \" and \\ ... but
>> unfortunately that would force the use of double \\ in all windows filename
>> paths. I realize that one could use "/" on Windows instead but using this
>> approach could cause unnecessary confusion with beginners and become a FAQ
>> that comes up more often than the use dummy TEMPLATEs to enable queries in
>> MapScript.
>>
>> 2- Another approach could be to use two double quotes ("") to escape a
>> double quote, and two single quotes ('') to escape a single quote
>>
>> e.g.
>>  "This string contains ""Double Quotes"""
>>  'This string contains ''Single Quotes'''
>>  "You don't need to escape single quotes in this string since it uses double
>> quotes ("") as delimiter"
>>  'And the same way "Double Quotes" don't need escaping here'
>>  "Two ''single quotes'' in this string are not considered an escape sequence
>> and remain two individual chars'
>>
>> /me thinks #2 could work with a minimum of disruption to existing mapfiles,
>> unless I missed something. We'd need Steve's opinion on how this can be
>> implemented in the parser.
>>
>> Anyone have better suggestions?
>>
>> Daniel
>> --
>> Daniel Morissette
>> http://www.mapgears.com/
>> _______________________________________________
>> mapserver-dev mailing list
>> mapserver-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>


More information about the mapserver-dev mailing list