don't get stuck in EventLog on malformed links cidr/112.667 idea/112.666 pycharm/112.665 rubymine/112.664 rubymine/112.668 rubymine/112.669 storm/112.663
authorpeter <peter@jetbrains.com>
Wed, 1 Feb 2012 22:59:22 +0000 (23:59 +0100)
committerpeter <peter@jetbrains.com>
Wed, 1 Feb 2012 23:01:13 +0000 (00:01 +0100)
platform/platform-impl/src/com/intellij/notification/EventLog.java
platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy

index c04f7064f54494d849119eba31e86eb543a2e294..310e5544c0e82d7414711b75ec481d69a0c2f01c 100644 (file)
@@ -183,22 +183,22 @@ public class EventLog implements Notifications {
           links.put(document.createRangeMarker(new TextRange(document.getTextLength() - linkText.length(), document.getTextLength())),
                     new NotificationHyperlinkInfo(notification, href));
           content = content.substring(linkEnd + A_CLOSING.length());
+          continue;
         }
       }
-      else {
-        hasHtml = true;
-        if ("<br>".equals(tagStart) ||
-            "</br>".equals(tagStart) ||
-            "</p>".equals(tagStart) ||
-            "<p>".equals(tagStart) ||
-            "<p/>".equals(tagStart)) {
-          lineSeparators.add(document.createRangeMarker(TextRange.from(document.getTextLength(), 0)));
-        }
-        else if (!"<html>".equals(tagStart) && !"</html>".equals(tagStart) && !"<body>".equals(tagStart) && !"</body>".equals(tagStart)) {
-          showMore.set(true);
-        }
-        content = content.substring(tagMatcher.end());
+
+      hasHtml = true;
+      if ("<br>".equals(tagStart) ||
+          "</br>".equals(tagStart) ||
+          "</p>".equals(tagStart) ||
+          "<p>".equals(tagStart) ||
+          "<p/>".equals(tagStart)) {
+        lineSeparators.add(document.createRangeMarker(TextRange.from(document.getTextLength(), 0)));
+      }
+      else if (!"<html>".equals(tagStart) && !"</html>".equals(tagStart) && !"<body>".equals(tagStart) && !"</body>".equals(tagStart)) {
+        showMore.set(true);
       }
+      content = content.substring(tagMatcher.end());
     }
     return hasHtml;
   }
index fee62a4801f908621be45f73216b0a0ffc10922f..e15a4d7325929e998296f2bb0e2a672d9ba76dd2 100644 (file)
@@ -63,4 +63,9 @@ class EventLogTest extends LightPlatformTestCase {
     assert entry.links.collect { it.first } == [new TextRange(0, 4)]
   }
 
+  public void testMalformedLink() throws Exception {
+    def entry = EventLog.formatForLog(new Notification("xxx", '<a href="a">link<a/>', "content", NotificationType.ERROR))
+    assert entry.message ==  'link: content (show balloon)'
+  }
+
 }