[mel-base-devel] Parse-address (correction)

Fred Gibson fred at streamfocus.com
Wed Mar 17 01:39:16 UTC 2010


Please ignore the previous email on this.  To solve the problem, I
added a string-search function to replace the < and > to < and >
, and this solved the problem.

diff --git a/lib/mel-base/rfc2822.lisp b/lib/mel-base/rfc2822.lisp
index 704ce36..1c6d401 100644
--- a/lib/mel-base/rfc2822.lisp
+++ b/lib/mel-base/rfc2822.lisp
@@ -614,9 +614,32 @@
                           :display-name (subseq string start (1- list-start)))
            (1+ semikolon-start))))

+(defun string-replace (new old string)
+  (let ((str1 (string string))
+        (str2 "")
+        (sub1 (string old))
+        (sub2 (string new))
+        (index1 0))
+    (loop
+        (if (string-equal str1 sub1
+                          :start1 index1
+                          :end1 (min (length str1)
+                                     (+ index1 (length sub1))))
+            (progn
+              (setq str2 (concatenate 'string str2 sub2))
+              (incf index1 (length sub1)))
+            (progn
+              (setq str2 (concatenate 'string
+                                      str2
+                                      (subseq str1 index1 (1+ index1))))
+              (incf index1)))
+        (unless (< index1 (length str1))
+          (return str2)))))
+
 (defun parse-address (string &key (start 0) (end (length string)) (errorp t))
   (restart-case
-      (let ((first-special (next-token-of-type string :special :start
start :end end)))
+      (let* ((string (string-replace ">" ">" (string-replace "<"
"<" string)))
+             (first-special (next-token-of-type string :special
:start start :end end)))
        (ecase first-special
          #+nil((nil) (mime-parse-error "parsing address: No address found"))
          (#\: (parse-group-address string :start start


-- 
Fred Gibson

Founder / Software Developer
http://www.streamfocus.com

(c)2010 Organon Technologies LLC




More information about the mel-base-devel mailing list