Changeset 1513

Show
Ignore:
Timestamp:
07/01/06 11:08:52 (2 years ago)
Author:
mbonetti
Message:

Better url filtering (it actually works, now :)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/plugins/urlfilter.php

    r1181 r1513  
    3131/// Author: Marco Bonetti 
    3232/// Description: This plugin will try to make ugly URL links look better 
    33 /// Version: 1.6 
     33/// Version: 1.7 
    3434 
    3535/** 
     
    3838 */ 
    3939function __urlfilter_filter($in) { 
    40     $match = '|<a[^>]+?href="(.*?)">\\1</a>|i'; 
    41     return preg_replace_callback($match, '__filter_callback', $in); 
     40    $match = '#<a[^>]+?href="(.*?)">\\1</a>#im'; 
     41    // matches non-linkified URLs 
     42    $match2 = '#[^>"\'](http[^\s$]+)[\s$]?#im'; 
     43    $ret= preg_replace_callback($match, '__filter_callback', $in); 
     44    $ret2= preg_replace_callback($match2,'__filter_callback', $ret); 
     45    return $ret2; 
    4246} 
    4347 
     
    4953    $ret = preg_match("/^(http:\/\/)?([^\/]+)/i", $matches[1], $outmatches); 
    5054    if ($outmatches && isset ($outmatches[2])) { 
    51         return "<a href=\"". $matches[1]."\">[" . $outmatches[2] . "]</a>"; 
     55        return " <a href=\"". $matches[1]."\">[" . $outmatches[2] . "]</a> "; 
    5256    } 
    53     return "<a href=\"". $matches[1]."\">[" . $matches[1] . "]</a>"; 
     57    return " <a href=\"". $matches[1]."\">[" . $matches[1] . "]</a> "; 
    5458}  
    5559