Opened 3 years ago

Closed 3 years ago

#1487787 closed Bugs (duplicate)

HTML link generator includes trailing punctuation (with patch)

Reported by: joshmalone Owned by:
Priority: 5 Milestone: 0.6-beta
Component: PHP backend Version: 0.5
Severity: normal Keywords:
Cc:

Description

The function link_callback() in rcube_string_replacer.php allows trailing punctuation to be included in the link. The breaks URLs that occur at the end of a sentance.

My proposed 1-line fix seems to be working on my site. This diff is against 0.5. I don't see this as being fixed in the changelog, but apologies if this has already been addressed.

diff -u -r1.1 rcube_string_replacer.php
--- rcube_string_replacer.php   2011/02/15 16:17:24     1.1
+++ rcube_string_replacer.php   2011/02/15 16:24:06
@@ -81,7 +81,7 @@
 
     if (preg_match('!^(http|ftp|file)s?://!', $scheme)) {
       $url = $matches[1] . $matches[2];
-      $i = $this->add(html::a(array('href' => $url, 'target' => '_blank'), Q($url)));
+      $i = $this->add(html::a(array('href' => rtrim($url, '.!? '), 'target' => '_blank'), Q($url)));
     }
     else if (preg_match('/^(\W)www\.$/', $matches[1], $m)) {
       $url = 'www.' . $matches[2];
@@ -129,4 +129,4 @@
     return preg_replace_callback(self::$pattern, array($this, 'replace_callback'), $str);
   }
 
-}
\ No newline at end of file
+}

Change History (1)

comment:1 Changed 3 years ago by alec

  • Component changed from Addressbook to PHP backend
  • Milestone changed from later to 0.6-beta
  • Resolution set to duplicate
  • Status changed from new to closed

I see it was fixed in [a1013c03].

Note: See TracTickets for help on using tickets.