Jochen Wiedmann created EMAIL-198:
-------------------------------------
Summary: Performance in ImageHtmlEmail
Key: EMAIL-198
URL: https://issues.apache.org/jira/browse/EMAIL-198
Project: Commons Email
Issue Type: Improvement
Affects Versions: 1.5
Reporter: Jochen Wiedmann
Assignee: Jochen Wiedmann
Fix For: 1.6
In the class ImageHtmlEmail, there are two regular expressions
(REGEX_SCRIPT_SRC, and
REGEX_IMAGE_SRC), which can behave rather slow in exceptional cases, as
evidenced by
the following code snippet:
@Test
public void testSlowRegularExpressions() throws Exception {
ImageHtmlEmail mail = new ImageHtmlEmail();
mail.setHostName("example.com");
mail.setFrom("[email protected]");
mail.addTo("[email protected]");
StringBuilder text = new StringBuilder("<img");
for (int i = 0; i < 3000; i++) {
text.append(" ");
}
mail.setMsg("<html><body><pre>" + text + "</pre></body></html>");
long startTime = System.currentTimeMillis();
mail.buildMimeMessage();
long duration = System.currentTimeMillis() - startTime;
assertTrue("Run time exceeds permitted duration of 50 seconds: " + duration,
duration < 100*1000);
}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)