Line 320 | Line 320 |
---|
* Generates a text with approx. the specified length which contains the specified words and their context * * @param string $text The full text from which context shall be extracted
|
* Generates a text with approx. the specified length which contains the specified words and their context * * @param string $text The full text from which context shall be extracted
|
* @param string $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
| * @param array $words An array of words which should be contained in the result, has to be a valid part of a PCRE pattern (escape with preg_quote!)
|
* @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value * * @return string Context of the specified words separated by "..."
| * @param int $length The desired length of the resulting text, however the result might be shorter or longer than this value * * @return string Context of the specified words separated by "..."
|
Line 532 | Line 532 |
---|
if (preg_match('#^<[rt][ >]#', $text)) {
|
if (preg_match('#^<[rt][ >]#', $text)) {
|
$text = $phpbb_container->get('text_formatter.utils')->clean_formatting($text);
| $text = utf8_htmlspecialchars($phpbb_container->get('text_formatter.utils')->clean_formatting($text));
|
} else {
| } else {
|
Line 803 | Line 803 |
---|
$orig_url = $url; $orig_relative = $relative_url; $append = '';
|
$orig_url = $url; $orig_relative = $relative_url; $append = '';
|
$url = htmlspecialchars_decode($url); $relative_url = htmlspecialchars_decode($relative_url);
| $url = html_entity_decode($url, ENT_COMPAT); $relative_url = html_entity_decode($relative_url, ENT_COMPAT);
|
// make sure no HTML entities were matched $chars = array('<', '>', '"');
| // make sure no HTML entities were matched $chars = array('<', '>', '"');
|
Line 911 | Line 911 |
---|
break; }
|
break; }
|
$url = htmlspecialchars($url); $text = htmlspecialchars($text); $append = htmlspecialchars($append);
| $url = htmlspecialchars($url, ENT_COMPAT); $text = htmlspecialchars($text, ENT_COMPAT); $append = htmlspecialchars($append, ENT_COMPAT);
|
$html = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
| $html = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
|
Line 921 | Line 921 |
---|
}
/**
|
}
/**
|
* make_clickable function * * Replace magic urls of form http://xxx.xxx., www.xxx. and [email protected].
| * Replaces magic urls of form http://xxx.xxx., www.xxx. and [email protected].
|
* Cuts down displayed size of link if over 50 chars, turns absolute links * into relative versions when the server/script path matches the link
|
* Cuts down displayed size of link if over 50 chars, turns absolute links * into relative versions when the server/script path matches the link
|
| * * @param string $text Message text to parse URL/email entries * @param bool|string $server_url The server URL. If false, the board URL will be used * @param string $class CSS class selector to add to the parsed URL entries * * @return string A text with parsed URL/email entries
|
*/
|
*/
|
function make_clickable($text, $server_url = false, $class = 'postlink')
| function make_clickable($text, $server_url = false, string $class = 'postlink')
|
{ if ($server_url === false) {
| { if ($server_url === false) {
|
Line 948 | Line 952 |
---|
$magic_url_match_args = array(); }
|
$magic_url_match_args = array(); }
|
| // Check if the match for this $server_url and $class already exists $element_exists = false; if (isset($magic_url_match_args[$server_url])) { array_walk_recursive($magic_url_match_args[$server_url], function($value) use (&$element_exists, $static_class) { if ($value == $static_class) { $element_exists = true; return; } } ); }
// Only add new $server_url and $class matches if not exist if (!$element_exists) {
|
// relative urls for this board
|
// relative urls for this board
|
$magic_url_match_args[$server_url][] = array(
| $magic_url_match_args[$server_url][] = [
|
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu', MAGIC_URL_LOCAL, $local_class,
|
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu', MAGIC_URL_LOCAL, $local_class,
|
);
| $static_class, ];
|
// matches a xxxx://aaaaa.bbb.cccc. ...
|
// matches a xxxx://aaaaa.bbb.cccc. ...
|
$magic_url_match_args[$server_url][] = array(
| $magic_url_match_args[$server_url][] = [
|
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu', MAGIC_URL_FULL, $class,
|
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu', MAGIC_URL_FULL, $class,
|
);
| $static_class, ];
|
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
|
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
|
$magic_url_match_args[$server_url][] = array(
| $magic_url_match_args[$server_url][] = [
|
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu', MAGIC_URL_WWW, $class,
|
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu', MAGIC_URL_WWW, $class,
|
);
| $static_class, ]; }
|
|
|
| if (!isset($magic_url_match_args[$server_url]['email'])) {
|
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
|
// 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_args[$server_url][] = array(
| $magic_url_match_args[$server_url]['email'] = [
|
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu', MAGIC_URL_EMAIL, '',
|
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu', MAGIC_URL_EMAIL, '',
|
);
| ]; }
|
}
foreach ($magic_url_match_args[$server_url] as $magic_args) { if (preg_match($magic_args[0], $text, $matches)) {
|
}
foreach ($magic_url_match_args[$server_url] as $magic_args) { if (preg_match($magic_args[0], $text, $matches)) {
|
| // Only apply $class from the corresponding function call argument (excepting emails which never has a class) if ($magic_args[1] != MAGIC_URL_EMAIL && $magic_args[3] != $static_class) { continue; }
|
$text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args) { $relative_url = isset($matches[3]) ? $matches[3] : '';
| $text = preg_replace_callback($magic_args[0], function($matches) use ($magic_args) { $relative_url = isset($matches[3]) ? $matches[3] : '';
|
Line 1053 | Line 1088 |
---|
} else {
|
} else {
|
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();
| $root_path = $phpbb_path_helper->get_web_root_path();
|
/** * Event to override the root_path for smilies
| /** * Event to override the root_path for smilies
|
Line 1166 | Line 1201 |
---|
$filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);
$upload_icon = '';
|
$filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);
$upload_icon = '';
|
| $download_link = ''; $display_cat = false;
|
if (isset($extensions[$attachment['extension']])) {
| if (isset($extensions[$attachment['extension']])) {
|
Line 1325 | Line 1362 |
---|
); extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars))); $update_count_ary = $update_count;
|
); extract($phpbb_dispatcher->trigger_event('core.parse_attachments_modify_template_data', compact($vars))); $update_count_ary = $update_count;
|
unset($update_count);
| unset($update_count, $display_cat, $download_link);
|
$template->assign_block_vars('_file', $block_array);
| $template->assign_block_vars('_file', $block_array);
|
Line 1419 | Line 1456 |
---|
$string = substr($string, 4); }
|
$string = substr($string, 4); }
|
$_chars = utf8_str_split(htmlspecialchars_decode($string));
| $_chars = utf8_str_split(html_entity_decode($string, ENT_COMPAT));
|
$chars = array_map('utf8_htmlspecialchars', $_chars);
// Now check the length ;)
| $chars = array_map('utf8_htmlspecialchars', $_chars);
// Now check the length ;)
|
Line 1434 | Line 1471 |
---|
if (utf8_strlen($string) > $max_store_length) { // let's split again, we do not want half-baked strings where entities are split
|
if (utf8_strlen($string) > $max_store_length) { // let's split again, we do not want half-baked strings where entities are split
|
$_chars = utf8_str_split(htmlspecialchars_decode($string));
| $_chars = utf8_str_split(html_entity_decode($string, ENT_COMPAT));
|
$chars = array_map('utf8_htmlspecialchars', $_chars);
do
| $chars = array_map('utf8_htmlspecialchars', $_chars);
do
|