diff options
| author | Mattias Engdegård | 2019-02-15 19:27:48 +0100 |
|---|---|---|
| committer | Mattias Engdegård | 2019-02-16 12:43:32 +0100 |
| commit | 478bbf7c80e71ff84f0e4e1363bf86e93d9c51c3 (patch) | |
| tree | 7d05c376a0299282d291eff879eedcc6f3d2651d /test | |
| parent | aff0c585060b7cc92d52a32978c6aa64cf7e2a5e (diff) | |
| download | emacs-478bbf7c80e71ff84f0e4e1363bf86e93d9c51c3.tar.gz emacs-478bbf7c80e71ff84f0e4e1363bf86e93d9c51c3.zip | |
Prevent over-eager rx character range condensation
`rx' incorrectly considers character ranges between ASCII and raw bytes to
cover all codes in-between, which includes all non-ASCII Unicode chars.
This causes (any "\000-\377" ?Å) to be simplified to (any "\000-\377"),
which is not at all the same thing: [\000-\377] really means
[\000-\177\200-\377] (Bug#34492).
* lisp/emacs-lisp/rx.el (rx-any-condense-range): Split ranges going
from ASCII to raw bytes.
* test/lisp/emacs-lisp/rx-tests.el (rx-char-any-raw-byte): Add test case.
* etc/NEWS: Mention the overall change (Bug#33205).
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index f15e1016f7c..e14feda347f 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -53,7 +53,11 @@ | |||
| 53 | ;; Range of raw characters, multibyte. | 53 | ;; Range of raw characters, multibyte. |
| 54 | (should (equal (string-match-p (rx (any "Å\211\326-\377\177")) | 54 | (should (equal (string-match-p (rx (any "Å\211\326-\377\177")) |
| 55 | "XY\355\177\327") | 55 | "XY\355\177\327") |
| 56 | 2))) | 56 | 2)) |
| 57 | ;; Split range; \177-\377ÿ should not be optimised to \177-\377. | ||
| 58 | (should (equal (string-match-p (rx (any "\177-\377" ?ÿ)) | ||
| 59 | "ÿA\310B") | ||
| 60 | 0))) | ||
| 57 | 61 | ||
| 58 | (ert-deftest rx-pcase () | 62 | (ert-deftest rx-pcase () |
| 59 | (should (equal (pcase "a 1 2 3 1 1 b" | 63 | (should (equal (pcase "a 1 2 3 1 1 b" |