[mapserver-users] Mapserver CGI URL parameter parsing with plus character escaped as %2b
Fergus McDonald
mapserver at schartz.net
Wed Oct 1 08:01:30 PDT 2014
Thank you for the speedy response.
Yes.. that was exactly the issue. By placing a literal space within the
parameter within OpenLayers, the URL arrives at mapserver escaped as
labelitem%20columnname and everything works.
May I suggest somewhere in the Mapserver CGI documentation it might
mention that the plus sign is used to encode a space.. particularly in
the section on CGI "Changing map file parameters via a form or a URL",
as I couldn't find any mention of this.
Thanks again for your help.
On Wed, 1 Oct 2014 16:30:08 +0200
thomas bonfort <thomas.bonfort at gmail.com> wrote:
> the + sign is used to encode a space in a url, and that space is what
> mapserver's parser is looking for. translated to mapfile syntax, your
> first two requests are parsed as
>
> labelitem columnname
>
> whereas the last one is
>
> labelitem+columnname
>
> which is invalid.
>
> tl;dr don't escape the + sign, mapserver is expecting a space not a +
>
> --
> thomas
>
> On 1 October 2014 16:15, Fergus McDonald <mapserver at schartz.net>
> wrote:
> > I am having an issue with Mapserver 6.4.1 when attempting to pass a
> > layer labelitem parameter setting via URL.
> >
> > The map file contains the following validation for layer 0
> >
> > VALIDATION
> > "labelitem" "[a-z]+"
> > END
> >
> > The following request works (ignore the double quotes around the
> > entire URL):
> >
> > "http://sitename/cgi-bin/map=pathtomapfile&mode=map&map.layer[0]=labelitem+columnname"
> >
> > as does this (note the brackets replaced with html escapes)
> >
> > "http://sitename/cgi-bin/map=pathtomapfile&mode=map&map.layer%5B0%5D=labelitem+columnname"
> >
> > ..but if the plus sign is escaped also:
> >
> > "http://sitename/cgi-bin/map=pathtomapfile&mode=map&map.layer%5B0%5D=labelitem%2Bcolumnname"
> >
> > Mapserver fails with the following error:
> >
> > getString(): Symbol definition error. Parsing error near (+):(line
> > 1)
> >
> > This problem arises because when generating such requests from
> > OpenLayers, any such parameters automatically have the plus sign
> > escaped before the request is sent. It does seem unconsistent that
> > escapes are recognised for some parts of the URL and not others.
> >
> > Am I doing something wrong or should this be a bug report?
> >
> > Thanks in advance
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list