From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Stefan-W. Hahn" Subject: [PATCH] Org-bibtex: checking string length in org-bibtex-read before using aref Date: Fri, 21 Feb 2014 17:27:59 +0100 Message-ID: <20140221162758.GT7560@pille.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="lc9FT7cWel8HagAv" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGsxV-0006nV-Ci for emacs-orgmode@gnu.org; Fri, 21 Feb 2014 11:28:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGsxP-0006HE-2t for emacs-orgmode@gnu.org; Fri, 21 Feb 2014 11:28:17 -0500 Received: from moutng.kundenserver.de ([212.227.17.8]:60987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGsxO-0006Ge-PS for emacs-orgmode@gnu.org; Fri, 21 Feb 2014 11:28:11 -0500 Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --lc9FT7cWel8HagAv Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Good afternoon, I have a problem with org-bibtex function org-bibtex-read if I have an empty field in a bibitem like this: @article(test, description = "") In this case the "aref" gives an exception. I would like to suggest the attached following fix. With kind regards, Stefan -- Stefan-W. Hahn It is easy to make things. It is hard to make things simple. --lc9FT7cWel8HagAv Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-PATCH-Org-bibtex-checking-string-length-in-org-bibte.patch" Content-Transfer-Encoding: quoted-printable =46rom e5fa86104d94e69575d6c4ff54d0aa41b7083440 Mon Sep 17 00:00:00 2001 =46rom: "Stefan-W. Hahn" Date: Fri, 21 Feb 2014 17:19:39 +0100 Subject: [PATCH] [PATCH] Org-bibtex: checking string length in org-bibtex-r= ead before using aref If a field in a bibtex entry is empty: @article(test, description =3D "") 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. TINY CHANGE. Signed-off-by: Stefan-W. Hahn --- lisp/org-bibtex.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el index b4e6977..7571169 100644 --- a/lisp/org-bibtex.el +++ b/lisp/org-bibtex.el @@ -613,7 +613,8 @@ (defun org-bibtex-read () (strip-delim (lambda (str) ; strip enclosing "..." and {...} (dolist (pair '((34 . 34) (123 . 125) (123 . 125))) - (when (and (=3D (aref str 0) (car pair)) + (when (and (> (length str) 0) + (=3D (aref str 0) (car pair)) (=3D (aref str (1- (length str))) (cdr pair))) (setf str (substring str 1 (1- (length str)))))) str))) (push (mapcar --=20 1.9.0 --lc9FT7cWel8HagAv--