[gdal-dev] CPLEscapeString URL - encoding characters that don't need to be encoded

Even Rouault even.rouault at mines-paris.org
Wed Jun 18 06:18:55 PDT 2014


Le mercredi 18 juin 2014 14:47:47, Timothy Astle a écrit :
> I was thinking something like the following:
> 
>               if( (pszInput[iIn] >= 'a' && pszInput[iIn] <= 'z')
> 
>                   || (pszInput[iIn] >= 'A' && pszInput[iIn] <= 'Z')
>                   || (pszInput[iIn] >= '0' && pszInput[iIn] <= '9')
> 
> -                || pszInput[iIn] == '_' || pszInput[iIn] == '.' )
> +                || pszInput[iIn] == '$' && pszInput[iIn] == '-'
> +                || pszInput[iIn] == '_' || pszInput[iIn] == '.'
> +                || pszInput[iIn] == '+' && pszInput[iIn] == '!'
> +                || pszInput[iIn] == '*' && pszInput[iIn] == '\''
> +                || pszInput[iIn] == '(' && pszInput[iIn] == ')'
> +                || pszInput[iIn] == '"' && pszInput[iIn] == ',' )
> 
> which follows the list of special characters that may be used unencoded
> within a URL.
> 
>     Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
>     reserved characters used for their reserved purposes may be used
>     unencoded within a URL.
> 
> That list is mutually exclusive from the list you cited as being a
> concern, which I agree with.

Looks reasonable, although I anticipate we might hit server bugs if changing 
that...

> 
> 
> Tim
> 
> On 17/06/2014 6:24 PM, Even Rouault wrote:
> > Le lundi 16 juin 2014 14:20:59, Timothy Astle a écrit :
> >> Hi all,
> >> 
> >> Does anyone know why CPLEscapeString
> >> (https://svn.osgeo.org/gdal/trunk/gdal/port/cpl_string.cpp) character
> >> encodes characters that are valid as-is according to
> >> http://www.ietf.org/rfc/rfc1738.txt?
> >> 
> >> I just hit a situation where I noticed the WMS driver is converting
> >> hyphens to %2D for layer names.  The 3rd party server doesn't handle it
> >> (but it should) and this caught my attention.
> >> 
> >> Any thoughts?  Is it just a case where a patch would be welcome?
> > 
> > Tim,
> > 
> > What would your patch do ? Implement the following from RFC1738 ? :
> > 
> > "Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
> > reserved characters used for their reserved purposes may be used
> > unencoded within a URL."
> > 
> > Well, actually I think it should still encode the reserved characters
> > (";",
> > 
> >   "/", "?", ":", "@", "=" and "&"), since valid use cases of
> >   CPLEscapeString(,
> > 
> > CPLES_URL) might be do make sure that they are encoded.
> > 
> > Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list