[gdal-dev] vsicurl configuration design decisions

Even Rouault even.rouault at spatialys.com
Fri Oct 13 15:29:41 PDT 2017


Sean,

> I'd like to point out that very often URLs in a query string do not need to
> be encoded. Both the Python (see my earlier example) and Node standard
> parsers will handle the string
> 

While researching that issue, and from my pat memories, I found that there is 
a bit of confusion around the subject when to escape or not

> /viscurl?option1=foo&option2=bar&url=https://example.com/foo.tif
> 
> without any URL encoding.

https://tools.ietf.org/html/rfc3986 says in "3.4.  Query"

"""
      query       = *( pchar / "/" / "?" )

   The characters slash ("/") and question mark ("?") may represent data
   within the query component.  Beware that some older, erroneous
   implementations may not handle such data correctly when it is used as
   the base URI for relative references (Section 5.1), apparently
   because they fail to distinguish query data from path data when
   looking for hierarchical separators.  However, as query components
   are often used to carry identifying information in the form of
   "key=value" pairs and one frequently used value is a reference to
   another URI, it is sometimes better for usability to avoid percent-
   encoding those characters.
"""

But urrlib.urlencode() encodes slashes in values of query arguments, so they 
probably decided to avoid isues with the above mentionned older, erroneous 
implementations

>>> urllib.urlencode({'foo':'bar', 'url': 'http://example.com'})
'url=http%3A%2F%2Fexample.com&foo=bar'

> The web already has escaping rules built in, one of the benefits I alluded
> to above.

OK, let's follow your suggestion of using URL query string formatting, while 
this hasn't gone in a official release. Could you create a ticket about that ?

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list