* [PATCH] Escape double quotes in URL passed to browse-url
@ 2013-05-05 15:04 Michael Brand
2013-05-05 16:13 ` Carsten Dominik
0 siblings, 1 reply; 2+ messages in thread
From: Michael Brand @ 2013-05-05 15:04 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 535 bytes --]
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.
[-- Attachment #2: 0001-Escape-double-quotes-in-URL-passed-to-browse-url.patch.txt --]
[-- Type: text/plain, Size: 3695 bytes --]
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.
---
lisp/org.el | 26 +++++++++++++++++---------
testing/lisp/test-org.el | 16 +++++++++++++---
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))))
\f
--
1.7.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Escape double quotes in URL passed to browse-url
2013-05-05 15:04 [PATCH] Escape double quotes in URL passed to browse-url Michael Brand
@ 2013-05-05 16:13 ` Carsten Dominik
0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2013-05-05 16:13 UTC (permalink / raw)
To: Michael Brand; +Cc: Org Mode
Applied, thanks.
- Carsten
On 5.5.2013, at 17:04, Michael Brand <michael.ch.brand@gmail.com> wrote:
> 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.
> <0001-Escape-double-quotes-in-URL-passed-to-browse-url.patch.txt>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-05 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-05 15:04 [PATCH] Escape double quotes in URL passed to browse-url Michael Brand
2013-05-05 16:13 ` Carsten Dominik
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.