emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %-escapes in file URL


From: YAMAMOTO Mitsuharu
Subject: Re: %-escapes in file URL
Date: Fri, 19 May 2006 08:09:39 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Richard Stallman <rms <at> gnu.org> writes:

> 
>     In dnd-handle-one-url, %-escapes in the given file URL is decoded
>     immediately.  But I think that should be done when extracting the file
>     name from it (i.e., in dnd-get-local-file-name) in order to cope with
>     applications outside Emacs via browse-url.
> 
> Could you explain the connection, please?
> 

(I'm resending this from Gmane, because my emails seem to be rejected by
mx10.gnu.org with "Unrouteable address" these days.) 

Sure.  RFC 2396 says:

2.4.2. When to Escape and Unescape

   A URI is always in an "escaped" form, since escaping or unescaping a
   completed URI might change its semantics.  Normally, the only time
   escape encodings can safely be made is when the URI is being created
   from its component parts; each component may have its own set of
   characters that are reserved, so only the mechanism responsible for
   generating or interpreting that component can determine whether or
   not escaping a character will change its semantics. Likewise, a URI
   must be separated into its components before the escaped characters
   within those components can be safely decoded.

So, URLs coming from other applications (e.g, via drag-and-drop)
should be assumed to be in escaped forms.  Likewise, URLs going to
other applications (e.g., via browse-url) should be in escaped forms.
Some functions in browse-url such as `browse-url-netscape' does
%-escaping, but that is not re-escaping but just increasing the kind
of characters that should be escaped (notably `,' and `)').

A simple and natural policy is to always keep URLs in escaped forms,
whether or not they are used inside Emacs only.  So, my proposal is as
follows:

  * Always treat URLs as those in escaped form.  Don't re-escape or
    unescape them as long as they are URLs (i.e, have a prefix such as
    "file://").  Increasing the kind of escaped characters is not
    re-escaping.

  * When creating a URL from a file name, encode the file name with
    the file name coding system and then %-escape it.

  * When creating a file name from a URL, %-unescape the URL and then
    decode it with the file name coding system.

                                     YAMAMOTO Mitsuharu
                                address@hidden






reply via email to

[Prev in Thread] Current Thread [Next in Thread]