summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHarald Jörg <haj@posteo.de>2024-03-08 00:37:36 +0100
committerHarald Jörg <haj@posteo.de>2024-03-08 00:41:32 +0100
commit00f86833ac5423d57825213ef8b611978be0a3eb (patch)
treef25e8cc5a730498a0c9991ba98ea9074ae19628a /test
parente42f14f0e034d0b20c6b9fd0fea23686699e7df0 (diff)
downloademacs-00f86833ac5423d57825213ef8b611978be0a3eb.tar.gz
; perl-mode, cperl-mode: Fix $\" in strings (Bug#69604)
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function): Add to syntax-propertize-rules that $ is punctuation in strings. * lisp/progmodes/cperl-mode.el (cperl-find-pods-heres): capture $\ to catch the edge case of "$\"". Make $ a punctuation char in strings and comments. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-69604): New testcases with various combinations of $ " \
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
index 62b7fdab7f7..9d9718f719c 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -1431,6 +1431,25 @@ cperl-mode fontifies text after the delimiter as Perl code."
(should (equal (get-text-property (point) 'face)
font-lock-comment-face))))
+(ert-deftest cperl-test-bug-69604 ()
+ "Verify that $\" in a double-quoted string does not end the string.
+Both `perl-mode' and `cperl-mode' treat ?$ as a quoting/escaping char to
+avoid issues with punctuation variables. In a string, however, this is
+not appropriate."
+ (let ((strings
+ '("\"$\\\" in string ---\"; # \"" ; $ must not quote \
+ "$\" . \" in string ---\"; # \"" ; $ must quote \
+ "\"\\$\" . \" in string ---\"; # \""))) ; \$ must not quote
+ (dolist (string strings)
+ (with-temp-buffer
+ (insert string)
+ (funcall cperl-test-mode)
+ (font-lock-ensure)
+ (goto-char (point-min))
+ (search-forward "in string")
+ (should (equal (get-text-property (point) 'face)
+ font-lock-string-face))))))
+
(ert-deftest test-indentation ()
(ert-test-erts-file (ert-resource-file "cperl-indents.erts")))