git.fiddlerwoaroof.com
Browse code

2007-08-02 Ahmon Dancy <dancy@dancy>

layer authored on 02/08/2007 18:14:31
Showing 4 changed files
... ...
@@ -1,3 +1,16 @@
1
+2007-08-02  Ahmon Dancy  <dancy@dancy>
2
+
3
+	* mime-parse.cl:
4
+
5
+	Don't include the stuff between the end of a multipart part and
6
+	the beginning of the next part in the mime-part-body-size.
7
+
8
+	* mime-transfer-encoding.cl:
9
+
10
+	with-decoded-part-body-stream.  Set the stream's external-format
11
+	based on the charset specified in the part (if any (defaults to
12
+	:latin1)).
13
+
1 14
 2007-06-05  Ahmon Dancy  <dancy@dancy>
2 15
 
3 16
 	* rfe7210: rfc2822.cl: new extract-email-addresses function.
... ...
@@ -1,3 +1,9 @@
1
+#+(version= 8 1)
2
+(sys:defpatch "mime" 1
3
+  "v1: changes to internal/undocumented portions of module."
4
+  :type :system
5
+  :post-loadable t)
6
+
1 7
 #+(version= 8 0)
2 8
 (sys:defpatch "mime" 3
3 9
   "v0: New module.  See documentation.;
... ...
@@ -34,7 +40,7 @@ v2: make-mime-part: Default external-format is :utf8."
34 40
 ;; merchantability or fitness for a particular purpose.  See the GNU
35 41
 ;; Lesser General Public License for more details.
36 42
 ;;
37
-;; $Id: mime-api.cl,v 1.7 2007/05/31 23:13:08 dancy Exp $
43
+;; $Id: mime-api.cl,v 1.8 2007/08/02 18:14:31 layer Exp $
38 44
 
39 45
 (defpackage :net.post-office
40 46
   (:use #:lisp #:excl)
... ...
@@ -14,7 +14,7 @@
14 14
 ;; merchantability or fitness for a particular purpose.  See the GNU
15 15
 ;; Lesser General Public License for more details.
16 16
 ;;
17
-;; $Id: mime-parse.cl,v 1.6 2007/05/31 23:13:08 dancy Exp $
17
+;; $Id: mime-parse.cl,v 1.7 2007/08/02 18:14:31 layer Exp $
18 18
 
19 19
 (defpackage :net.post-office
20 20
   (:use #:lisp #:excl)
... ...
@@ -347,10 +347,10 @@
347 347
     
348 348
     ;; If boundary isn't specified.. try to compensate by using our
349 349
     ;; parent's boundary.
350
-    (if (null boundary)
351
-	(setf boundary parent-boundary)
352
-      (setf boundary (mime-dequote boundary)))
353
-    
350
+    (if* (null boundary)
351
+       then (setf boundary parent-boundary)
352
+       else (setf boundary (mime-dequote boundary)))
353
+
354 354
     ;; Locate the first boundary.
355 355
     (multiple-value-bind (ignore1 ignore2 ignore3 newpos)
356 356
 	(read-until-boundary stream boundary pos mbox)
... ...
@@ -366,13 +366,12 @@
366 366
     
367 367
     (setf (mime-part-parts part) (nreverse parts))
368 368
     
369
+    (setf (mime-part-body-size part) (- pos startpos))
370
+    
369 371
     ;; Discard everything that follows until we reach the parent-boundary.
370 372
     (multiple-value-bind (ignore1 ignore2 eof pos)
371 373
 	(read-until-boundary stream parent-boundary pos mbox)
372 374
       (declare (ignore ignore1 ignore2))
373
-      
374
-      (setf (mime-part-body-size part) (- pos startpos))
375
-      
376 375
       (values part eof pos))))
377 376
 
378 377
 
... ...
@@ -14,7 +14,7 @@
14 14
 ;; merchantability or fitness for a particular purpose.  See the GNU
15 15
 ;; Lesser General Public License for more details.
16 16
 ;;
17
-;; $Id: mime-transfer-encoding.cl,v 1.13 2007/06/19 22:01:14 dancy Exp $
17
+;; $Id: mime-transfer-encoding.cl,v 1.14 2007/08/02 18:14:31 layer Exp $
18 18
 
19 19
 (defpackage :net.post-office
20 20
   (:use #:lisp #:excl)
... ...
@@ -283,7 +283,9 @@
283 283
 (defmacro with-decoded-part-body-stream ((sym part instream) &body body)
284 284
   (let ((p (gensym))
285 285
 	(encoding (gensym))
286
-	(count (gensym)))
286
+	(count (gensym))
287
+	(charset (gensym))
288
+	(ef (gensym)))
287 289
     `(let* ((,p ,part)
288 290
 	    (,encoding (mime-part-encoding ,p))
289 291
 	    (,count (mime-part-body-size ,p)))
... ...
@@ -291,6 +293,11 @@
291 293
 					      ,instream
292 294
 					      ,encoding
293 295
 					      ,count)
296
+	 (let* ((,charset (or (cdr (assoc "charset" (mime-part-parameters ,p)
297
+					  :test #'equalp))
298
+			      "us-ascii"))
299
+		(,ef (or (charset-to-external-format ,charset) :latin1)))
300
+	   (setf (stream-external-format ,sym) ,ef))
294 301
 	 ,@body))))
295 302
 					  
296 303
 (defun mime-decode-transfer-encoding (outstream instream encoding count)