http://kenai.com/bugzilla/show_bug.cgi?id=5847
Bug #: 5847
Summary: StringIndexOutOfBoundsException when parsing bad
address with unclosed quote in mail header
Classification: Unclassified
Product: javamail
Version: 1.4.7
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P5
Component: internet
AssignedTo: shannon_at_kenai.com
ReportedBy: shannon_at_kenai.com
CC: issues_at_javamail.kenai.com
during parsing some eml-files with JavaMail API 1.4.7 a
StringIndexOutOfBoundsException was thrown by calling MimeMessage.getFrom() -
method.
The Exception stack trace is:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1911)
at javax.mail.internet.InternetAddress.unquote(InternetAddress.java:371)
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1071)
at
javax.mail.internet.InternetAddress.parseHeader(InternetAddress.java:658)
at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:702)
at javax.mail.internet.MimeMessage.getFrom(MimeMessage.java:362)
You can reproduce it with any email that have a from-header line like:
...header lines before ...
From: " <string_at_string.ru>
...header lines after ...
The personal-part within this from-header starts and ends with a qoutation mark
(as it is a single quotation mark), so unquoting this string produces a
StringIndexOutOfBoundsException.
i.e.
String s = "\"";
if (s.startsWith("\"") && s.endsWith("\"")) {
s = s.substring(1, s.length() - 1); // StringIndexOutOfBoundsException
will be thrown.
}
This behavior occurs even if the property "mail.mime.address.strict" is set to
"false".
--
Configure bugmail: http://kenai.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.