GNU bug report logs -
#2967
smart quotes in .emacs
Previous Next
Reported by: "Kit O'Connell" <vulpine <at> pobox.com>
Date: Sun, 12 Apr 2009 13:00:03 UTC
Severity: wishlist
Tags: fixed, patch
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
Message #24 received at 2967 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 2967 + patch
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
> Please include the character itself in the error message text.
>
> Also, are we sure these two are the only ones we want to catch in this
> manner?
I added some more likely looking ones from
https://en.wikipedia.org/wiki/Quotation_mark_glyphs.
> Finally, if this is accepted, let's have a test for this, and maybe
> also some documentation, at least in NEWS.
[v2-0001-Signal-error-for-symbol-names-with-strange-quotes.patch (text/x-diff, inline)]
From 438030f42698f347e38a9dea1561eedadd7e2edc Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 7 Jun 2017 19:59:09 -0400
Subject: [PATCH v2] Signal error for symbol names with strange quotes
(Bug#2967)
* src/lread.c (read1): Signal an error when a symbol starts with a
non-escaped quote-like character.
* test/src/lread-tests.el (lread-tests--funny-quote-symbols): New
test.
* etc/NEWS: Announce change.
---
etc/NEWS | 4 ++++
src/lread.c | 18 ++++++++++++++++++
test/src/lread-tests.el | 17 +++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index edb71118ef..d297d049d1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1110,6 +1110,10 @@ instead of its first.
renamed to 'lread--old-style-backquotes'. No user code should use
this variable.
+** To avoid confusion caused by "smart quotes", the reader no longer
+accepts Lisp symbols which begin with the following quotation
+characters: ‘’‛“”‟〞"', unless they are escaped with backslash.
+
+++
** Module functions are now implemented slightly differently; in
particular, the function 'internal--module-call' has been removed.
diff --git a/src/lread.c b/src/lread.c
index 901e40b348..dbaadce4b4 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3479,6 +3479,24 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
if (! NILP (result))
return unbind_to (count, result);
}
+ if (!quoted && multibyte)
+ {
+ int ch = STRING_CHAR ((unsigned char *) read_buffer);
+ switch (ch)
+ {
+ case 0x2018: /* LEFT SINGLE QUOTATION MARK */
+ case 0x2019: /* RIGHT SINGLE QUOTATION MARK */
+ case 0x201B: /* SINGLE HIGH-REVERSED-9 QUOTATION MARK */
+ case 0x201C: /* LEFT DOUBLE QUOTATION MARK */
+ case 0x201D: /* RIGHT DOUBLE QUOTATION MARK */
+ case 0x201F: /* DOUBLE HIGH-REVERSED-9 QUOTATION MARK */
+ case 0x301E: /* DOUBLE PRIME QUOTATION MARK */
+ case 0xFF02: /* FULLWIDTH QUOTATION MARK */
+ case 0xFF07: /* FULLWIDTH APOSTROPHE */
+ xsignal2 (Qinvalid_read_syntax, build_string ("strange quote"),
+ CALLN (Fstring, make_number (ch)));
+ }
+ }
{
Lisp_Object result;
ptrdiff_t nbytes = p - read_buffer;
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index a0a317feee..dd5a2003b4 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -142,6 +142,23 @@ (ert-deftest lread-tests--unescaped-char-literals ()
"unescaped character literals "
"`?\"', `?(', `?)', `?;', `?[', `?]' detected!")))))
+(ert-deftest lread-tests--funny-quote-symbols ()
+ "Check that 'smart quotes' or similar trigger errors in symbol names."
+ (dolist (quote-char
+ '(#x2018 ;; LEFT SINGLE QUOTATION MARK
+ #x2019 ;; RIGHT SINGLE QUOTATION MARK
+ #x201B ;; SINGLE HIGH-REVERSED-9 QUOTATION MARK
+ #x201C ;; LEFT DOUBLE QUOTATION MARK
+ #x201D ;; RIGHT DOUBLE QUOTATION MARK
+ #x201F ;; DOUBLE HIGH-REVERSED-9 QUOTATION MARK
+ #x301E ;; DOUBLE PRIME QUOTATION MARK
+ #xFF02 ;; FULLWIDTH QUOTATION MARK
+ #xFF07 ;; FULLWIDTH APOSTROPHE
+ ))
+ (let ((str (format "%cfoo" quote-char)))
+ (should-error (read str) :type 'invalid-read-syntax)
+ (should (eq (read (concat "\\" str)) (intern str))))))
+
(ert-deftest lread-test-bug26837 ()
"Test for http://debbugs.gnu.org/26837 ."
(let ((load-path (cons
--
2.11.1
This bug report was last modified 7 years and 361 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.