Changeset 3408
- Timestamp:
- 02/06/07 09:05:36 (2 years ago)
- Files:
-
- branches/1.0/lib/helper/TextHelper.php (modified) (2 diffs)
- branches/1.0/test/unit/helper/TextHelperTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/lib/helper/TextHelper.php
r2386 r3408 156 156 if (!defined('SF_AUTO_LINK_RE')) 157 157 { 158 define('SF_AUTO_LINK_RE', ' /158 define('SF_AUTO_LINK_RE', '~ 159 159 ( # leading text 160 160 <\w+.*?>| # leading HTML tag, or 161 [^=!:\'" \/]|# leading punctuation, or161 [^=!:\'"/]| # leading punctuation, or 162 162 ^ # beginning of line 163 163 ) 164 164 ( 165 (?:http [s]?:\/\/)|# protocol spec, or165 (?:https?://)| # protocol spec, or 166 166 (?:www\.) # www.* 167 ) 167 ) 168 168 ( 169 ([\w]+:?[=?&\/.-]?)* # url segment 170 \w+[\/]? # url tail 171 (?:\#\w*)? # trailing anchor 169 [-\w]+ # subdomain or domain 170 (?:\.[-\w]+)* # remaining subdomains or domain 171 (?::\d+)? # port 172 (?:/(?:(?:[\~\w\+%-]|(?:[,.;:][^\s$]))+)?)* # path 173 (?:\?[\w\+%&=.;-]+)? # query string 174 (?:\#[\w\-]*)? # trailing anchor 172 175 ) 173 176 ([[:punct:]]|\s|<|$) # trailing text 174 /x');177 ~x'); 175 178 } 176 179 … … 190 193 else 191 194 { 192 return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"'.$href_options.'>\'.$matches[2].$matches[3].\'</a>\'.$matches[ 5];195 return $matches[1].\'<a href="\'.($matches[2] == "www." ? "http://www." : $matches[2]).$matches[3].\'"'.$href_options.'>\'.$matches[2].$matches[3].\'</a>\'.$matches[4]; 193 196 } 194 197 ') branches/1.0/test/unit/helper/TextHelperTest.php
r3336 r3408 13 13 sfLoader::loadHelpers(array('Helper', 'Tag', 'Text')); 14 14 15 $t = new lime_test(4 1, new lime_output_color());15 $t = new lime_test(42, new lime_output_color()); 16 16 17 17 // truncate_text() … … 111 111 $t->is(auto_link_text('<p>Link '.$link2_raw.'</p>'), '<p>Link '.$link2_result.'</p>', 'auto_linking() converts URLs to links'); 112 112 $t->is(auto_link_text('<p>'.$link2_raw.' Link</p>'), '<p>'.$link2_result.' Link</p>', 'auto_linking() converts URLs to links'); 113 $t->is(auto_link_text('<p>http://www.google.com/?q=symfony Link</p>'), '<p><a href="http://www.google.com/?q=symfony">http://www.google.com/?q=symfony</a> Link</p>', 'auto_linking() converts URLs to links');