From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#7746: SERIOUS BUG: mail-strip-quoted-names bug causing unrmail to lose mail Date: Sat, 01 Jan 2011 22:21:18 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1293938643 10110 80.91.229.12 (2 Jan 2011 03:24:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 2 Jan 2011 03:24:03 +0000 (UTC) Cc: 7746@debbugs.gnu.org To: mark.lillibridge@hp.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 02 04:23:59 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PZEY2-0007us-EV for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Jan 2011 04:23:58 +0100 Original-Received: from localhost ([127.0.0.1]:57019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZEY1-0002EM-Lp for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Jan 2011 22:23:57 -0500 Original-Received: from [140.186.70.92] (port=56986 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZEXp-0002Af-FQ for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 22:23:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZEXo-0002az-2O for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 22:23:45 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZEXo-0002av-0a for bug-gnu-emacs@gnu.org; Sat, 01 Jan 2011 22:23:44 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PZEPO-0006jZ-Ni; Sat, 01 Jan 2011 22:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Jan 2011 03:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7746 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7746-submit@debbugs.gnu.org id=B7746.129393805925815 (code B ref 7746); Sun, 02 Jan 2011 03:15:02 +0000 Original-Received: (at 7746) by debbugs.gnu.org; 2 Jan 2011 03:14:19 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZEOg-0006iJ-JS for submit@debbugs.gnu.org; Sat, 01 Jan 2011 22:14:18 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZEOe-0006i3-Sq; Sat, 01 Jan 2011 22:14:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqkFAHJ9H01Ld/TY/2dsb2JhbACWK44cdLtBgnOCVwSEZY4b X-IronPort-AV: E=Sophos;i="4.60,261,1291611600"; d="scan'208";a="86887982" Original-Received: from 75-119-244-216.dsl.teksavvy.com (HELO pastel.home) ([75.119.244.216]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 01 Jan 2011 22:21:18 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 88B8758DFC; Sat, 1 Jan 2011 22:21:18 -0500 (EST) In-Reply-To: (Mark Lillibridge's message of "Mon, 27 Dec 2010 16:17:20 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 01 Jan 2011 22:15:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42996 Archived-At: close 7746 thanks > This code erases the buffer " *temp*" even if it is being used by > another piece of code! This is particularly bad because this is the > first buffer used by with-temp-buffer. Indeed, that's wrong, thanks for spotting it. I've installed your suggested patch (see below) into the emacs-23 branch (for Emacs-23.3). BTW, I'm wondering why the code handles nesting in this way. Can you try the second patch below (you may need to hand-apply it since it's based on the new code I just installed), to confirm that it works just as well? Stefan --- lisp/mail/mail-utils.el 2010-10-09 00:41:03 +0000 +++ lisp/mail/mail-utils.el 2011-01-02 03:03:38 +0000 @@ -189,8 +189,7 @@ ;; Detect nested comments. (if (string-match "[ \t]*(\\([^)\\]\\|\\\\.\\|\\\\\n\\)*(" address) ;; Strip nested comments. - (with-current-buffer (get-buffer-create " *temp*") - (erase-buffer) + (with-temp-buffer (insert address) (set-syntax-table lisp-mode-syntax-table) (goto-char 1) @@ -203,8 +202,7 @@ (forward-sexp 1) (error (goto-char (point-max)))) (point)))) - (setq address (buffer-string)) - (erase-buffer)) + (setq address (buffer-string))) ;; Strip non-nested comments an easier way. (while (setq pos (string-match ;; This doesn't hack rfc822 nested comments Second patch to simplify the code: === modified file 'lisp/mail/mail-utils.el' --- lisp/mail/mail-utils.el 2011-01-02 03:16:03 +0000 +++ lisp/mail/mail-utils.el 2011-01-02 03:19:53 +0000 @@ -186,30 +186,13 @@ (mapconcat 'identity (rfc822-addresses address) ", ")) (let (pos) - ;; Detect nested comments. - (if (string-match "[ \t]*(\\([^)\\]\\|\\\\.\\|\\\\\n\\)*(" address) - ;; Strip nested comments. - (with-temp-buffer - (insert address) - (set-syntax-table lisp-mode-syntax-table) - (goto-char 1) - (while (search-forward "(" nil t) - (forward-char -1) - (skip-chars-backward " \t") - (delete-region (point) - (save-excursion - (condition-case () - (forward-sexp 1) - (error (goto-char (point-max)))) - (point)))) - (setq address (buffer-string))) - ;; Strip non-nested comments an easier way. + ;; Strip comments. (while (setq pos (string-match ;; This doesn't hack rfc822 nested comments ;; `(xyzzy (foo) whinge)' properly. Big deal. - "[ \t]*(\\([^)\\]\\|\\\\.\\|\\\\\n\\)*)" + "[ \t]*(\\([^()\\]\\|\\\\.\\|\\\\\n\\)*)" address)) - (setq address (replace-match "" nil nil address 0)))) + (setq address (replace-match "" nil nil address 0))) ;; strip surrounding whitespace (string-match "\\`[ \t\n]*" address)