mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix IOOBE when processing notifications with multiple newlines (EA-33445)
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user