emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/gnus/rfc2047.el [emacs-unicode-2]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/gnus/rfc2047.el [emacs-unicode-2]
Date: Wed, 29 Sep 2004 03:44:59 -0400

Index: emacs/lisp/gnus/rfc2047.el
diff -c emacs/lisp/gnus/rfc2047.el:1.13.4.3 emacs/lisp/gnus/rfc2047.el:1.13.4.4
*** emacs/lisp/gnus/rfc2047.el:1.13.4.3 Thu Sep  9 09:36:26 2004
--- emacs/lisp/gnus/rfc2047.el  Wed Sep 29 07:22:16 2004
***************
*** 126,131 ****
--- 126,150 ----
  ;;; Functions for encoding RFC2047 messages
  ;;;
  
+ (defun rfc2047-qp-or-base64 ()
+   "Return the type with which to encode the buffer.
+ This is either `base64' or `quoted-printable'."
+   (save-excursion
+     (let ((limit (min (point-max) (+ 2000 (point-min))))
+         (n8bit 0))
+       (goto-char (point-min))
+       (skip-chars-forward "\x20-\x7f\r\n\t" limit)
+       (while (< (point) limit)
+       (incf n8bit)
+       (forward-char 1)
+       (skip-chars-forward "\x20-\x7f\r\n\t" limit))
+       (if (or (< (* 6 n8bit) (- limit (point-min)))
+             ;; Don't base64, say, a short line with a single
+             ;; non-ASCII char when splitting parts by charset.
+             (= n8bit 1))
+         'quoted-printable
+       'base64))))
+ 
  (defun rfc2047-narrow-to-field ()
    "Narrow the buffer to the header on the current line."
    (beginning-of-line)
***************
*** 411,417 ****
                       ;; encoding, choose the one that's shorter.
                       (save-restriction
                         (narrow-to-region b e)
!                        (if (eq (mm-qp-or-base64) 'base64)
                             'B
                           'Q))))
         (start (concat
--- 430,436 ----
                       ;; encoding, choose the one that's shorter.
                       (save-restriction
                         (narrow-to-region b e)
!                        (if (eq (rfc2047-qp-or-base64) 'base64)
                             'B
                           'Q))))
         (start (concat
***************
*** 720,730 ****
    ;; Be more liberal to accept buggy base64 strings. If
    ;; base64-decode-string accepts buggy strings, this function could
    ;; be aliased to identity.
!   (case (mod (length string) 4)
!     (0 string)
!     (1 string) ;; Error, don't pad it.
!     (2 (concat string "=="))
!     (3 (concat string "="))))
  
  (defun rfc2047-decode (charset encoding string)
    "Decode STRING from the given MIME CHARSET in the given ENCODING.
--- 739,753 ----
    ;; Be more liberal to accept buggy base64 strings. If
    ;; base64-decode-string accepts buggy strings, this function could
    ;; be aliased to identity.
!   (if (= 0 (mod (length string) 4))
!       string
!     (when (string-match "=+$" string)
!       (setq string (substring string 0 (match-beginning 0))))
!     (case (mod (length string) 4)
!       (0 string)
!       (1 string) ;; Error, don't pad it.
!       (2 (concat string "=="))
!       (3 (concat string "=")))))
  
  (defun rfc2047-decode (charset encoding string)
    "Decode STRING from the given MIME CHARSET in the given ENCODING.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]