Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.5
-
None
Description
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("from@example.com");
mail.addTo("to@example.com");
StringBuilder text = new StringBuilder("<img");
for (int i = 0; i < 3000; i++)
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);
}