james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markus Wiederkehr" <markus.wiederk...@gmail.com>
Subject [mime4j] Possible header field parsing problem
Date Wed, 03 Dec 2008 19:15:42 GMT
I think I have found a minor(?) issue when parsing header fields.

RFC 822 defines a field as:
     field       =  field-name ":" [ field-body ] CRLF
     field-name  =  1*<any CHAR, excluding CTLs, SPACE, and ":">

.. which implies two things. First a field name must consist of at
least one character. And second a field name may not contain spaces or
tabs; not even trailing ones.

Now take a look at o.a.j.mime4j.parser.AbstractEntity#parseField. This
method accepts empty field name, that is, header lines that
immediately start with a colon. It does not accept trailing
tabs/spaces.

On the other hand o.a.j.mime4j.field.Field#parse uses a regular
expression that allows trailing tabs or spaces in the field name. The
regex does not match empty field names.

I think both methods should be very strict and allow neither empty
field names nor trailing spaces. Or at the very least they should be
consistent with each other.

If both method would behave consistently this would also resolve
another issue that's been bothering me: the MimeException in
Field#parse. It could be changed back to an IllegalArgumentException
because the method would never be invoked with an invalid argument
when parsing an InputStream. AbstractEntity#parseField already drops
such invalid header fields.

Opinions?

Markus

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message