drewr/postal

`name` being used to stringify keywords

Opened this issue · 0 comments

1-

In message.clj there's:

(defn add-extra! [^javax.mail.Message jmsg msgrest]
  (doseq [[n v] msgrest]
    (.addHeader jmsg (if (keyword? n) (name n) n) v))
  jmsg)

However name treats the slash / character as a delimiter.

For instance, the nonstandard header field as a keyword:

(send-message {:from "a@a.com"
               :to "a@a.com"
               :subject "Hi!"
               :body "Test."
               :X-ISO/IEC-ID-1 "test1"
               "X-ISO/IEC-ID-2" "test2"})

Is truncated to:

IEC-ID-1: test1
X-ISO/IEC-ID-2: test2

Maybe some sort of helper function like this to replace instances of name?

(defn k2s [k]
  (if (keyword? k)
    (subs (str k) 1)
    k))

2-

I wasn't sure, but it looks like slashes are valid characters for header fields according to the RFC.

Header fields are lines composed of a field name, followed by a colon
(":"), followed by a field body, and terminated by CRLF.  A field
name MUST be composed of printable US-ASCII characters (i.e.,
characters that have values between 33 and 126, inclusive), except
colon.

http://tools.ietf.org/html/rfc2822#section-2.2