aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Xu <william.xwl@gmail.com>2008-02-16 08:56:00 +0000
committerWilliam Xu <william.xwl@gmail.com>2008-02-16 08:56:00 +0000
commit5198c20b9fe58a7a167078b2aea1e952585dd268 (patch)
tree03a755662971bb68b1682072768ef648dec44c27
parent3294650f52d5a1ac41fb933fade5b46753ed13f1 (diff)
(emms-url-quote): Check validity of string parameter S.
darcs-hash:20080216085614-cfa61-7ff36e17d340cb138941a82f5e90c8077a3868eb.gz
-rw-r--r--emms-url.el32
1 files changed, 17 insertions, 15 deletions
diff --git a/emms-url.el b/emms-url.el
index 5c7746e..99d7ad7 100644
--- a/emms-url.el
+++ b/emms-url.el
@@ -61,21 +61,23 @@ Characters in [a-zA-Z_.-/] and SAFE(default is \"\") will never be
quoted.
e.g.,
(emms-url-quote \"abc def\") => \"abc%20def\"."
- (or safe (setq safe ""))
- (save-match-data
- (let ((re (if (string-match "]" safe)
- ;; `]' should be placed at the beginning inside []
- (format "[]a-zA-Z_.-/%s]"
- (emms-replace-regexp-in-string "]" "" safe))
- (format "[a-zA-Z_.-/%s]" safe))))
- (mapconcat
- (lambda (c)
- (let ((s1 (char-to-string c)))
- (if (string-match re s1)
- s1
- (format "%%%02x" c))))
- (string-to-list (encode-coding-string s 'utf-8))
- ""))))
+ (if (not (stringp s))
+ ""
+ (or safe (setq safe ""))
+ (save-match-data
+ (let ((re (if (string-match "]" safe)
+ ;; `]' should be placed at the beginning inside []
+ (format "[]a-zA-Z_.-/%s]"
+ (emms-replace-regexp-in-string "]" "" safe))
+ (format "[a-zA-Z_.-/%s]" safe))))
+ (mapconcat
+ (lambda (c)
+ (let ((s1 (char-to-string c)))
+ (if (string-match re s1)
+ s1
+ (format "%%%02x" c))))
+ (string-to-list (encode-coding-string s 'utf-8))
+ "")))))
(defun emms-url-quote-plus (s &optional safe)
"Run (emms-url-quote s \" \"), then replace ` ' with `+'."