1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-31 11:39:37 +02:00

Merge remote-tracking branch 'fredsa/ticket/11606' into develop

* fredsa/ticket/11606:
  [ticket/11606] remove preg_replace() /e modifier in make_clickable()
This commit is contained in:
Andreas Fischer 2013-09-23 02:25:13 +02:00
commit 41dd9d3b49

View File

@ -727,37 +727,58 @@ function make_clickable($text, $server_url = false, $class = 'postlink')
$server_url = generate_board_url();
}
static $magic_url_match;
static $magic_url_replace;
static $static_class;
static $magic_url_match_args;
if (!is_array($magic_url_match) || $static_class != $class)
if (!is_array($magic_url_match_args) || $static_class != $class)
{
$static_class = $class;
$class = ($static_class) ? ' class="' . $static_class . '"' : '';
$local_class = ($static_class) ? ' class="' . $static_class . '-local"' : '';
$magic_url_match = $magic_url_replace = array();
// Be sure to not let the matches cross over. ;)
$magic_url_match_args = array();
// relative urls for this board
$magic_url_match[] = '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '$local_class')";
$magic_url_match_args[] = array(
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#i',
MAGIC_URL_LOCAL,
$local_class,
);
// matches a xxxx://aaaaa.bbb.cccc. ...
$magic_url_match[] = '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#ie';
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '$class')";
$magic_url_match_args[] = array(
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#i',
MAGIC_URL_FULL,
$class,
);
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
$magic_url_match[] = '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#ie';
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '$class')";
$magic_url_match_args[] = array(
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#i',
MAGIC_URL_WWW,
$class,
);
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
$magic_url_match[] = '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/ie';
$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')";
$magic_url_match_args[] = array(
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/i',
MAGIC_URL_EMAIL,
'',
);
}
return preg_replace($magic_url_match, $magic_url_replace, $text);
foreach ($magic_url_match_args as $magic_args)
{
if (preg_match($magic_args[0], $text, $matches))
{
$text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args)
{
return make_clickable_callback($magic_args[1], $matches[1], $matches[2], $matches[3], $magic_args[2]);
}, $text);
}
}
return $text;
}
/**