comparison lisp/net/browse-url.el @ 106717:15eb515afd85

* net/browse-url.el (browse-url-encode-url): Don't escape commas. They are valid characters in URL paths (rfc3986), and at least Firefox does not understand the encoded version (Bug#3166).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 02 Jan 2010 15:14:54 -0500
parents c89e7ab6a9d6
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
106716:4039413a8b1d 106717:15eb515afd85
611 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 611 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
612 ;; URL encoding 612 ;; URL encoding
613 613
614 (defun browse-url-url-encode-chars (text chars) 614 (defun browse-url-url-encode-chars (text chars)
615 "URL-encode the chars in TEXT that match CHARS. 615 "URL-encode the chars in TEXT that match CHARS.
616 CHARS is a regexp-like character alternative (e.g., \"[,)$]\")." 616 CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
617 (let ((encoded-text (copy-sequence text)) 617 (let ((encoded-text (copy-sequence text))
618 (s 0)) 618 (s 0))
619 (while (setq s (string-match chars encoded-text s)) 619 (while (setq s (string-match chars encoded-text s))
620 (setq encoded-text 620 (setq encoded-text
621 (replace-match (format "%%%x" 621 (replace-match (format "%%%x"
624 s (1+ s))) 624 s (1+ s)))
625 encoded-text)) 625 encoded-text))
626 626
627 (defun browse-url-encode-url (url) 627 (defun browse-url-encode-url (url)
628 "Escape annoying characters in URL. 628 "Escape annoying characters in URL.
629 The annoying characters are those that can mislead a webbrowser 629 The annoying characters are those that can mislead a web browser
630 regarding its parameter treatment. For instance, `,' can 630 regarding its parameter treatment."
631 be misleading because it could be used to separate URLs." 631 ;; FIXME: Is there an actual example of a web browser getting
632 (browse-url-url-encode-chars url "[,)$]")) 632 ;; confused? (This used to encode commas, but at least Firefox
633 ;; handles commas correctly and doesn't accept encoded commas.)
634 (browse-url-url-encode-chars url "[)$]"))
633 635
634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 636 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
635 ;; URL input 637 ;; URL input
636 638
637 ;;;###autoload 639 ;;;###autoload