emms-help
[Top][All Lists]
Advanced

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

[emms-help] Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-q


From: William Xu
Subject: [emms-help] Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-quote.
Date: Fri, 15 Feb 2008 16:11:11 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (darwin)

Michael Olson <address@hidden> writes:

> The emms-player-mpd file, which I maintain, must be able to pass the
> entire URL.  Otherwise I'd have to do some extra work that really ought
> to be handled by this function.  It does not make sense to call
> something `emms-url-quote' and not have it handle real URLs.

Take an example from emms-lastfm.el: 

      (emms-lastfm-http-POST emms-lastfm-now-playing-url
                             (concat "&s="    emms-lastfm-session-id
                                     "&a[0]=" (emms-url-quote artist)
                                     "&t[0]=" (emms-url-quote title)
                                     "&b[0]=" (emms-url-quote album)
                                     "&l[0]=" track-length
                                     "&n[0]=" track-number
                                     "&m[0]=" musicbrainz-id)
                             'emms-lastfm-submit-now-playing-sentinel))))

It's very common to have special characters like `&', `=' in a uri. If
one tries to call emms-url-quote on the full uri, it would be a pain to
have to list those special characters in `safe'.

Also, when I wrote that, I had referenced python's implementation, they
also: "By default, the quote function is intended for quoting the path
section of a URL." 

urllib2.quote() docstring: 

quote(s, safe='/')
    quote('abc def') -> 'abc%20def'
    
    Each part of a URL, e.g. the path info, the query, etc., has a
    different set of reserved characters that must be quoted.
    
    RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
    the following reserved characters.
    
    reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                  "$" | ","
    
    Each of these characters is reserved in some component of a URL,
    but not necessarily in all of them.
    
    By default, the quote function is intended for quoting the path
    section of a URL.  Thus, it will not encode '/'.  This character
    is reserved, but in typical usage the quote function is being
    called on a path where the existing slash characters are used as
    reserved characters.

-- 
William




reply via email to

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