Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-quote.

View: New views
3 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-quote.

by William Xu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Olson <mwolson@...> writes:

> Thu Feb 14 20:58:00 CST 2008  Michael Olson <mwolson@...>
>   * emms-url: Improve emms-url-quote.
>  
>    - Don't clobber the match data.
>    - Don't escape the colon in "http://".

For escaping the colon in "http://", the patch uses:

    (string-match "\\`\\([^:]+:\\)\\(.+\\)\\'" s)
    (let ((handler (match-string 1 s))
          (loc (or (match-string 2 s) s))

Do you assume that argument must be a full uri path like `http://foo' ?
And how to handle cases like 'http://foo@:bar'?

I thought the argument could be any string, so that this function would
be generally useful. For creating a full uri path, i would rather use
something like:

    (concat "http://" (emms-url-quote "blahblah"))

--
William


_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Parent Message unknown Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-quote.

by William Xu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Olson <mwolson@...> 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


_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Parent Message unknown Re: [Emms-patches] darcs patch: emms-url: Improve emms-url-quote.

by William Xu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Olson <mwolson@...> writes:

> I've now sent a patch that restores the previous behavior (with the
> exception of saving match data) and adds another function to do what I
> want in emms-player-mpd.el.

Thanks. I didn't know that emms-player-mpd.el had a somewhat different
usage on that.

--
William


_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help