File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
main/java/jakarta/mail/internet
test/java/jakarta/mail/internet Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 1997, 2025 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 2026 Oracle and/or its affiliates. All rights reserved.
33 *
44 * This program and the accompanying materials are made available under the
55 * terms of the Eclipse Public License v. 2.0, which is available at
@@ -660,8 +660,10 @@ public void addHeaderLine(String line) {
660660 try {
661661 char c = line .charAt (0 );
662662 if (c == ' ' || c == '\t' ) {
663- InternetHeader h = headers .get (headers .size () - 1 );
664- h .line += "\r \n " + line ;
663+ if (!headers .isEmpty ()) {
664+ InternetHeader h = headers .get (headers .size () - 1 );
665+ h .line += "\r \n " + line ;
666+ }
665667 } else
666668 headers .add (new InternetHeader (line ));
667669 } catch (StringIndexOutOfBoundsException e ) {
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2025, 2026 Oracle and/or its affiliates. All rights reserved.
33 *
44 * This program and the accompanying materials are made available under the
55 * terms of the Eclipse Public License v. 2.0, which is available at
1919
2020import static org .junit .Assert .assertEquals ;
2121
22+ import java .io .ByteArrayInputStream ;
23+ import java .util .Base64 ;
2224import java .util .Properties ;
2325import jakarta .mail .Session ;
2426import org .junit .Test ;
@@ -83,4 +85,13 @@ public void testSystemPropertiesAndSessionWithNoProperties() throws Exception {
8385 System .clearProperty ("mail.mime.allowutf8" );
8486 }
8587 }
88+
89+ @ Test
90+ public void testEmptyHeaders () throws Exception {
91+ String base64Input = "ICAgIAogICAKCg==" ;
92+ byte [] input = Base64 .getDecoder ().decode (base64Input );
93+ Session session = Session .getDefaultInstance (new Properties ());
94+ ByteArrayInputStream is = new ByteArrayInputStream (input );
95+ new MimeMessage (session , is );
96+ }
8697}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ longer available.
2121
2222 CHANGES IN THE 2.2.0 RELEASE
2323 ----------------------------
24+ E 827 Exception in Internet-headers when parsing malformed MIME headers
2425E 714 Support minimum JDK of 11+ and minimum of Android API 33+
2526E 720 finalize() in java.lang.Object has been deprecated
2627E 744 Remove SecurityManager reference from API
You can’t perform that action at this time.
0 commit comments