summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-14 22:39:54 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-12-14 22:39:54 +0100
commitfe98379fce44927b2a25fc817a4da76f7eec866d (patch)
tree42c0d2a44cc67c63a61e1f43e59067513ed97ba9
parent263a0cf00ed528a835003293c1ff810f140ffd86 (diff)
downloadorg-mode-fe98379fce44927b2a25fc817a4da76f7eec866d.tar.gz
Fix fuzzy link escaping
* lisp/org.el (org-make-link-string): Properly escape square brackets and percent sings in fuzzy links. * testing/lisp/test-org-clock.el (test-org-clock/clocktable/link): Update tests. Reported-by: Paulo Matos <paulo@matos-sorge.com> <http://lists.gnu.org/r/emacs-orgmode/2017-12/msg00269.html>
-rw-r--r--lisp/org.el10
-rw-r--r--testing/lisp/test-org-clock.el4
2 files changed, 6 insertions, 8 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 11be226..bb95056 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9959,14 +9959,12 @@ according to FMT (default from `org-email-link-description-format')."
(let ((uri (cond ((string-match org-link-types-re link)
(concat (match-string 1 link)
(org-link-escape (substring link (match-end 1)))))
- ;; For readability, url-encode internal links only
- ;; when absolutely needed (i.e, when they contain
- ;; square brackets). File links however, are
- ;; encoded since, e.g., spaces are significant.
((or (file-name-absolute-p link)
- (string-match-p "\\`\\.\\.?/\\|[][]" link))
+ (string-match-p "\\`\\.\\.?/" link))
(org-link-escape link))
- (t link)))
+ ;; For readability, do not encode space characters
+ ;; in fuzzy links.
+ (t (org-link-escape link (remq ?\s org-link-escape-chars)))))
(description
(and (org-string-nw-p description)
;; Remove brackets from description, as they are fatal.
diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index b7b09ed..4f73dbc 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -640,7 +640,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
-| [[Foo%20%5B%5Bhttp://orgmode.org%5D%5BOrg%20mode%5D%5D][Foo Org mode]] | 26:00 |"
+| [[Foo %5B%5Bhttp://orgmode.org%5D%5BOrg mode%5D%5D][Foo Org mode]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[http://orgmode.org][Org mode]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
@@ -651,7 +651,7 @@ CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|------------------------+---------|
| *Total time* | *26:00* |
|------------------------+---------|
-| [[Foo%20%5B%5Bhttp://orgmode.org%5D%5D][Foo http://orgmode.org]] | 26:00 |"
+| [[Foo %5B%5Bhttp://orgmode.org%5D%5D][Foo http://orgmode.org]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[http://orgmode.org]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"