aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-09-14 01:23:25 +0200
committerLars Ingebrigtsen2020-09-14 01:23:25 +0200
commit1749d32d027da2d3c52301bd84a4dcfb70694d51 (patch)
treed5cacaf67aa463e537fe24abd1a936fe1861359c
parent9cc992e68ff7c37420f3d9dd5fa73bc9525e4c2a (diff)
downloademacs-1749d32d027da2d3c52301bd84a4dcfb70694d51.tar.gz
emacs-1749d32d027da2d3c52301bd84a4dcfb70694d51.zip
Fix up report-emacs-bug action on invalid From headers
* lisp/mail/emacsbug.el (report-emacs-bug-hook): Move point to the From header if the user has to edit the From header.
-rw-r--r--lisp/mail/emacsbug.el112
1 files changed, 57 insertions, 55 deletions
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index db85b64cc8d..db374f15c27 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -416,67 +416,69 @@ usually do not have translators for other languages.\n\n")))
416 416
417(defun report-emacs-bug-hook () 417(defun report-emacs-bug-hook ()
418 "Do some checking before sending a bug report." 418 "Do some checking before sending a bug report."
419 (save-excursion 419 (goto-char (point-max))
420 (goto-char (point-max)) 420 (skip-chars-backward " \t\n")
421 (skip-chars-backward " \t\n") 421 (and (= (- (point) (point-min))
422 (and (= (- (point) (point-min)) 422 (length report-emacs-bug-orig-text))
423 (length report-emacs-bug-orig-text)) 423 (string-equal (buffer-substring-no-properties (point-min) (point))
424 (string-equal (buffer-substring-no-properties (point-min) (point)) 424 report-emacs-bug-orig-text)
425 report-emacs-bug-orig-text) 425 (error "No text entered in bug report"))
426 (error "No text entered in bug report")) 426 ;; Warning for novice users.
427 ;; Warning for novice users. 427 (when (and (string-match "bug-gnu-emacs@gnu\\.org" (mail-fetch-field "to"))
428 (when (and (string-match "bug-gnu-emacs@gnu\\.org" (mail-fetch-field "to")) 428 (not report-emacs-bug-no-confirmation)
429 (not report-emacs-bug-no-confirmation) 429 (not (yes-or-no-p
430 (not (yes-or-no-p 430 "Send this bug report to the Emacs maintainers? ")))
431 "Send this bug report to the Emacs maintainers? "))) 431 (with-output-to-temp-buffer "*Bug Help*"
432 (with-output-to-temp-buffer "*Bug Help*" 432 (princ (substitute-command-keys
433 (princ (substitute-command-keys 433 (format "\
434 (format "\
435You invoked the command M-x report-emacs-bug, 434You invoked the command M-x report-emacs-bug,
436but you decided not to mail the bug report to the Emacs maintainers. 435but you decided not to mail the bug report to the Emacs maintainers.
437 436
438If you want to mail it to someone else instead, 437If you want to mail it to someone else instead,
439please insert the proper e-mail address after \"To: \", 438please insert the proper e-mail address after \"To: \",
440and send the mail again%s." 439and send the mail again%s."
441 (if report-emacs-bug-send-command 440 (if report-emacs-bug-send-command
442 (format " using \\[%s]" 441 (format " using \\[%s]"
443 report-emacs-bug-send-command) 442 report-emacs-bug-send-command)
444 ""))))) 443 "")))))
445 (error "M-x report-emacs-bug was canceled, please read *Bug Help* buffer")) 444 (error "M-x report-emacs-bug was canceled, please read *Bug Help* buffer"))
446 ;; Query the user for the SMTP method, so that we can skip 445 ;; Query the user for the SMTP method, so that we can skip
447 ;; questions about From header validity if the user is going to 446 ;; questions about From header validity if the user is going to
448 ;; use mailclient, anyway. 447 ;; use mailclient, anyway.
449 (when (or (and (derived-mode-p 'message-mode) 448 (when (or (and (derived-mode-p 'message-mode)
450 (eq message-send-mail-function 'sendmail-query-once)) 449 (eq message-send-mail-function 'sendmail-query-once))
451 (and (not (derived-mode-p 'message-mode)) 450 (and (not (derived-mode-p 'message-mode))
452 (eq send-mail-function 'sendmail-query-once))) 451 (eq send-mail-function 'sendmail-query-once)))
453 (sendmail-query-user-about-smtp) 452 (sendmail-query-user-about-smtp)
454 (when (derived-mode-p 'message-mode) 453 (when (derived-mode-p 'message-mode)
455 (setq message-send-mail-function (message-default-send-mail-function)))) 454 (setq message-send-mail-function (message-default-send-mail-function))))
456 (or report-emacs-bug-no-confirmation 455 (or report-emacs-bug-no-confirmation
457 ;; mailclient.el does not need a valid From 456 ;; mailclient.el does not need a valid From
458 (if (derived-mode-p 'message-mode) 457 (if (derived-mode-p 'message-mode)
459 (eq message-send-mail-function 'message-send-mail-with-mailclient) 458 (eq message-send-mail-function 'message-send-mail-with-mailclient)
460 (eq send-mail-function 'mailclient-send-it)) 459 (eq send-mail-function 'mailclient-send-it))
461 ;; Not narrowing to the headers, but that's OK. 460 ;; Not narrowing to the headers, but that's OK.
462 (let ((from (mail-fetch-field "From"))) 461 (let ((from (mail-fetch-field "From")))
463 (and (or (not from) 462 (when (and (or (not from)
464 (message-bogus-recipient-p from) 463 (message-bogus-recipient-p from)
465 ;; This is the default user-mail-address. On today's 464 ;; This is the default user-mail-address. On
466 ;; systems, it seems more likely to be wrong than right, 465 ;; today's systems, it seems more likely to
467 ;; since most people don't run their own mail server. 466 ;; be wrong than right, since most people
468 (string-match (format "\\<%s@%s\\>" 467 ;; don't run their own mail server.
469 (regexp-quote (user-login-name)) 468 (string-match (format "\\<%s@%s\\>"
470 (regexp-quote (system-name))) 469 (regexp-quote (user-login-name))
471 from)) 470 (regexp-quote (system-name)))
472 (not (yes-or-no-p 471 from))
473 (format-message "Is `%s' really your email address? " 472 (not (yes-or-no-p
474 from))) 473 (format-message "Is `%s' really your email address? "
475 (error "Please edit the From address and try again")))) 474 from))))
476 ;; Bury the help buffer (if it's shown). 475 (goto-char (point-min))
477 (when-let ((help (get-buffer "*Bug Help*"))) 476 (re-search-forward "^From: " nil t)
478 (when (get-buffer-window help) 477 (error "Please edit the From address and try again"))))
479 (quit-window nil (get-buffer-window help)))))) 478 ;; Bury the help buffer (if it's shown).
479 (when-let ((help (get-buffer "*Bug Help*")))
480 (when (get-buffer-window help)
481 (quit-window nil (get-buffer-window help)))))
480 482
481;;;###autoload 483;;;###autoload
482(defun submit-emacs-patch (subject file) 484(defun submit-emacs-patch (subject file)