Skip to content

Commit

Permalink
Merge pull request graulund#63 from Tenzer/preg_replace-php_5.5_fix
Browse files Browse the repository at this point in the history
Replaced deprecated preg_replace /e flag with preg_replace_callback
  • Loading branch information
graulund committed Dec 20, 2013
2 parents 5474612 + 55470ef commit 82a8d17
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions inc/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,28 @@ function linkifyTweet($str, $linksOnly = false){
'(?<!title=\"http:\/\/)(?<!title=\"https:\/\/)' .
'(?<!data-image=\")(?<!data-image=\"http:\/\/)(?<!data-image=\"https:\/\/)';
// Expression
$html = preg_replace("/$lookbehind\b(((https?:\/\/)|www\.).+?)(([!?,.\"\)]+)?(\s|$))/e", "_linkifyTweet_link('$1', '$2', '$3', '$4')", $str);
$html = preg_replace_callback(
"/$lookbehind\b(((https?:\/\/)|www\.).+?)(([!?,.\"\)]+)?(\s|$))/",
function ($m) {
return _linkifyTweet_link($m[1], $m[2], $m[3], $m[4]);
},
$str
);
if(!$linksOnly){
$html = preg_replace("/\B\@([a-zA-Z0-9_]{1,20}(\/\w+)?)/e", "_linkifyTweet_at('$1', '$2')", $html);
$html = preg_replace("/\B\#([\pL|0-9|_]+)/eu", "_linkifyTweet_hashtag('$1', '$2')", $html);
$html = preg_replace_callback(
"/\B\@([a-zA-Z0-9_]{1,20}(\/\w+)?)/",
function ($m) {
return _linkifyTweet_at($m[1], $m[2]);
},
$html
);
$html = preg_replace_callback(
"/\B\#([\pL|0-9|_]+)/u",
function ($m) {
return _linkifyTweet_hashtag($m[1], $m[2]);
},
$html
);
}
return $html;
}
Expand Down

0 comments on commit 82a8d17

Please sign in to comment.