* [PATCH] Org-bibtex: checking string length in org-bibtex-read before using aref
@ 2014-02-21 16:27 Stefan-W. Hahn
2014-02-24 16:36 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Stefan-W. Hahn @ 2014-02-21 16:27 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
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.
[-- Attachment #2: 0001-PATCH-Org-bibtex-checking-string-length-in-org-bibte.patch --]
[-- Type: text/x-diff, Size: 1240 bytes --]
From e5fa86104d94e69575d6c4ff54d0aa41b7083440 Mon Sep 17 00:00:00 2001
From: "Stefan-W. Hahn" <stefan.hahn@s-hahn.de>
Date: Fri, 21 Feb 2014 17:19:39 +0100
Subject: [PATCH] [PATCH] Org-bibtex: checking string length in org-bibtex-read
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.
TINY CHANGE.
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
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 (= (aref str 0) (car pair))
+ (when (and (> (length str) 0)
+ (= (aref str 0) (car pair))
(= (aref str (1- (length str))) (cdr pair)))
(setf str (substring str 1 (1- (length str)))))) str)))
(push (mapcar
--
1.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Org-bibtex: checking string length in org-bibtex-read before using aref
2014-02-21 16:27 [PATCH] Org-bibtex: checking string length in org-bibtex-read before using aref Stefan-W. Hahn
@ 2014-02-24 16:36 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2014-02-24 16:36 UTC (permalink / raw)
To: Stefan-W. Hahn; +Cc: emacs-orgmode
Hello,
"Stefan-W. Hahn" <info@s-hahn.de> writes:
> 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.
Applied (with a tiny change). Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-24 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21 16:27 [PATCH] Org-bibtex: checking string length in org-bibtex-read before using aref Stefan-W. Hahn
2014-02-24 16:36 ` Nicolas Goaziou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).