From: Dmitry Bely <dbely@mail.ru>
Cc: "Sascha LЭdecke" <sascha@meta-x.de>, "Florian Weimer" <fw@deneb.enyo.de>
Subject: mml1991.el patch (was gpg.el)
Date: Mon, 29 Apr 2002 21:45:54 +0400 [thread overview]
Message-ID: <7kmqjt4d.fsf@mail.ru> (raw)
In-Reply-To: <k7quwiqj.fsf@mail.ru>
OK, that's not the gpg.el bug. The problem is that
(1) (mm-body-encoding) does not allow 8bit encodings for PGP-signed
messages and returns base64 for some code pages (e.g. for Russian
koi8r)
(2) (mml1991-gpg-sign) always assumes that it gets qp-encoded text, so it
fails if base64-encoded one is supplied.
Here is the patch that fixes this issue (I am neither the very experienced
Lisp programmer nor Gnus hacker, so if you feel that I did something the
wrong, please correct me)
Index: mml1991.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml1991.el,v
retrieving revision 6.6
diff -u -r6.6 mml1991.el
--- mml1991.el 2002/02/20 00:15:32 6.6
+++ mml1991.el 2002/04/29 17:38:27
@@ -49,10 +49,19 @@
(defun mml1991-mailcrypt-sign (cont)
(let ((text (current-buffer))
headers signature
- (result-buffer (get-buffer-create "*GPG Result*")))
+ (result-buffer (get-buffer-create "*GPG Result*"))
+ encode-function decode-function)
;; Save MIME Content[^ ]+: headers from signing
(goto-char (point-min))
- (while (looking-at "^Content[^ ]+:") (forward-line))
+ (while (looking-at "^Content[^ ]+:")
+ (progn
+ (if (looking-at "^Content-Transfer-Encoding:\\s-+\\(\\S-+\\)")
+ (let ((encoding (downcase (match-string 1))))
+ (setq encode-function
+ (intern (concat encoding "-encode-region")))
+ (setq decode-function
+ (intern (concat encoding "-decode-region")))))
+ (forward-line)))
(if (> (point) (point-min))
(progn
(setq headers (buffer-substring (point-min) (point)))
@@ -60,7 +69,8 @@
(goto-char (point-max))
(unless (bolp)
(insert "\n"))
- (quoted-printable-decode-region (point-min) (point-max))
+ (if decode-function
+ (funcall decode-function (point-min) (point-max)))
(with-temp-buffer
(setq signature (current-buffer))
(insert-buffer text)
@@ -72,7 +82,8 @@
(goto-char (point-min))
(while (re-search-forward "\r+$" nil t)
(replace-match "" t t))
- (quoted-printable-encode-region (point-min) (point-max))
+ (if encode-function
+ (funcall encode-function (point-min) (point-max)))
(set-buffer text)
(kill-region (point-min) (point-max))
(if headers (insert headers))
@@ -125,10 +136,19 @@
(defun mml1991-gpg-sign (cont)
(let ((text (current-buffer))
headers signature
- (result-buffer (get-buffer-create "*GPG Result*")))
+ (result-buffer (get-buffer-create "*GPG Result*"))
+ encode-function decode-function)
;; Save MIME Content[^ ]+: headers from signing
(goto-char (point-min))
- (while (looking-at "^Content[^ ]+:") (forward-line))
+ (while (looking-at "^Content[^ ]+:")
+ (progn
+ (if (looking-at "^Content-Transfer-Encoding:\\s-+\\(\\S-+\\)")
+ (let ((encoding (downcase (match-string 1))))
+ (setq encode-function
+ (intern (concat encoding "-encode-region")))
+ (setq decode-function
+ (intern (concat encoding "-decode-region")))))
+ (forward-line)))
(if (> (point) (point-min))
(progn
(setq headers (buffer-substring (point-min) (point)))
@@ -136,7 +156,8 @@
(goto-char (point-max))
(unless (bolp)
(insert "\n"))
- (quoted-printable-decode-region (point-min) (point-max))
+ (if decode-function
+ (funcall decode-function (point-min) (point-max)))
(with-temp-buffer
(unless (gpg-sign-cleartext text (setq signature (current-buffer))
result-buffer
@@ -148,7 +169,8 @@
(goto-char (point-min))
(while (re-search-forward "\r+$" nil t)
(replace-match "" t t))
- (quoted-printable-encode-region (point-min) (point-max))
+ (if encode-function
+ (funcall encode-function (point-min) (point-max)))
(set-buffer text)
(kill-region (point-min) (point-max))
(if headers (insert headers))
Hope to hear from you soon,
Dmitry
next prev parent reply other threads:[~2002-04-29 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-26 12:08 gpg.el Dmitry Bely
2002-04-26 15:28 ` gpg.el Florian Weimer
2002-04-26 16:02 ` gpg.el Dmitry Bely
2002-04-29 17:45 ` Dmitry Bely [this message]
2002-05-01 10:37 ` mml1991.el patch (was gpg.el) Florian Weimer
2002-05-01 15:33 ` Dmitry Bely
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7kmqjt4d.fsf@mail.ru \
--to=dbely@mail.ru \
--cc=fw@deneb.enyo.de \
--cc=sascha@meta-x.de \
/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.
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 NNTP newsgroup(s).