about summary refs log tree commit diff
path: root/users/sterni/mblog/note.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'users/sterni/mblog/note.lisp')
-rw-r--r--users/sterni/mblog/note.lisp18
1 files changed, 17 insertions, 1 deletions
diff --git a/users/sterni/mblog/note.lisp b/users/sterni/mblog/note.lisp
index 0091e97b08..93d9231aa2 100644
--- a/users/sterni/mblog/note.lisp
+++ b/users/sterni/mblog/note.lisp
@@ -66,6 +66,20 @@
                                :test #'string-equal))
     (string-equal (cdr uniform-id) "com.apple.mail-note")))
 
+(defun decode-RFC2047-to-string (input)
+  (apply
+   #'concatenate
+   (cons 'string
+         (mapcar
+          (lambda (el)
+            (etypecase el
+              (cons (babel:octets-to-string
+                     (car el)
+                     :encoding (babel-encodings:get-character-encoding
+                                (intern (string-upcase (cdr el)) 'keyword))))
+              (string el)))
+          (mime:parse-RFC2047-text input)))))
+
 (defun make-apple-note (msg)
   (check-type msg mime-message)
 
@@ -73,7 +87,9 @@
     (error "Passed message is not an Apple Note according to headers"))
 
   (let ((text-part (mime:find-mime-text-part msg))
-        (subject (find-mime-message-header "Subject" msg))
+        (subject (when-let ((val (find-mime-message-header "Subject" msg)))
+                   ;; TODO(sterni): mime4cl should do this
+                   (decode-RFC2047-to-string val)))
         (uuid (when-let ((val (find-mime-message-header
                                "X-Universally-Unique-Identifier"
                                msg)))