1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Fix input of sharp-quoted symbols in Eshell with em-extpipe

* lisp/eshell/em-extpipe.el (eshell-parse-external-pipeline): Fix
misinterpreting sharp-quoted symbols as the beginning of single-quoted
strings (Bug#53518).  Add protection against a possible infinite loop.
* test/lisp/eshell/em-extpipe-tests.el (em-extpipe-test-17): New
test (bug#53518).
This commit is contained in:
Sean Whitton 2022-01-26 14:13:00 +01:00 committed by Lars Ingebrigtsen
parent fc8875be07
commit afd1fdf6bb
2 changed files with 14 additions and 3 deletions

View file

@ -30,6 +30,7 @@
(require 'cl-lib)
(require 'esh-arg)
(require 'esh-cmd)
(require 'esh-io)
(require 'esh-util)
@ -97,15 +98,21 @@ as though it were Eshell syntax."
(while (> bound (point))
(let* ((found
(save-excursion
(re-search-forward "['\"\\]" bound t)))
(re-search-forward
"\\(?:#?'\\|\"\\|\\\\\\)" bound t)))
(next (or (and found (match-beginning 0))
bound)))
(if (re-search-forward pat next t)
(throw 'found (match-beginning 1))
(goto-char next)
(while (or (eshell-parse-backslash)
(while (or (eshell-parse-lisp-argument)
(eshell-parse-backslash)
(eshell-parse-double-quote)
(eshell-parse-literal-quote)))))))))
(eshell-parse-literal-quote)))
;; Guard against an infinite loop if none of
;; the parsers moved us forward.
(unless (or (> (point) next) (eobp))
(forward-char 1))))))))
(goto-char (if (and result go) (match-end 0) start))
result)))
(unless (or eshell-current-argument eshell-current-quoted)

View file

@ -202,4 +202,8 @@
(eshell-command-result-p input "rab")
(eshell-command-result-p "echo \"bar\" | rev" "nonsense"))))
;; Confirm we don't break input of sharp-quoted symbols (Bug#53518).
(em-extpipe-tests--deftest em-extpipe-test-17 "funcall #'upcase foo"
(eshell-command-result-p input "FOO"))
;;; em-extpipe-tests.el ends here