aboutsummaryrefslogtreecommitdiff
path: root/emms-url.el
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2008-02-15 17:35:00 +0000
committerMichael Olson <mwolson@gnu.org>2008-02-15 17:35:00 +0000
commit2964c94e715085829002ded00cc9933cf4b2279c (patch)
tree82f6e5a8dfc384ffad869f5eefe34d1ff3780230 /emms-url.el
parent4ff658089418170cc4628effc3481b6ec0f01dd2 (diff)
emms-url: Add emms-url-quote-entire function.
Use it to conservatively escape entire URLs. Make emms-player-mpd use this instead of emms-url-quote. darcs-hash:20080215173509-1bfb2-de02bb833c0ca4afefa42f232c1278d1c3e155ca.gz
Diffstat (limited to 'emms-url.el')
-rw-r--r--emms-url.el25
1 files changed, 25 insertions, 0 deletions
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.