org-footnote--collect-references: Fix infinite recursion
* lisp/org-footnote.el (org-footnote--collect-references): Fix infinite recursion when nested references form a closed loop. * testing/lisp/test-org-footnote.el (test-org-footnote/sort): New test. Reported-by: Avraham Pinkas <ampinkas@gmail.com> Link: https://orgmode.org/list/CAHEwkt8vnYGr1ZN-De9ec4bqBk_7yHARFAsZmY81u1GimSritA@mail.gmail.com
This commit is contained in:
parent
34a354f0fd
commit
4ff4828944
|
@ -404,7 +404,8 @@ References are sorted according to a deep-reading order."
|
|||
(dolist (r (mapcar (lambda (l) (assoc l references))
|
||||
(reverse
|
||||
(cdr (assoc (nth 0 ref) nested)))))
|
||||
(funcall add-reference r t))))))
|
||||
(unless (member r ordered) ; avoid infinite recursion when references link to each other
|
||||
(funcall add-reference r t)))))))
|
||||
(dolist (r (reverse references) (nreverse ordered))
|
||||
(funcall add-reference r nil))))))
|
||||
|
||||
|
|
|
@ -533,6 +533,26 @@ Text[fn:1][fn:4]
|
|||
\[fn:2] Def 2[fn:3]
|
||||
|
||||
\[fn:4] Def 4
|
||||
"
|
||||
(let ((org-footnote-section nil)) (org-footnote-sort))
|
||||
(buffer-string))))
|
||||
;; Handle cycles inside nested references
|
||||
(should
|
||||
(equal
|
||||
"
|
||||
One [fn:2] two [fn:1]
|
||||
|
||||
[fn:2] Two [fn:1]
|
||||
|
||||
[fn:1] One [fn:2]
|
||||
"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
One [fn:2] two [fn:1]
|
||||
|
||||
[fn:1] One [fn:2]
|
||||
|
||||
[fn:2] Two [fn:1]
|
||||
"
|
||||
(let ((org-footnote-section nil)) (org-footnote-sort))
|
||||
(buffer-string))))
|
||||
|
|
Loading…
Reference in New Issue