Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db791579 authored by cketti's avatar cketti
Browse files

Add support for obsolete header field format

Putting whitespace between header field name and colon is valid in the
obsolete syntax.
parent ea699b3d
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -170,10 +170,6 @@ public class MimeHeader implements Cloneable {
            if (raw == null) {
                throw new NullPointerException("Argument 'raw' cannot be null");
            }
            if (name != null && !raw.startsWith(name + ":")) {
                throw new IllegalArgumentException("The value of 'raw' needs to start with the supplied field name " +
                        "followed by a colon");
            }

            return new Field(name, null, raw);
        }
+10 −0
Original line number Diff line number Diff line
@@ -52,6 +52,16 @@ public class MimeMessageParseTest {
        assertEquals("this is some test text.", streamToString(MimeUtility.decodeBody(msg.getBody())));
    }

    @Test
    public void headerFieldNameWithSpace() throws Exception {
        MimeMessage msg = parseWithoutRecurse(toStream("" +
                "From : <adam@example.org>\r\n" +
                "\r\n" +
                "Body"));

        assertEquals("<adam@example.org>", msg.getHeader("From")[0]);
    }

    @Test
    public void testSinglePart8BitRecurse() throws Exception {
        MimeMessage msg = parseWithRecurse(toStream(