Browse code
2007-09-24 Ahmon Dancy <dancy@dancy>
layer authored on 24/09/2007 22:17:45
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -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: rfc2822.cl,v 1.10 2007/09/20 18:22:42 layer Exp $ |
|
17 |
+;; $Id: rfc2822.cl,v 1.11 2007/09/24 22:17:45 layer Exp $ |
|
18 | 18 |
|
19 | 19 |
#+(version= 8 0) |
20 | 20 |
(sys:defpatch "rfc2822" 0 |
... | ... |
@@ -238,9 +238,9 @@ domain. |
238 | 238 |
(grab-next-comment string start end) |
239 | 239 |
(if display-name |
240 | 240 |
(setf start newpos)) |
241 |
- (values |
|
242 |
- (list :mailbox display-name localpart domain) |
|
243 |
- start))))) |
|
241 |
+ (values |
|
242 |
+ (list :mailbox display-name localpart domain) |
|
243 |
+ start))))) |
|
244 | 244 |
|
245 | 245 |
(defun grab-next-comment (string start end) |
246 | 246 |
(loop |
... | ... |
@@ -295,8 +295,6 @@ domain. |
295 | 295 |
(loop |
296 | 296 |
(multiple-value-setq (type value newpos) |
297 | 297 |
(rfc2822-lex string start end first)) |
298 |
- (if (null type) |
|
299 |
- nil) |
|
300 | 298 |
(if* (or (eq type :atom) |
301 | 299 |
(eq type :quoted-string) |
302 | 300 |
(and (not first) (or (eq value #\.) (eq type :wsp)))) |
... | ... |
@@ -304,6 +302,7 @@ domain. |
304 | 302 |
(setf first nil) |
305 | 303 |
(setf start newpos) |
306 | 304 |
else (return))) |
305 |
+ ;; Dump any trailing whitespace we collected |
|
307 | 306 |
(if (and (stringp res) (match-re "^\\s" (first res))) |
308 | 307 |
(pop res)) |
309 | 308 |
(if res |
... | ... |
@@ -388,7 +387,8 @@ domain. |
388 | 387 |
(values :quoted-string |
389 | 388 |
(subseq string (car whole) (cdr whole)) |
390 | 389 |
(cdr whole))) |
391 |
- elseif (or (eq char #\space) (eq char #\tab)) |
|
390 |
+ elseif (or (eq char #\space) (eq char #\tab) |
|
391 |
+ (eq char #\return) (eq char #\newline)) |
|
392 | 392 |
then ;; whitespace |
393 | 393 |
(multiple-value-bind (x match) |
394 | 394 |
(match-re "^\\s+" string |
... | ... |
@@ -426,17 +426,22 @@ domain. |
426 | 426 |
(cdr whole)))))))) |
427 | 427 |
|
428 | 428 |
#+ignore |
429 |
-(defun test () |
|
430 |
- (dolist (file (command-output "find ~/mail/ -name \"[0-9][0-9]*\"")) |
|
431 |
- (with-open-file (f file) |
|
432 |
- (let* ((part (parse-mime-structure f)) |
|
433 |
- (hdrs (mime-part-headers part))) |
|
434 |
- (dolist (type '("From" "To" "Cc")) |
|
435 |
- (let ((hdr (cdr (assoc type hdrs :test #'equalp)))) |
|
436 |
- (when hdr |
|
437 |
- (if (null (extract-email-addresses hdr :require-domain nil |
|
438 |
- :errorp nil)) |
|
439 |
- (format t "Failed to parse: ~s~%" hdr))))))))) |
|
429 |
+(defun test (&key errorp (compact t)) |
|
430 |
+ (let ((seen-addrs (make-hash-table :test #'equal))) |
|
431 |
+ (dolist (file (excl.osi:command-output "find ~/mail/ -name \"[0-9][0-9]*\"")) |
|
432 |
+ (with-open-file (f file) |
|
433 |
+ (let* ((part (net.post-office:parse-mime-structure f)) |
|
434 |
+ (hdrs (net.post-office:mime-part-headers part))) |
|
435 |
+ (dolist (type '("From" "To" "Cc")) |
|
436 |
+ (let ((hdr (cdr (assoc type hdrs :test #'equalp)))) |
|
437 |
+ (when (and hdr |
|
438 |
+ (string/= hdr "") |
|
439 |
+ (not (gethash hdr seen-addrs))) |
|
440 |
+ (setf (gethash hdr seen-addrs) t) |
|
441 |
+ (if (null (extract-email-addresses hdr :require-domain nil |
|
442 |
+ :errorp errorp |
|
443 |
+ :compact compact)) |
|
444 |
+ (format t "Failed to parse: ~s~%" hdr)))))))))) |
|
440 | 445 |
|
441 | 446 |
;; Ripped from maild:dns.cl and modified. |
442 | 447 |
|