From 57cfb3dbb7ade058f1b99990ba306e2f74645a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alois=20Jan=C3=AD=C4=8Dek?= Date: Wed, 16 Dec 2020 13:31:32 +0100 Subject: [PATCH] (fix): index file: prevent malformed absolute path (#1346) When `org-roam-directory` doesn't end with trailing slash and `org-roam-index-file` contains relative filename, absolute path to org-roam index file returned by `org-roam--get-index-path` is malformed and invalid. Co-authored-by: Jethro Kuan --- CHANGELOG.md | 1 + org-roam.el | 19 ++++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 560897a..2de119c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#1308](https://github.com/org-roam/org-roam/pull/1308) fixed file renames corrupting database - [#1325](https://github.com/org-roam/org-roam/pull/1325) make titles and tags extracted unique per note - [#1327](https://github.com/org-roam/org-roam/pull/1327) preserve existing link description during automatic replacement +- [#1346](https://github.com/org-roam/org-roam/pull/1346) prevent malformed path to `org-roam-index-file` ## 1.2.3 (13-11-2020) diff --git a/org-roam.el b/org-roam.el index 445248e..a8b66d0 100644 --- a/org-roam.el +++ b/org-roam.el @@ -868,17 +868,14 @@ plist containing the path and title for the file." The path to the index can be defined in `org-roam-index-file'. Otherwise, it is assumed to be a note in `org-roam-directory' whose title is 'Index'." - (let* ((index org-roam-index-file) - (path (pcase index - ((pred functionp) (funcall index)) - ((pred stringp) index) - ('nil (user-error "You need to set `org-roam-index-file' before you can jump to it")) - (wrong-type (signal 'wrong-type-argument - `((functionp stringp) - ,wrong-type)))))) - (if (f-relative-p index) - (concat (expand-file-name org-roam-directory) path) - index))) + (let ((path (pcase org-roam-index-file + ((pred functionp) (funcall org-roam-index-file)) + ((pred stringp) org-roam-index-file) + ('nil (user-error "You need to set `org-roam-index-file' before you can jump to it")) + (wrong-type (signal 'wrong-type-argument + `((functionp stringp) + ,wrong-type)))))) + (expand-file-name path org-roam-directory))) ;;;; dealing with file-wide properties (defun org-roam--set-global-prop (name value)