aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-player-mpd.el2
-rw-r--r--emms-url.el25
2 files changed, 26 insertions, 1 deletions
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index 16d035d..c31c48b 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -758,7 +758,7 @@ Execute CALLBACK with CLOSURE as its first argument when done."
(progn
(require 'emms-url)
(with-temp-buffer
- (url-insert-file-contents (emms-url-quote url))
+ (url-insert-file-contents (emms-url-quote-entire url))
(emms-http-decode-buffer (current-buffer))
(emms-player-mpd-add-buffer-contents (current-buffer)
closure callback)))
diff --git a/emms-url.el b/emms-url.el
index aee894d..24ae903 100644
--- a/emms-url.el
+++ b/emms-url.el
@@ -28,6 +28,31 @@
(require 'url)
(require 'emms-compat)
+(defvar emms-url-specials-entire
+ '((?\ . "%20")
+ (?\n . "%0D%0A"))
+ "*An alist of characters which must be represented specially in URLs.
+The transformation is the key of the pair.
+
+This is used by `emms-url-quote-entire'.")
+
+(defun emms-url-quote-entire (url)
+ "Escape specials conservatively in an entire URL.
+
+The specials to escape are specified by the `emms-url-specials-entire'
+variable.
+
+If you want to escape parts of URLs thoroughly, then use
+`emms-url-quote' instead."
+ (apply (function concat)
+ (mapcar
+ (lambda (ch)
+ (let ((repl (assoc ch emms-url-specials-entire)))
+ (if (null repl)
+ (char-to-string ch)
+ (cdr repl))))
+ (append url nil))))
+
(defun emms-url-quote (s &optional safe)
"Replace special characters in S using the `%xx' escape.
This is useful for escaping parts of URLs, but not entire URLs.