Check validity of rx submatch-n number

* lisp/emacs-lisp/rx.el (rx-submatch): Type and range check (Bug#34373).
This commit is contained in:
Mattias Engdegård 2019-02-07 19:05:06 +01:00
parent 866f527ddf
commit 2eafb4af55

View file

@ -725,6 +725,8 @@ FORM is either `(repeat N FORM1)' or `(repeat N M FORMS...)'."
(defun rx-submatch-n (form)
"Parse and produce code from FORM, which is `(submatch-n N ...)'."
(let ((n (nth 1 form)))
(unless (and (integerp n) (> n 0))
(error "rx `submatch-n' argument must be positive"))
(concat "\\(?" (number-to-string n) ":"
(if (= 3 (length form))
;; Only one sub-form.