unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: mark.lillibridge@hp.com
Cc: 7746@debbugs.gnu.org
Subject: bug#7746: SERIOUS BUG: mail-strip-quoted-names bug causing unrmail to lose mail
Date: Sat, 01 Jan 2011 22:21:18 -0500	[thread overview]
Message-ID: <jwvfwtc6lua.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <qmhoc8692en.fsf@hp.com> (Mark Lillibridge's message of "Mon, 27 Dec 2010 16:17:20 -0800")

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)






  parent reply	other threads:[~2011-01-02  3:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-28  0:17 bug#7746: SERIOUS BUG: mail-strip-quoted-names bug causing unrmail to lose mail Mark Lillibridge
2011-01-02  2:43 ` Glenn Morris
2011-01-02  3:21 ` Stefan Monnier [this message]
2011-01-03  0:18   ` Mark Lillibridge
2011-01-03  3:36     ` Stefan Monnier
2011-01-03  4:13       ` Mark Lillibridge
2011-01-03 19:17         ` Mark Lillibridge
2011-01-05 21:32           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvfwtc6lua.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=7746@debbugs.gnu.org \
    --cc=mark.lillibridge@hp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).