Require balanced parens in hyperlinks, otherwise exclude it.

This makes links like "(http://foo/)" render more accurately,
by skipping the parens the user placed around the link.

Bug: GERRIT-163
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
index 7bdd0db..4c61588 100644
--- a/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
@@ -71,7 +71,13 @@
   /** Convert bare http:// and https:// URLs into &lt;a href&gt; tags. */
   public SafeHtml linkify() {
     return replaceAll(
-        "(https?://[a-zA-Z0-9$_.+!*',%;:@&=?#/()-]{1,}[a-zA-Z0-9$_.+!*',%;:@&=?#/-])",
+        "(https?://" +
+          "[a-zA-Z0-9$_.+!*',%;:@&=?#/-]{2,}" +
+          "([(]" +
+          "[a-zA-Z0-9$_.+!*',%;:@&=?#/-]*" +
+          "[)])*" +
+          "[a-zA-Z0-9$_.+!*',%;:@&=?#/-]*" +
+        ")",
         "<a href=\"$1\">$1</a>");
   }