From 8f14c5e1ebaa2512db6df5d9e005a1c7eb326178 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 25 Jul 2013 22:14:59 +0200 Subject: [PATCH] Fix parsing of links with ... in URL (#1489192) --- program/lib/Roundcube/rcube_string_replacer.php | 2 +- tests/Framework/StringReplacer.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php index 02d5856cc..acdc4e317 100644 --- a/program/lib/Roundcube/rcube_string_replacer.php +++ b/program/lib/Roundcube/rcube_string_replacer.php @@ -38,7 +38,7 @@ class rcube_string_replacer $url1 = '.:;,'; $url2 = 'a-zA-Z0-9%=#$@+?!&\\/_~\\[\\]\\(\\){}\*-'; - $this->link_pattern = "/([\w]+:\/\/|\W[Ww][Ww][Ww]\.|^[Ww][Ww][Ww]\.)($utf_domain([$url1]?[$url2]+)*)/"; + $this->link_pattern = "/([\w]+:\/\/|\W[Ww][Ww][Ww]\.|^[Ww][Ww][Ww]\.)($utf_domain([$url1]*[$url2]+)*)/"; $this->mailto_pattern = "/(" ."[-\w!\#\$%&\'*+~\/^`|{}=]+(?:\.[-\w!\#\$%&\'*+~\/^`|{}=]+)*" // local-part ."@$utf_domain" // domain-part diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php index ee9efac4e..e8a762a39 100644 --- a/tests/Framework/StringReplacer.php +++ b/tests/Framework/StringReplacer.php @@ -27,6 +27,7 @@ class Framework_StringReplacer extends PHPUnit_Framework_TestCase array('http://domain.tld/path*path2', 'http://domain.tld/path*path2'), array("Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF", "Click this link:\nhttps://mail.xn--brderli-o2a.ch/rc/ EOF"), array('Start http://localhost/?foo End', 'Start http://localhost/?foo End'), + array('http://localhost/?foo=bar. Period', 'http://localhost/?foo=bar. Period'), array('www.domain.tld', 'www.domain.tld'), array('WWW.DOMAIN.TLD', 'WWW.DOMAIN.TLD'), array('[http://link.com]', '[http://link.com]'), @@ -35,6 +36,7 @@ class Framework_StringReplacer extends PHPUnit_Framework_TestCase array('(http://link.com)', '(http://link.com)'), array('http://link.com?a(b)c', 'http://link.com?a(b)c'), array('http://link.com?(link)', 'http://link.com?(link)'), + array('https://github.com/a/b/compare/3a0f82...1f4b2a after', 'https://github.com/a/b/compare/3a0f82...1f4b2a after'), array('http://', 'http://'), array('http://', 'http://'), array('1@1.com www.domain.tld', '1@1.com www.domain.tld'),