diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-11-26 23:55:05 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-11-26 23:56:17 +0100 |
commit | cd60a35fe1088ac9d42e324968df04d36b7f0668 (patch) | |
tree | 37f4caadcc14395701e3755274e2be3e721c071b | |
parent | 32a7305ddaca97334b380829f063ad95b0f59d3b (diff) | |
download | org-mode-cd60a35fe1088ac9d42e324968df04d36b7f0668.tar.gz |
Fix opening custom ID links with percent escaped syntax
* lisp/org.el (org-open-at-point): Un-escape percent escaped path.
* testing/lisp/test-org.el (test-org/custom-id): Add test.
Reported-by: stardiviner <numbchild@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-11/msg00303.html>
-rw-r--r-- | lisp/org.el | 7 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index ed766f9..0da0007 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10284,9 +10284,10 @@ a link." (org-search-radio-target (org-element-property :path context)) (org-link-search - (if (member type '("custom-id" "coderef")) - (org-element-property :raw-link context) - path) + (pcase type + ("custom-id" (concat "#" path)) + ("coderef" (format "(%s)" path)) + (_ path)) ;; Prevent fuzzy links from matching ;; themselves. (and (equal type "fuzzy") diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 669ad43..6e1abc8 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2338,6 +2338,12 @@ SCHEDULED: <2014-03-04 tue.>" "* H1\n:PROPERTIES:\n:CUSTOM_ID: custom\n:END:\n* H2\n[[#custom<point>]]" (org-open-at-point) (looking-at-p "\\* H1"))) + ;; Handle escape characters. + (should + (org-test-with-temp-text + "* H1\n:PROPERTIES:\n:CUSTOM_ID: [%]\n:END:\n* H2\n[[#%5B%25%5D<point>]]" + (org-open-at-point) + (looking-at-p "\\* H1"))) ;; Throw an error on false positives. (should-error (org-test-with-temp-text |