[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 892db04: Fix rx `regexp` form with deprecated syntax
From: |
Mattias Engdegård |
Subject: |
master 892db04: Fix rx `regexp` form with deprecated syntax |
Date: |
Thu, 18 Feb 2021 05:54:37 -0500 (EST) |
branch: master
commit 892db042a0d85caeea9a4969073e13f525eb9f60
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Fix rx `regexp` form with deprecated syntax
The argument of the rx `regexp` form is assumed to evaluate to a valid
regexp, but certain kinds of deprecated but still accepted usage were
not handled correctly, such as unescaped literal (special) characters:
(rx "a" (regexp "*")) => "a*" which is wrong.
Handle these cases; there is no extra trouble.
* lisp/emacs-lisp/rx.el (rx--translate-regexp): Force bracketing
of single special characters.
* test/lisp/emacs-lisp/rx-tests.el (rx-regexp): Add test case.
---
lisp/emacs-lisp/rx.el | 2 +-
test/lisp/emacs-lisp/rx-tests.el | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index b29b870..58584f3 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -890,7 +890,7 @@ Return (REGEXP . PRECEDENCE)."
(* (or (seq "[:" (+ (any "a-z")) ":]")
(not (any "]"))))
"]")
- anything
+ (not (any "*+?^$[\\"))
(seq "\\"
(or anything
(seq (any "sScC_") anything)
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 63d7c7b..388c5e8 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -391,6 +391,8 @@
(let ((x "a*"))
(should (equal (rx (regexp x) "b")
"\\(?:a*\\)b"))
+ (should (equal (rx "a" (regexp "*"))
+ "a\\(?:*\\)"))
(should (equal (rx "" (regexp x) (eval ""))
"a*"))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 892db04: Fix rx `regexp` form with deprecated syntax,
Mattias Engdegård <=