[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] elpa d418e9a 15/51: Prevent infinite loop in TeX-command-expand
From: |
Tassilo Horn |
Subject: |
[elpa] elpa d418e9a 15/51: Prevent infinite loop in TeX-command-expand |
Date: |
Sun, 22 May 2016 07:22:48 +0000 (UTC) |
branch: elpa
commit d418e9a064e4158556dacb33744d610097eff04b
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
Prevent infinite loop in TeX-command-expand
* tex.el (TeX-view-command-raw): This function should always return a
string. Throw an error if fails to do so. This prevents an infinite
loop in `TeX-command-expand' in the case in which `command' is nil
because of a malformed viewer specification.
* tests/tex/command-expansion.el (TeX-view-command-raw-errors): Add
tests to trigger errors in `TeX-view-command-raw'.
---
tests/tex/command-expansion.el | 43 ++++++++++++++++++++++++++++++++++++++++
tex.el | 6 +++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index d6dfc89..ebdb6d1 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -33,4 +33,47 @@
'TeX-master-file))
"%% \"\\input\"")))
+(ert-deftest TeX-view-command-raw-errors ()
+ "Tests to trigger errors in `TeX-view-command-raw'."
+ ;; Viewer specification should be either a command line string or a Lisp
+ ;; function name to be executed. This test makes sure that the functions
+ ;; throws an error if the selected viewer has a wrong specification (for
+ ;; example a function call, not the function name) such that the returned
+ ;; value `command' isn't a string. This prevents an infinite loop in
+ ;; `TeX-command-expand'.
+ (should-error
+ (with-temp-buffer
+ (let ((TeX-view-program-list '(("viewer"
+ (wrong-specification))))
+ (TeX-view-program-selection
+ '((output-pdf "viewer"))))
+ (TeX-mode)
+ (TeX-view-command-raw)))
+ :type 'error)
+ ;; Signal an error when a nonexistent viewer is selected.
+ (should-error
+ (with-temp-buffer
+ (let ((TeX-view-program-selection
+ '((output-pdf "does-not-exist"))))
+ (TeX-mode)
+ (TeX-view-command-raw)))
+ :type 'error)
+ ;; Signal an error if the binary associated to the viewer cannot be found.
+ (should-error
+ (with-temp-buffer
+ (let ((TeX-view-program-list
+ '(("viewer" "viewer %o" "**this-program-does-not-exist**")))
+ (TeX-view-program-selection
+ '((output-pdf "viewer"))))
+ (TeX-mode)
+ (TeX-view-command-raw)))
+ :type 'error)
+ ;; Error if there is no selected viewer for current buffer.
+ (should-error
+ (with-temp-buffer
+ (let (TeX-view-program-selection)
+ (TeX-mode)
+ (TeX-view-command-raw)))
+ :type 'error))
+
;;; command-expansion.el ends here
diff --git a/tex.el b/tex.el
index f7b5bc4..fb734f4 100644
--- a/tex.el
+++ b/tex.el
@@ -1598,7 +1598,11 @@ Check the `TeX-view-program-selection' variable"
viewer)))
((listp elt)
(when (TeX-view-match-predicate (car elt))
(setq command (concat command (cadr elt)))))))
- command))))
+ (if (stringp command)
+ command
+ ;; Signal an error if `command' isn't a string. This prevents an
+ ;; infinite loop in `TeX-command-expand' if `command' is nil.
+ (error "Wrong viewer specification in
`TeX-view-program-list'"))))))
;;; Engine
- [elpa] elpa 88fbf80 20/51: Fix in TeX sentinels, (continued)
- [elpa] elpa 88fbf80 20/51: Fix in TeX sentinels, Tassilo Horn, 2016/05/22
- [elpa] elpa 693eee6 11/51: TikZ: Remove unneeded function., Tassilo Horn, 2016/05/22
- [elpa] elpa b20cd68 16/51: Fix a documentation type., Tassilo Horn, 2016/05/22
- [elpa] elpa 71349ec 23/51: Use `deactivate-input-method' if defined, Tassilo Horn, 2016/05/22
- [elpa] elpa d4d2ab5 31/51: Enable directory local variables in japanese-{latex, plain-tex}-mode, Tassilo Horn, 2016/05/22
- [elpa] elpa 63a83c3 30/51: Make unloading of tex-site work on Emacs 24, Tassilo Horn, 2016/05/22
- [elpa] elpa 5886c49 41/51: Improve the insertation of "macro" environment, Tassilo Horn, 2016/05/22
- [elpa] elpa e19f8bd 37/51: Do not check TeX engine with ifluatex package, Tassilo Horn, 2016/05/22
- [elpa] elpa 79a8643 47/51: Respect both "xcolor" and "color" for command queries, Tassilo Horn, 2016/05/22
- [elpa] elpa ccfe316 42/51: Make TeX-view work better with regions, Tassilo Horn, 2016/05/22
- [elpa] elpa d418e9a 15/51: Prevent infinite loop in TeX-command-expand,
Tassilo Horn <=
- [elpa] elpa 4f9666b 24/51: Use customize option `TeX-region' instead of "_region_", Tassilo Horn, 2016/05/22
- [elpa] elpa a83c4d0 02/51: Fix compatibility with older Emacs versions, Tassilo Horn, 2016/05/22
- [elpa] elpa 13153ba 40/51: Use commit date for package date also in configure, Tassilo Horn, 2016/05/22
- [elpa] elpa 7fc63f1 39/51: Tweak mode name only when file local variable is enabled., Tassilo Horn, 2016/05/22
- [elpa] elpa 7e3bec8 44/51: Run `TeX-add-symbols' if "xcolor" is not an active style, Tassilo Horn, 2016/05/22
- [elpa] elpa f0849b4 10/51: TikZ: Add the 'sin' and 'cos' connectors., Tassilo Horn, 2016/05/22
- [elpa] elpa 7ea1aa3 18/51: TikZ: Don't allow relative points with \coordinate., Tassilo Horn, 2016/05/22
- [elpa] elpa c032063 19/51: Auto save `TeX-command-extra-options'., Tassilo Horn, 2016/05/22
- [elpa] elpa 56c1afd 28/51: Call TeX-newline-function interactively, Tassilo Horn, 2016/05/22
- [elpa] elpa eb9986d 46/51: Respect both "xcolor" and "color" for query to "shadecolor", Tassilo Horn, 2016/05/22