summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brand <michael.ch.brand@gmail.com>2013-05-05 15:04:40 (GMT)
committer Carsten Dominik <carsten.dominik@gmail.com>2013-05-05 16:12:53 (GMT)
commit9998f2c897eb710cbc592c8b8e558cf1b2f8b7c1 (patch)
treec018041169d3a3abbc8665574533d0b52fd3dad4
parentccfe83666bd2a5e62a020c8e9c31bbcf6a9d44d3 (diff)
downloadorg-mode-9998f2c897eb710cbc592c8b8e558cf1b2f8b7c1.zip
org-mode-9998f2c897eb710cbc592c8b8e558cf1b2f8b7c1.tar.gz
Escape double quotes in URL passed to browse-url
Escape double quotes in URL passed to browse-url * lisp/org.el (org-link-escape-chars-browser): Add char double quote. * lisp/org.el (org-open-at-point): Make use of the constant `org-link-escape-chars-browser'. * testing/lisp/test-org.el (test-org/org-link-unescape-ascii-extended-char): Fill paragraph. (test-org/org-link-escape-url-with-escaped-char): Fill paragraph and typo. (test-org/org-link-escape-chars-browser): New test. This is to make work to open the Org link [[http://some.host.com/search?q="Org mode"]] in a browser. From 28726bcc7b7c440d70e2d95ea5a61d0cd5f084ea Mon Sep 17 00:00:00 2001 From: Michael Brand <michael.ch.brand@gmail.com> Date: Sun, 5 May 2013 17:02:18 +0200 Subject: [PATCH] Escape double quotes in URL passed to browse-url * lisp/org.el (org-link-escape-chars-browser): Add char double quote. * lisp/org.el (org-open-at-point): Make use of the constant `org-link-escape-chars-browser'. * testing/lisp/test-org.el (test-org/org-link-unescape-ascii-extended-char): Fill paragraph. (test-org/org-link-escape-url-with-escaped-char): Fill paragraph and typo. (test-org/org-link-escape-chars-browser): New test. This is to make work to open the Org link [[http://some.host.com/search?q="Org mode"]] in a browser.
-rw-r--r--lisp/org.el26
-rw-r--r--testing/lisp/test-org.el16
2 files changed, 30 insertions, 12 deletions
diff --git a/lisp/org.el b/lisp/org.el
index ae0110f..b839a8f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9693,7 +9693,7 @@ according to FMT (default from `org-email-link-description-format')."
This is the list that is used for internal purposes.")
(defconst org-link-escape-chars-browser
- '(?\ )
+ '(?\ ?\")
"List of escapes for characters that are problematic in links.
This is the list that is used before handing over to the browser.")
@@ -10423,16 +10423,24 @@ application the system uses for this file type."
(apply cmd (nreverse args1))))
((member type '("http" "https" "ftp" "news"))
- (browse-url (concat type ":" (if (org-string-match-p "[[:nonascii:] ]" path)
- (org-link-escape
- path org-link-escape-chars-browser)
- path))))
+ (browse-url
+ (concat type ":"
+ (if (org-string-match-p
+ (concat "[[:nonascii:]"
+ org-link-escape-chars-browser "]")
+ path)
+ (org-link-escape path org-link-escape-chars-browser)
+ path))))
((string= type "doi")
- (browse-url (concat org-doi-server-url (if (org-string-match-p "[[:nonascii:] ]" path)
- (org-link-escape
- path org-link-escape-chars-browser)
- path))))
+ (browse-url
+ (concat org-doi-server-url
+ (if (org-string-match-p
+ (concat "[[:nonascii:]"
+ org-link-escape-chars-browser "]")
+ path)
+ (org-link-escape path org-link-escape-chars-browser)
+ path))))
((member type '("message"))
(browse-url (concat type ":" path)))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 259dc04..6aa0de7 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -395,15 +395,25 @@
(should
(string=
"àâçèéêîôùû"
- (decode-coding-string (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1))))
+ (decode-coding-string
+ (org-link-unescape "%E0%E2%E7%E8%E9%EA%EE%F4%F9%FB") 'latin-1))))
(ert-deftest test-org/org-link-escape-url-with-escaped-char ()
- "Escape and unscape a URL that includes an escaped char.
+ "Escape and unescape a URL that includes an escaped char.
http://article.gmane.org/gmane.emacs.orgmode/21459/"
(should
(string=
"http://some.host.com/form?&id=blah%2Bblah25"
- (org-link-unescape (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
+ (org-link-unescape
+ (org-link-escape "http://some.host.com/form?&id=blah%2Bblah25")))))
+
+(ert-deftest test-org/org-link-escape-chars-browser ()
+ "Escape a URL to pass to `browse-url'."
+ (should
+ (string=
+ "http://some.host.com/search?q=%22Org%20mode%22"
+ (org-link-escape "http://some.host.com/search?q=\"Org mode\""
+ org-link-escape-chars-browser))))