diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
index 143ecef87e..a71120adfd 100644
--- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
+++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
@@ -122,8 +122,9 @@ public abstract class SafeHtml
/** Convert bare http:// and https:// URLs into <a href> tags. */
public SafeHtml linkify() {
final String part = "(?:" +
- "[a-zA-Z0-9$_.+!*',%;:@=?#/~-]" +
+ "[a-zA-Z0-9$_+!*'%;:@=?#/~-]" +
"|&(?!lt;|gt;)" +
+ "|[.,](?!(?:\\s|$))" +
")";
return replaceAll(
"(https?://" +
diff --git a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java
index 749df176ab..75c37459bc 100644
--- a/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java
+++ b/gerrit-gwtexpui/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_LinkifyTest.java
@@ -60,6 +60,38 @@ public class SafeHtml_LinkifyTest {
assertEquals("A <http://go.here/> B", n.asString());
}
+ @Test
+ public void testLinkify_TrailingPlainLetter() {
+ final SafeHtml o = html("A http://go.here/foo B");
+ final SafeHtml n = o.linkify();
+ assertNotSame(o, n);
+ assertEquals("A http://go.here/foo B", n.asString());
+ }
+
+ @Test
+ public void testLinkify_TrailingDot() {
+ final SafeHtml o = html("A http://go.here/. B");
+ final SafeHtml n = o.linkify();
+ assertNotSame(o, n);
+ assertEquals("A http://go.here/. B", n.asString());
+ }
+
+ @Test
+ public void testLinkify_TrailingComma() {
+ final SafeHtml o = html("A http://go.here/, B");
+ final SafeHtml n = o.linkify();
+ assertNotSame(o, n);
+ assertEquals("A http://go.here/, B", n.asString());
+ }
+
+ @Test
+ public void testLinkify_TrailingDotDot() {
+ final SafeHtml o = html("A http://go.here/.. B");
+ final SafeHtml n = o.linkify();
+ assertNotSame(o, n);
+ assertEquals("A http://go.here/.. B", n.asString());
+ }
+
private static SafeHtml html(String text) {
return new SafeHtmlBuilder().append(text).toSafeHtml();
}