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

Timothy Astle tastle at caris.com
Wed Jun 18 05:47:47 PDT 2014


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.


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
>

-- 
Tim Astle
Development Manager
Web Technologies

*CARIS* <http://www.caris.com>
115 Waggoners Lane
Fredericton, New Brunswick
Canada    E3B 2L4
Tel: +1.506.458.8533     Fax: +1.506.459.3849
www.caris.com <http://www.caris.com>

*Connect with CARIS*
Twitter <http://www.twitter.com/CARIS_GIS> | LinkedIn 
<http://www.linkedin.com/groups?mostPopular=&gid=3217878> | Facebook 
<https://www.facebook.com/pages/CARIS-The-Marine-GIS-Experts/123907500987669?v=app_4949752878> 
| Google+ 
<https://plus.google.com/b/114389770462919844434/114389770462919844434/posts> 
| YouTube <http://www.youtube.com/user/CARISGIS>

Download your free copy of CARIS Easy View today!
www.caris.com/easyview <http://www.caris.com/easyview>

_________________________________________________________________________
This email and any files transmitted with it are confidential and 
intended only for the addressee(s). If you are not the intended 
recipient(s) please notify us by email reply. You should not use, 
disclose, distribute or copy this communication if received in error.

Any views or opinions expressed in this email are solely those of the 
author and do not necessarily represent those of the company. No binding 
contract will result from this email until such time as a written 
document is signed on behalf of the company.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140618/0faffede/attachment.html>


More information about the gdal-dev mailing list