From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 5DC1C6DE09CD for ; Sun, 2 Oct 2016 07:05:45 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=-0.131, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f-4qNQR8AVB2 for ; Sun, 2 Oct 2016 07:05:43 -0700 (PDT) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 125886DE0999 for ; Sun, 2 Oct 2016 07:05:43 -0700 (PDT) Received: by mail-wm0-f66.google.com with SMTP id p138so10648151wmb.0 for ; Sun, 02 Oct 2016 07:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DMFazfvg0pqznaBHryGgFjt5cdP4fv90psJ0uqbgrBA=; b=i131OMQT+C65j43mUtJl6aEI4TXsbdO9YV8QlXOAWqMLBCewVoJY21nw7P/F2jV/Vv mxS+gNH0MfnwF/L90VwITAj0nsJX8GbziUTDRz+AzWyLQUV4p0SbHt5c8uOVGbuLxqXx DhNI5z+IupPOcy1G6/N2XWSddaekqi+Er6htlfyzJGWjuXI47kdgKbbxLftWa9RpyQLl PWOMIeTYAkZHS8zjLqhqHDnNZtk5u9auou7AMAaqdScKqmcKOALBV6NfX/VHMk9ZOI2N F2IyAwoALW12oLKi8uEVvSvEQZumfYAOpkUWYb+ACJazcB2PP+yQs/QzdRZdagxFMbzq 0Pwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DMFazfvg0pqznaBHryGgFjt5cdP4fv90psJ0uqbgrBA=; b=koxGtROcWnEnc2CSjs+2G8IAcACMbDc+SURH5BxNNORmeJjYLMvygWzksxeXYqXZ32 lNvNxD51lkIW7XVzkc7RkSS4xCCDL62L+ggn1x79Lp5q6pGP8FfxMYwFTeXmRS6bzHmK eYAuwg6bdkUWsaUQpQPmwYmZ62KMvaMGgDe0Oq+xpwXW8xA5FaZCp1/c8kujZDSWSLC5 9i4bohgghsk61w8HePaeFPGbHiT4Q5D5qETlMFhw4z3FFm6oR08Ilm1cL1dKN8SiHvH3 Uf4+q+8sR1cXHoPhR3Pdza1Tp94y0dMEOtGRM6OVFzZd1ZJG5ji9x2sTnRzzK0Yx2q31 Pfsg== X-Gm-Message-State: AA6/9RmudgAaZ1xsmJ56BBxTrV5MU3HlAA3Pzt+l3vnt/oFRWx7jKX0UZT9K3XXt+z3UeA== X-Received: by 10.28.232.84 with SMTP id f81mr6508398wmh.39.1475417141486; Sun, 02 Oct 2016 07:05:41 -0700 (PDT) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id yt4sm29580552wjc.48.2016.10.02.07.05.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Oct 2016 07:05:40 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: mua: check for misplaced secure mml tags Date: Sun, 2 Oct 2016 15:05:31 +0100 Message-Id: <1475417131-24915-3-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475417131-24915-1-git-send-email-markwalters1009@gmail.com> References: <1475417131-24915-1-git-send-email-markwalters1009@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Oct 2016 14:05:45 -0000 Emacs message-send seems to ignore a secure mml tag anywhere except at the start of the body, and it must be followed by a newline. Since this is almost certainly not desired we check for it, and require user confirmation before sending. As the setup before message-send or message-send-and-exit is getting more complicated it is convenient to unify the two correspoinding notmuch functions. --- emacs/notmuch-mua.el | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 72fb770..bae95f3 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -490,12 +490,37 @@ will be addressed to all recipients of the source message." (notmuch-mua-reply query-string sender reply-all) (deactivate-mark))) +(defun notmuch-mua-misplaced-secure-tag () + "Query user if there is a misplaced secure mml tag. + +Emacs message-send will (probably) ignore a secure mml tag unless +it is at the start of the body and followed by a newline. Since +this is almost certainly not desired we check for it, and get +confirmation from the user if there is such a tag. Returns t if +there is such a tag unless the user confirms they mean it." + (save-excursion + (let ((body-start (progn (message-goto-body) (point)))) + (goto-char (point-max)) + ;; We are always fine if there is no secure tag. + (when (search-backward "<#secure" nil 't) + ;; There is a secure tag, so it must be at the start of the + ;; body, with no secure tag earlier (i.e., in the headers) and + ;; it must be followed by a newline. + (unless (and (= (point) body-start) + (not (search-backward "<#secure" nil 't)) + (looking-at "<#secure[^\n>]*>\n")) + (not (yes-or-no-p "\ +There is a <#secure> tag not at the start of the body. It is +likely that the message will be sent unsigned and unencrypted. +Really send? "))))))) + (defun notmuch-mua-send-common (arg &optional exit) (interactive "P") (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc)) - (if exit - (message-send-and-exit arg) - (message-send arg)))) + (unless (notmuch-mua-misplaced-secure-tag) + (if exit + (message-send-and-exit arg) + (message-send arg))))) (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") -- 2.1.4