Browse Source

org-bibtex: Fix `org-bibtex-read' on an empty field

* lisp/org-bibtex.el (org-bibtex-read): Check string length before
  using aref.

If a field in a bibtex entry is empty:

@article(test,
   description = "")

the function org-bibtex-read throws an exception because of
using aref on this empty string.

The solution is to check the length of the string before.

TINYCHANGE

Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
Stefan-W. Hahn 7 years ago
parent
commit
2e72176e21
1 changed files with 2 additions and 1 deletions
  1. 2 1
      lisp/org-bibtex.el

+ 2 - 1
lisp/org-bibtex.el

@@ -613,7 +613,8 @@ This uses `bibtex-parse-entry'."
 	(strip-delim
 	 (lambda (str)	     ; strip enclosing "..." and {...}
 	   (dolist (pair '((34 . 34) (123 . 125) (123 . 125)))
-	     (when (and (= (aref str 0) (car pair))
+	     (when (and (> (length str) 1)
+			(= (aref str 0) (car pair))
 			(= (aref str (1- (length str))) (cdr pair)))
 	       (setf str (substring str 1 (1- (length str)))))) str)))
     (push (mapcar