Development

Changeset 3408

You must first sign up to be able to contribute.

Changeset 3408

Show
Ignore:
Timestamp:
02/06/07 09:05:36 (2 years ago)
Author:
fabien
Message:

fixed bug in TextHelper? SF_AUTO_LINK_RE (closes #1406)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/helper/TextHelper.php

    r2386 r3408  
    156156if (!defined('SF_AUTO_LINK_RE')) 
    157157{ 
    158   define('SF_AUTO_LINK_RE', '/ 
     158  define('SF_AUTO_LINK_RE', '~ 
    159159    (                       # leading text 
    160160      <\w+.*?>|             #   leading HTML tag, or 
    161       [^=!:\'"\/]|          #   leading punctuation, or 
     161      [^=!:\'"/]|           #   leading punctuation, or 
    162162      ^                     #   beginning of line 
    163163    ) 
    164164    ( 
    165       (?:http[s]?:\/\/)|    # protocol spec, or 
     165      (?:https?://)|        # protocol spec, or 
    166166      (?:www\.)             # www.* 
    167     )  
     167    ) 
    168168    ( 
    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 
    172175    ) 
    173176    ([[:punct:]]|\s|<|$)    # trailing text 
    174    /x'); 
     177   ~x'); 
    175178} 
    176179 
     
    190193      else 
    191194      { 
    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]; 
    193196      } 
    194197    ') 
  • branches/1.0/test/unit/helper/TextHelperTest.php

    r3336 r3408  
    1313sfLoader::loadHelpers(array('Helper', 'Tag', 'Text')); 
    1414 
    15 $t = new lime_test(41, new lime_output_color()); 
     15$t = new lime_test(42, new lime_output_color()); 
    1616 
    1717// truncate_text() 
     
    111111$t->is(auto_link_text('<p>Link '.$link2_raw.'</p>'), '<p>Link '.$link2_result.'</p>', 'auto_linking() converts URLs to links'); 
    112112$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');