fix IOOBE when processing notifications with multiple newlines (EA-33445)

This commit is contained in:
peter
2012-02-04 10:33:09 +01:00
parent e8b188b9dc
commit 0486fbbe72
2 changed files with 7 additions and 3 deletions
@@ -235,10 +235,10 @@ public class EventLog implements Notifications {
}
private static void removeJavaNewLines(Document document, List<RangeMarker> lineSeparators, boolean hasHtml) {
String text = document.getText();
int i = -1;
CharSequence text = document.getCharsSequence();
int i = 0;
while (true) {
i = text.indexOf('\n', i + 1);
i = StringUtil.indexOf(text, '\n', i);
if (i < 0) break;
document.deleteString(i, i + 1);
if (!hasHtml) {
@@ -74,4 +74,8 @@ class EventLogTest extends LightPlatformTestCase {
assert EventLog.formatForLog(new Notification("xxx", 'title', "foo<br/>Bar", NotificationType.ERROR)).message == 'title: foo // Bar'
}
public void testManyNewlines() throws Exception {
assert EventLog.formatForLog(new Notification("xxx", 'title', "foo\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nbar", NotificationType.ERROR)).message == 'title: foo bar'
}
}