Index: trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 13161)
+++ trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 13162)
@@ -19,4 +19,5 @@
 import java.util.Collections;
 import java.util.List;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -79,4 +80,8 @@
     private static final Pattern SENTENCE_MARKS_EASTERN = Pattern.compile("(\\u3002)([\\p{L}\\p{Punct}])");
 
+    private static final Pattern HTTP_LINK = Pattern.compile("(https?://[^\\s\\(\\)<>]+)");
+    private static final Pattern HTML_LINK = Pattern.compile("<a href=\"[^\"]+\">([^<]+)</a>");
+    private static final Pattern SLASH = Pattern.compile("([^/])/([^/])");
+
     private final NoteData noteData;
 
@@ -231,12 +236,14 @@
     private void fixPanelSize(MapView mv, String text) {
         int maxWidth = mv.getWidth() * 2/3;
+        int maxHeight = mv.getHeight() * 2/3;
         JEditorPane pane = displayedPanel.getEditorPane();
-        if (pane.getPreferredSize().width > maxWidth && Config.getPref().getBoolean("note.text.break-on-sentence-mark", false)) {
+        Dimension d = pane.getPreferredSize();
+        if ((d.width > maxWidth || d.height > maxHeight) && Config.getPref().getBoolean("note.text.break-on-sentence-mark", false)) {
             // To make sure long notes are displayed correctly
             displayedPanel.setText(insertLineBreaks(text));
         }
         // If still too large, enforce maximum size
-        Dimension d = pane.getPreferredSize();
-        if (d.width > maxWidth) {
+        d = pane.getPreferredSize();
+        if (d.width > maxWidth || d.height > maxHeight) {
             View v = (View) pane.getClientProperty(BasicHTML.propertyKey);
             if (v == null) {
@@ -290,5 +297,5 @@
                 htmlText = htmlText.replace("&#xA;", "<br>");
                 // convert URLs to proper HTML links
-                htmlText = htmlText.replaceAll("(https?://[^\\s\\(\\)<>]+)", "<a href=\"$1\">$1</a>");
+                htmlText = replaceLinks(htmlText);
                 sb.append(htmlText);
             }
@@ -297,4 +304,25 @@
         String result = sb.toString();
         Logging.debug(result);
+        return result;
+    }
+
+    static String replaceLinks(String htmlText) {
+        String result = HTTP_LINK.matcher(htmlText).replaceAll("<a href=\"$1\">$1</a>");
+        Matcher m1 = HTML_LINK.matcher(result);
+        if (m1.find()) {
+            int last = 0;
+            StringBuffer sb = new StringBuffer(); // Switch to StringBuilder when switching to Java 9
+            do {
+                sb.append(result, last, m1.start());
+                last = m1.end();
+                String link = m1.group(0);
+                Matcher m2 = SLASH.matcher(link).region(link.indexOf('>'), link.lastIndexOf('<'));
+                while (m2.find()) {
+                    m2.appendReplacement(sb, "$1/\u200b$2"); //zero width space to wrap long URLs (see #10864, #15550)
+                }
+                m2.appendTail(sb);
+            } while (m1.find());
+            result = sb.append(result, last, result.length()).toString();
+        }
         return result;
     }
Index: trunk/test/unit/org/openstreetmap/josm/gui/layer/NoteLayerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/layer/NoteLayerTest.java	(revision 13161)
+++ trunk/test/unit/org/openstreetmap/josm/gui/layer/NoteLayerTest.java	(revision 13162)
@@ -56,3 +56,22 @@
         // CHECKSTYLE.ON: LineLength
     }
+
+    /**
+     * Unit test of {@link NoteLayer#replaceLinks}.
+     */
+    @Test
+    public void testReplaceLinks() {
+        // empty string
+        assertEquals("", NoteLayer.replaceLinks(""));
+        // no link
+        assertEquals("no http link", NoteLayer.replaceLinks("no http link"));
+        // just one link
+        assertEquals("<a href=\"https://www.example.com/test\">https://www.example.com/\u200btest</a>",
+                NoteLayer.replaceLinks("https://www.example.com/test"));
+        // CHECKSTYLE.OFF: LineLength
+        // text with several links (with and without slash)
+        assertEquals("foo <a href=\"https://foo.example.com/test\">https://foo.example.com/\u200btest</a> bar <a href=\"https://bar.example.com\">https://bar.example.com</a> baz",
+                NoteLayer.replaceLinks("foo https://foo.example.com/test bar https://bar.example.com baz"));
+        // CHECKSTYLE.ON: LineLength
+    }
 }
