Changeset 4401 in subversion
- Timestamp:
- Jan 10, 2011 8:22:45 AM (2 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_string_replacer.php (modified) (4 diffs)
-
tests/mailfunc.php (modified) (1 diff)
-
tests/src/plainbody.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r4396 r4401 11 11 - Add handling of multifolder METADATA/ANNOTATION responses 12 12 - Fix handling of INBOX when personal namespace prefix is non-empty (#1487657) 13 - Fix handling square brackets in links (#1487672) 13 14 14 15 RELEASE 0.5-RC -
trunk/roundcubemail/program/include/rcube_string_replacer.php
r4142 r4401 38 38 // Simplified domain expression for UTF8 characters handling 39 39 $utf_domain = '[^?&@"\'\\/()\s\r\t\n]+\\.[a-z]{2,5}'; 40 $url = '[a-z0-9%=#@+?.:;&\\/_~ -]+';40 $url = '[a-z0-9%=#@+?.:;&\\/_~\\[\\]-]+'; 41 41 42 42 $this->link_pattern = "/([\w]+:\/\/|\Wwww\.)($utf_domain($url)?)/i"; … … 82 82 if (preg_match('!^(http|ftp|file)s?://!', $scheme)) { 83 83 $url = $matches[1] . $matches[2]; 84 $i = $this->add(html::a(array('href' => $url, 'target' => '_blank'), Q($url)));85 84 } 86 85 else if (preg_match('/^(\W)www\.$/', $matches[1], $m)) { 87 $url = 'www.' . $matches[2]; 88 $i = $this->add($m[1] . html::a(array('href' => 'http://' . $url, 'target' => '_blank'), Q($url))); 86 $url = 'www.' . $matches[2]; 87 $url_prefix = 'http://'; 88 $prefix = $m[1]; 89 89 } 90 91 $suffix = $this->parse_url_brackets($url); 92 $i = $this->add($prefix . html::a(array( 93 'href' => $url_prefix . $url, 94 'target' => '_blank' 95 ), Q($url)) . $suffix); 90 96 91 97 // Return valid link for recognized schemes, otherwise, return the unmodified string for unrecognized schemes. … … 101 107 public function mailto_callback($matches) 102 108 { 109 $href = $matches[1]; 110 $suffix = $this->parse_url_brackets($href); 111 103 112 $i = $this->add(html::a(array( 104 'href' => 'mailto:' . $matches[1], 105 'onclick' => "return ".JS_OBJECT_NAME.".command('compose','".JQ($matches[1])."',this)", 106 ), 107 Q($matches[1]))); 113 'href' => 'mailto:' . $href, 114 'onclick' => "return ".JS_OBJECT_NAME.".command('compose','".JQ($href)."',this)", 115 ), Q($href)) . $suffix); 108 116 109 117 return $i >= 0 ? $this->get_replacement($i) : ''; … … 130 138 } 131 139 140 /** 141 * Fixes bracket characters in URL handling 142 */ 143 public static function parse_url_brackets(&$url) 144 { 145 // #1487672: special handling of square brackets, 146 // URL regexp allows [] characters in URL, for example: 147 // "http://example.com/?a[b]=c". However we need to handle 148 // properly situation when a bracket is placed at the end 149 // of the link e.g. "[http://example.com]" 150 if (preg_match('/(\\[|\\])/', $url)) { 151 $in = false; 152 for ($i=0, $len=strlen($url); $i<$len; $i++) { 153 if ($url[$i] == '[') { 154 if ($in) 155 break; 156 $in = true; 157 } 158 else if ($url[$i] == ']') { 159 if (!$in) 160 break; 161 $in = false; 162 } 163 } 164 165 if ($i<$len) { 166 $suffix = substr($url, $i); 167 $url = substr($url, 0, $i); 168 } 169 } 170 171 return $suffix; 172 } 173 132 174 } -
trunk/roundcubemail/tests/mailfunc.php
r4110 r4401 111 111 $part->body = quoted_printable_decode(file_get_contents(TESTS_DIR . 'src/plainbody.txt')); 112 112 $html = rcmail_print_body($part, array('safe' => true)); 113 113 114 114 $this->assertPattern('/<a href="mailto:nobody@roundcube.net" onclick="return rcmail.command\(\'compose\',\'nobody@roundcube.net\',this\)">nobody@roundcube.net<\/a>/', $html, "Mailto links with onclick"); 115 115 $this->assertPattern('#<a href="http://www.apple.com/legal/privacy/" target="_blank">http://www.apple.com/legal/privacy/</a>#', $html, "Links with target=_blank"); 116 $this->assertPattern('#\\[<a href="http://example.com/\\?tx\\[a\\]=5" target="_blank">http://example.com/\\?tx\\[a\\]=5</a>\\]#', $html, "Links with square brackets"); 116 117 } 117 118 -
trunk/roundcubemail/tests/src/plainbody.txt
r2323 r4401 36 36 https://myinfo.apple.com/cgi-bin/WebObjects/MyInfo 37 37 38 -[http://example.com/?tx[a]=5]-
Note: See TracChangeset
for help on using the changeset viewer.
