diff --git a/include/class.format.php b/include/class.format.php
index 31650f2c6f9a77d5839d061585414d717ac0fb55..489b52219e6fe8b2eaa2635ea2a2ec3acfc140f6 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -314,10 +314,10 @@ class Format {
             function($match) use ($token) {
                 // Scan for things that look like URLs
                 $links = preg_replace_callback(
-                    '`(?<!>)(((f|ht)tp(s?)://|(?<!//)www\.)([a-zA-Z0-9_-]+(\.|/|$))+\S*)`',
+                    '`(?<!>)(((f|ht)tp(s?)://|(?<!//)www\.)([-+~%/.\w]+)(?:[-?#+=&;%@.\w]*)?)`',
                     function ($match) use ($token) {
                         if (in_array(substr($match[1], -1),
-                                array(',','.','?','!',':',';'))) {
+                                array('.','?','-',':',';'))) {
                             $match[7] = substr($match[1], -1);
                             $match[1] = substr($match[1], 0, strlen($match[1])-1);
                         }