/[emacs]/emacs/lisp/gnus/rfc2047.el
ViewVC logotype

Diff of /emacs/lisp/gnus/rfc2047.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10.8.4 by miles, Thu Sep 16 00:12:16 2004 UTC revision 1.10.8.5 by miles, Wed Oct 6 05:23:53 2004 UTC
# Line 126  quoted-printable and base64 respectively Line 126  quoted-printable and base64 respectively
126  ;;; Functions for encoding RFC2047 messages  ;;; Functions for encoding RFC2047 messages
127  ;;;  ;;;
128    
129    (defun rfc2047-qp-or-base64 ()
130      "Return the type with which to encode the buffer.
131    This is either `base64' or `quoted-printable'."
132      (save-excursion
133        (let ((limit (min (point-max) (+ 2000 (point-min))))
134              (n8bit 0))
135          (goto-char (point-min))
136          (skip-chars-forward "\x20-\x7f\r\n\t" limit)
137          (while (< (point) limit)
138            (incf n8bit)
139            (forward-char 1)
140            (skip-chars-forward "\x20-\x7f\r\n\t" limit))
141          (if (or (< (* 6 n8bit) (- limit (point-min)))
142                  ;; Don't base64, say, a short line with a single
143                  ;; non-ASCII char when splitting parts by charset.
144                  (= n8bit 1))
145              'quoted-printable
146            'base64))))
147    
148  (defun rfc2047-narrow-to-field ()  (defun rfc2047-narrow-to-field ()
149    "Narrow the buffer to the header on the current line."    "Narrow the buffer to the header on the current line."
150    (beginning-of-line)    (beginning-of-line)
# Line 411  By default, the region is treated as con Line 430  By default, the region is treated as con
430                         ;; encoding, choose the one that's shorter.                         ;; encoding, choose the one that's shorter.
431                         (save-restriction                         (save-restriction
432                           (narrow-to-region b e)                           (narrow-to-region b e)
433                           (if (eq (mm-qp-or-base64) 'base64)                           (if (eq (rfc2047-qp-or-base64) 'base64)
434                               'B                               'B
435                             'Q))))                             'Q))))
436           (start (concat           (start (concat
# Line 720  decodable." Line 739  decodable."
739    ;; Be more liberal to accept buggy base64 strings. If    ;; Be more liberal to accept buggy base64 strings. If
740    ;; base64-decode-string accepts buggy strings, this function could    ;; base64-decode-string accepts buggy strings, this function could
741    ;; be aliased to identity.    ;; be aliased to identity.
742    (case (mod (length string) 4)    (if (= 0 (mod (length string) 4))
743      (0 string)        string
744      (1 string) ;; Error, don't pad it.      (when (string-match "=+$" string)
745      (2 (concat string "=="))        (setq string (substring string 0 (match-beginning 0))))
746      (3 (concat string "="))))      (case (mod (length string) 4)
747          (0 string)
748          (1 string) ;; Error, don't pad it.
749          (2 (concat string "=="))
750          (3 (concat string "=")))))
751    
752  (defun rfc2047-decode (charset encoding string)  (defun rfc2047-decode (charset encoding string)
753    "Decode STRING from the given MIME CHARSET in the given ENCODING.    "Decode STRING from the given MIME CHARSET in the given ENCODING.

Legend:
Removed from v.1.10.8.4  
changed lines
  Added in v.1.10.8.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26