Gnus development mailing list
 help / color / mirror / Atom feed
From: Kim-Minh Kaplan <kmkaplan@vocatex.fr>
Subject: [PATCH] [BUG] Binary attachments use wrong encoding (was Re: PDF's as base64 vs. Q/P encoded attachments)
Date: Wed, 22 Sep 1999 09:41:33 GMT	[thread overview]
Message-ID: <87d7vbi8qc.fsf@kloug.western.fr> (raw)
In-Reply-To: <x67lo12n1p.fsf@ninga.ellerbeck.org>

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Graham Todd writes:

> [...] I think it was decided that if roughly 1/6 of the characters
> were non-ASCII, then base64 should be used otherwise Q/P [...] most
> PDF's would/should get encoded as base64 wouldn't they?  Anyway they
> appear ASCIIish to Gnus.

There is a bug in the function that chooses between quoted printable
and base64.  The following patch should fix it.

Kim-Minh.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix for binary MIME attachments --]
[-- Type: text/x-patch, Size: 865 bytes --]

--- mm-encode.el.orig	Wed Sep 22 11:31:49 1999
+++ mm-encode.el	Wed Sep 22 11:32:41 1999
@@ -126,10 +126,12 @@
 
 (defun mm-qp-or-base64 ()
   (save-excursion
-    (save-restriction
-      (narrow-to-region (point-min) (min (+ (point-min) 1000) (point-max)))
-      (goto-char (point-min))
-      (let ((8bit 0))
+    (let ((8bit 0)
+	  (start (point-min))
+	  (end (min (+ (point-min) 1000) (point-max))))
+      (narrow-to-region start end)
+      (goto-char start)
+      (save-restriction
 	(cond
 	 ((not (featurep 'mule))
 	  (while (re-search-forward "[^\x20-\x7f\r\n\t]" nil t)
@@ -141,9 +143,9 @@
 	    (unless (eobp)
 	      (forward-char 1)
 	      (incf 8bit)))))
-	(if (> (/ (* 8bit 1.0) (buffer-size)) 0.166)
+	(if (> (/ (* 8bit 1.0) (- end start)) 0.166)
 	    'base64
-	  'quoted-printable)))))
+	  'quoted-printable))))) 
 
 (provide 'mm-encode)
 

  parent reply	other threads:[~1999-09-22  9:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-16  5:13 PDF's as base64 vs. Q/P encoded attachments Graham Todd
1999-07-16 10:22 ` Toby Speight
1999-07-21 22:18   ` Graham Todd
1999-08-27 19:03   ` Lars Magne Ingebrigtsen
1999-07-16 16:39 ` Robert Bihlmeyer
1999-07-21 22:19   ` Graham Todd
1999-08-27 19:07 ` Lars Magne Ingebrigtsen
1999-09-22  9:41 ` Kim-Minh Kaplan [this message]
1999-09-22 14:16   ` [PATCH] [BUG] Binary attachments use wrong encoding (was Re: PDF's as base64 vs. Q/P encoded attachments) Kim-Minh Kaplan

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=87d7vbi8qc.fsf@kloug.western.fr \
    --to=kmkaplan@vocatex.fr \
    /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).