Teach SafeHtml.linkify() to honor RFC 1738 and to skip trailing ")"

By using a more faithful regexp to the RFC 1738 documentation
we automatically handle <http://foo> style links better, by not
including the leading/trailing <>, as these are not valid in a URL
unless they are escaped.

Although RFC 1738 says "(" and ")" are valid in a URL, we skip the
trailing ")" if present, assuming the reference was embedded inside
a comment, such as "blah blah ... (See also http://foo)".

Bug: GERRIT-108
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 eef4a96..0a7505a 100644
--- a/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
@@ -50,7 +50,7 @@
 
   /** Convert bare http:// and https:// URLs into &lt;a href&gt; tags. */
   public SafeHtml linkify() {
-    return replaceAll("(https?://[^ \n\r\t]*)", "<a href=\"$1\">$1</a>");
+    return replaceAll("(https?://[a-zA-Z0-9$_.+!*',%;:@&=?#/()-]{1,}[a-zA-Z0-9$_.+!*',%;:@&=?#/-])", "<a href=\"$1\">$1</a>");
   }
 
   /**