From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#2967: smart quotes in .emacs Date: Sun, 16 Jul 2017 20:49:39 -0400 Message-ID: <87shhvc2fw.fsf@users.sourceforge.net> References: <498421570904120553o69ee009dj544e0866b434b8a3@mail.gmail.com> <87ink8xxw7.fsf@users.sourceforge.net> <83vao88jud.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1500252560 30001 195.159.176.226 (17 Jul 2017 00:49:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Jul 2017 00:49:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 2967@debbugs.gnu.org, monnier@iro.umontreal.ca, acm@muc.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 17 02:49:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dWuDl-00072B-II for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Jul 2017 02:49:09 +0200 Original-Received: from localhost ([::1]:47367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWuDo-00087p-1Z for geb-bug-gnu-emacs@m.gmane.org; Sun, 16 Jul 2017 20:49:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWuDh-00086f-8E for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2017 20:49:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWuDe-0001q4-64 for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2017 20:49:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWuDe-0001pz-1c for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2017 20:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dWuDd-0005Xr-R7 for bug-gnu-emacs@gnu.org; Sun, 16 Jul 2017 20:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jul 2017 00:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 2967 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 2967-submit@debbugs.gnu.org id=B2967.150025249421258 (code B ref 2967); Mon, 17 Jul 2017 00:49:01 +0000 Original-Received: (at 2967) by debbugs.gnu.org; 17 Jul 2017 00:48:14 +0000 Original-Received: from localhost ([127.0.0.1]:42904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dWuCs-0005Wj-29 for submit@debbugs.gnu.org; Sun, 16 Jul 2017 20:48:14 -0400 Original-Received: from mail-io0-f178.google.com ([209.85.223.178]:34673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dWuCq-0005WR-24; Sun, 16 Jul 2017 20:48:12 -0400 Original-Received: by mail-io0-f178.google.com with SMTP id r36so35806528ioi.1; Sun, 16 Jul 2017 17:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=x0hTc/usTeLjyBEcWGDlfrbIj1x5eZn8SQ2bun7aQ8g=; b=Z0YdLqhtMOvCupn9+RoDIJMon3UuQHzddKtW3+CrSZfL8tWxE5NlqnGPZ7bU+S6s5q KTdDgTskzmyueocGmYBSmOWB0QKVFRD1lKbkU3FEAN3VqWFXZFRCd3TBSezUubsnZ4ZA w2ccg2ntRx1ZtBW3Q8whKfdDyZCq9jdxYepY3SX4LqCKgqYv5ad4bwnLWoaAe+gr1BFH EXmVVzDcpdd8EExsgZ/p1bAuWtQyAcrQ0p9hwyBedJ+IkWjoSNkojG8BNlE9FsRp4Kgp 8QrGOLudD3ao2HEY5bE5t2Fl3Cadp6pvLnNdU0Rf+6/Gtw45ilzwCCPnv2EUm5Zob24L CLeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=x0hTc/usTeLjyBEcWGDlfrbIj1x5eZn8SQ2bun7aQ8g=; b=e9rpQqQaw3JfIGYTQHgnPi5edfDDS9YemUM6HCiTP9wlL7F81E7Pks2sd1tc7PStCR kcyuoBGl/knk9Y9jbMkX4f/FDysqF1zl428ha0eiB7AaesGNZAtBpFwTBC28sPafrgsZ pxG6HLX6SX2aRix+XNjcIaQTkqUY5Yp0G15VhGFALglY3qeGo+XkYqACp9q4Xj915D9B hx1x8Gv9wxWO+QNXbF5teG8S+QZy310Z3E+2LuKVRPeSnMgUd+xM50mec6S0MaFC3Pee I+HJwcZGrd6l7F+xoa04Ei8o4zTG2mIv0DR0skcir5cfcDJ4tS3wa8rEN4wgLTJjQqq/ /Y7g== X-Gm-Message-State: AIVw111Mwi3A2EoNSPyYrVZ16BgYlY8bARXzUF3os3y3tw+2EQr1t4gB QZgIazsHpn/7CxIz X-Received: by 10.107.178.23 with SMTP id b23mr17254146iof.79.1500252486521; Sun, 16 Jul 2017 17:48:06 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id 125sm4920977itz.7.2017.07.16.17.48.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Jul 2017 17:48:05 -0700 (PDT) In-Reply-To: <83vao88jud.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 07 Jun 2017 08:09:30 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134646 Archived-At: --=-=-= Content-Type: text/plain tags 2967 + patch quit Eli Zaretskii 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. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=v2-0001-Signal-error-for-symbol-names-with-strange-quotes.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch >From 438030f42698f347e38a9dea1561eedadd7e2edc Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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. =20 +** To avoid confusion caused by "smart quotes", the reader no longer +accepts Lisp symbols which begin with the following quotation +characters: =E2=80=98=E2=80=99=E2=80=9B=E2=80=9C=E2=80=9D=E2=80=9F=E3=80= =9E=EF=BC=82=EF=BC=87, 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 =3D 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 quo= te"), + CALLN (Fstring, make_number (ch))); + } + } { Lisp_Object result; ptrdiff_t nbytes =3D 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!"= ))))) =20 +(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 --=20 2.11.1 --=-=-=--