Opened 14 years ago

Closed 14 years ago

#3250 closed enhancement (fixed)

Case insensitive variable substitutions

Reported by: pramsey Owned by: pramsey
Priority: normal Milestone: 6.0 release
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc: sdlime

Description

Currently, variable substitutions are case-sensitive, and it would be useful to be able to handle substitutions case-insensitively at times. So, for example http://localhost/cgi-bin/mapserv?Subst=foo could match %subst% in the map file and substitute "foo".

The change will be mostly in msLayerSubstituteString, using strcasestr instead of strstr, when the feature is enabled. Handling of the _validation_pattern in the METADATA will also be changed to coerce the internal hash key to lower case before storing it and before testing against it.

FYI Note: This is a general purpose change, which will be put to specific use in passing the LAYERS key from a WMS request into a PostGIS data statement, that will split the WMS LAYERS string and use the values to pull information from a metadata table and write appropriate layer copyright information into the acetate map overlay.

Enabling case insensitive substitutions will be done with a CONFIG directive:

CONFIG SUBSTITUTIONS_IGNORE_CASE [yes|no]

The existing case-senstive behavior will be the default.

Change History (7)

comment:1 by pramsey, 14 years ago

Cc: sdlime added

While working on the patch, I found that the layer->metadata hashtables are already case-insensitive. The only case-sensitive piece left is the actual substitution in msLayerSubstituteString. I'm wondering if making the case-insensitivity the default behavior might be OK?

comment:2 by sdlime, 14 years ago

I was kinda wondering the same thing too, but even broader. The substitution code from mapstring.c is used primarily in 3 places:

  • the runtime subs
  • templates subs
  • logical expression subs

There's already a case insensitive version of msReplaceSubstring() available in mapstring.c (as msCaseReplaceSubstring()). I don't know why we don't use that instead of the case sensitive version everywhere- unless there are big performance penalties. I wouldn't think that would break apps.

This isn't a RFC-able enhancement although running the msCaseReplaceSubstring() for msReplaceSubstring() by mapserver-devs would be a good idea.

Steve

comment:3 by pramsey, 14 years ago

And I was wondering if we could replace msCaseFindSubstring() throughout the code base with strcasestr()!

comment:4 by pramsey, 14 years ago

I've placed the larger issue in #3254, so I can deal with my small issue here. Do you think the %substitution% code in particular can be safely made case insensitive?

comment:5 by sdlime, 14 years ago

Yes. Anyone relying on %foo% to behave differently from %FOO% is asking for trouble regardless. I think in 6.0 we simply go case insensitive for tags or all forms...

Steve

comment:6 by pramsey, 14 years ago

Committed at r9672

comment:7 by pramsey, 14 years ago

Resolution: fixed
Status: newclosed

Closing as complete!

Note: See TracTickets for help on using tickets.