aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/url
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/ChangeLog17
-rw-r--r--lisp/url/url-handlers.el2
-rw-r--r--lisp/url/url-util.el42
3 files changed, 45 insertions, 16 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 901fac01208..e4b54f9fc92 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,20 @@
12006-08-25 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * url-handlers.el (url-file-local-copy): Tell url-copy-file that the
4 dest file will already exist.
5
62006-07-31 Stefan Monnier <monnier@iro.umontreal.ca>
7
8 * url-util.el (url-hexify-string): Only utf-8 encode if it's
9 a multibyte string.
10 (url-normalize-url): Remove unused var `grok'.
11 (url-truncate-url-for-viewing): Remove unused var `tail'.
12
132006-07-30 Thien-Thi Nguyen <ttn@gnu.org>
14
15 * url-util.el (url-hexify-string): Rewrite.
16 Suggested by David Smith <davidsmith@acm.org>.
17
12006-07-12 Michael Olson <mwolson@gnu.org> 182006-07-12 Michael Olson <mwolson@gnu.org>
2 19
3 * url-irc.el (url-irc-erc): Call erc-handle-irc-url. 20 * url-irc.el (url-irc-erc): Call erc-handle-irc-url.
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index 6c6d85a1e03..97d10003620 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -213,7 +213,7 @@ A prefix arg makes KEEP-TIME non-nil."
213Returns the name of the local copy, or nil, if FILE is directly 213Returns the name of the local copy, or nil, if FILE is directly
214accessible." 214accessible."
215 (let ((filename (make-temp-file "url"))) 215 (let ((filename (make-temp-file "url")))
216 (url-copy-file url filename) 216 (url-copy-file url filename 'ok-if-already-exists)
217 filename)) 217 filename))
218 218
219(defun url-insert (buffer &optional beg end) 219(defun url-insert (buffer &optional beg end)
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index f33a58950fc..0aeb141c017 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -163,7 +163,7 @@ Also replaces the \" character, so that the result may be safely used as
163(defun url-normalize-url (url) 163(defun url-normalize-url (url)
164 "Return a 'normalized' version of URL. 164 "Return a 'normalized' version of URL.
165Strips out default port numbers, etc." 165Strips out default port numbers, etc."
166 (let (type data grok retval) 166 (let (type data retval)
167 (setq data (url-generic-parse-url url) 167 (setq data (url-generic-parse-url url)
168 type (url-type data)) 168 type (url-type data))
169 (if (member type '("www" "about" "mailto" "info")) 169 (if (member type '("www" "about" "mailto" "info"))
@@ -352,17 +352,31 @@ forbidden in URL encoding."
352This is taken from RFC 2396.") 352This is taken from RFC 2396.")
353 353
354;;;###autoload 354;;;###autoload
355(defun url-hexify-string (str) 355(defun url-hexify-string (string)
356 "Escape characters in a string." 356 "Return a new string that is STRING URI-encoded.
357 (mapconcat 357First, STRING is converted to utf-8, if necessary. Then, for each
358 (lambda (char) 358character in the utf-8 string, those found in `url-unreserved-chars'
359 ;; Fixme: use a char table instead. 359are left as-is, all others are represented as a three-character
360 (if (not (memq char url-unreserved-chars)) 360string: \"%\" followed by two lowercase hex digits."
361 (if (> char 255) 361 ;; To go faster and avoid a lot of consing, we could do:
362 (error "Hexifying multibyte character %s" str) 362 ;;
363 (format "%%%02X" char)) 363 ;; (defconst url-hexify-table
364 (char-to-string char))) 364 ;; (let ((map (make-vector 256 nil)))
365 str "")) 365 ;; (dotimes (byte 256) (aset map byte
366 ;; (if (memq byte url-unreserved-chars)
367 ;; (char-to-string byte)
368 ;; (format "%%%02x" byte))))
369 ;; map))
370 ;;
371 ;; (mapconcat (curry 'aref url-hexify-table) ...)
372 (mapconcat (lambda (byte)
373 (if (memq byte url-unreserved-chars)
374 (char-to-string byte)
375 (format "%%%02x" byte)))
376 (if (multibyte-string-p string)
377 (encode-coding-string string 'utf-8)
378 string)
379 ""))
366 380
367;;;###autoload 381;;;###autoload
368(defun url-file-extension (fname &optional x) 382(defun url-file-extension (fname &optional x)
@@ -389,7 +403,6 @@ then return the basename of the file with the extension stripped off."
389WIDTH defaults to the current frame width." 403WIDTH defaults to the current frame width."
390 (let* ((fr-width (or width (frame-width))) 404 (let* ((fr-width (or width (frame-width)))
391 (str-width (length url)) 405 (str-width (length url))
392 (tail (file-name-nondirectory url))
393 (fname nil) 406 (fname nil)
394 (modified 0) 407 (modified 0)
395 (urlobj nil)) 408 (urlobj nil))
@@ -397,8 +410,7 @@ WIDTH defaults to the current frame width."
397 (if (and (>= str-width fr-width) 410 (if (and (>= str-width fr-width)
398 (string-match "?" url)) 411 (string-match "?" url))
399 (setq url (concat (substring url 0 (match-beginning 0)) "?...") 412 (setq url (concat (substring url 0 (match-beginning 0)) "?...")
400 str-width (length url) 413 str-width (length url)))
401 tail (file-name-nondirectory url)))
402 (if (< str-width fr-width) 414 (if (< str-width fr-width)
403 nil ; Hey, we are done! 415 nil ; Hey, we are done!
404 (setq urlobj (url-generic-parse-url url) 416 (setq urlobj (url-generic-parse-url url)