fix(evil): add error handling for :h[elp] ex command

apropos throws up an arith-error trying to rank the results of matchless
regexp (which can result in a segfault on some systems; see #8532), and
is *incredibly* slow lookuping up short queries, so the command will now
abort if the query is just a regexp operator or less than 3 characters
long.

Fix: #8532
This commit is contained in:
Henrik Lissner
2025-09-26 12:15:59 -04:00
parent 24f9918694
commit c63b207e4f

View File

@@ -182,6 +182,13 @@ non-nil, a search is preformed against Doom's manual (with
(funcall (or (command-remapping #'describe-function) (funcall (or (command-remapping #'describe-function)
#'describe-function) #'describe-function)
(evil-ex-completed-binding (match-string 1 query)))) (evil-ex-completed-binding (match-string 1 query))))
((or (string-match "^ *[^a-z0-9-_]$" query)
(condition-case nil
(ignore (string-match-p query ""))
(invalid-regexp t)))
(user-error "Invalid query: %S" query))
((< (string-width query) 3)
(user-error "Query too short (must be > 2 characters): %S" query))
((message "Searching for %S, this may take a while..." query) ((message "Searching for %S, this may take a while..." query)
(apropos query t)))))) (apropos query t))))))