aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/composer.lock112
-rw-r--r--phpBB/config/default/container/services_notification.yml2
-rw-r--r--phpBB/config/default/container/services_text_formatter.yml1
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php8
-rw-r--r--phpBB/includes/functions.php38
-rw-r--r--phpBB/includes/functions_compatibility.php9
-rw-r--r--phpBB/includes/functions_user.php112
-rw-r--r--phpBB/includes/message_parser.php15
-rw-r--r--phpBB/phpbb/notification/type/quote.php31
-rw-r--r--phpBB/phpbb/textformatter/parser_interface.php3
-rw-r--r--phpBB/phpbb/textformatter/s9e/parser.php34
-rw-r--r--phpBB/phpbb/textformatter/s9e/utils.php25
-rw-r--r--phpBB/phpbb/textformatter/utils_interface.php8
-rw-r--r--phpBB/posting.php13
14 files changed, 179 insertions, 232 deletions
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 872509884c..dc7608b37e 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "d5368b75d221b5573b30307cb2f25f3b",
+ "hash": "c14bcbf5a6c4fd121492568aa3654c07",
"packages": [
{
"name": "lusitanian/oauth",
@@ -220,12 +220,12 @@
"source": {
"type": "git",
"url": "https://github.com/s9e/TextFormatter.git",
- "reference": "31fe627a4a82d41098a2db8036287c0693c79f13"
+ "reference": "29c5959f4425934a53b6fdb42760d719b95a6e82"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/31fe627a4a82d41098a2db8036287c0693c79f13",
- "reference": "31fe627a4a82d41098a2db8036287c0693c79f13",
+ "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/29c5959f4425934a53b6fdb42760d719b95a6e82",
+ "reference": "29c5959f4425934a53b6fdb42760d719b95a6e82",
"shasum": ""
},
"require": {
@@ -270,7 +270,7 @@
"parser",
"shortcodes"
],
- "time": "2015-04-25 20:58:33"
+ "time": "2015-05-18 04:48:32"
},
{
"name": "symfony/config",
@@ -613,6 +613,56 @@
"time": "2015-04-10 08:56:33"
},
{
+ "name": "symfony/finder",
+ "version": "2.8.x-dev",
+ "target-dir": "Symfony/Component/Finder",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Finder.git",
+ "reference": "ad159e0da47e9ffe719bafdc004159ad6e395567"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Finder/zipball/ad159e0da47e9ffe719bafdc004159ad6e395567",
+ "reference": "ad159e0da47e9ffe719bafdc004159ad6e395567",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "~2.7|~3.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Finder\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ },
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ }
+ ],
+ "description": "Symfony Finder Component",
+ "homepage": "http://symfony.com",
+ "time": "2015-04-10 08:56:33"
+ },
+ {
"name": "symfony/http-foundation",
"version": "2.8.x-dev",
"target-dir": "Symfony/Component/HttpFoundation",
@@ -2572,56 +2622,6 @@
"time": "2015-04-10 08:56:33"
},
{
- "name": "symfony/finder",
- "version": "2.8.x-dev",
- "target-dir": "Symfony/Component/Finder",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Finder.git",
- "reference": "ad159e0da47e9ffe719bafdc004159ad6e395567"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Finder/zipball/ad159e0da47e9ffe719bafdc004159ad6e395567",
- "reference": "ad159e0da47e9ffe719bafdc004159ad6e395567",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.9"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7|~3.0.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.8-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Finder\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Finder Component",
- "homepage": "http://symfony.com",
- "time": "2015-04-10 08:56:33"
- },
- {
"name": "symfony/process",
"version": "2.8.x-dev",
"target-dir": "Symfony/Component/Process",
@@ -2681,6 +2681,7 @@
"symfony/dependency-injection": 20,
"symfony/event-dispatcher": 20,
"symfony/filesystem": 20,
+ "symfony/finder": 20,
"symfony/http-kernel": 20,
"symfony/routing": 20,
"symfony/security-core": 20,
@@ -2691,7 +2692,6 @@
"symfony/css-selector": 20,
"symfony/debug": 20,
"symfony/dom-crawler": 20,
- "symfony/finder": 20,
"symfony/http-foundation": 20,
"symfony/process": 20
},
diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml
index b17a172fb5..c3bbcddfa6 100644
--- a/phpBB/config/default/container/services_notification.yml
+++ b/phpBB/config/default/container/services_notification.yml
@@ -221,6 +221,8 @@ services:
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
+ calls:
+ - [set_utils, [@text_formatter.utils]]
tags:
- { name: notification.type }
diff --git a/phpBB/config/default/container/services_text_formatter.yml b/phpBB/config/default/container/services_text_formatter.yml
index 972be31b31..20436f0f64 100644
--- a/phpBB/config/default/container/services_text_formatter.yml
+++ b/phpBB/config/default/container/services_text_formatter.yml
@@ -41,7 +41,6 @@ services:
arguments:
- @cache.driver
- %text_formatter.cache.parser.key%
- - @user
- @text_formatter.s9e.factory
- @dispatcher
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index d451b4d899..2b438e5670 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -416,8 +416,6 @@ class acp_bbcodes
// Allow unicode characters for URL|LOCAL_URL|RELATIVE_URL|INTTEXT tokens
$utf8 = preg_match('/(URL|LOCAL_URL|RELATIVE_URL|INTTEXT)/', $bbcode_match);
- $utf8_pcre_properties = phpbb_pcre_utf8_support();
-
$fp_match = preg_quote($bbcode_match, '!');
$fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
$fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace);
@@ -448,7 +446,7 @@ class acp_bbcodes
'!([a-zA-Z0-9-+.,_ ]+)!' => "$1"
),
'INTTEXT' => array(
- ($utf8_pcre_properties) ? '!([\p{L}\p{N}\-+,_. ]+)!u' : '!([a-zA-Z0-9\-+,_. ]+)!u' => "$1"
+ '!([\p{L}\p{N}\-+,_. ]+)!u' => "$1"
),
'IDENTIFIER' => array(
'!([a-zA-Z0-9-_]+)!' => "$1"
@@ -468,7 +466,7 @@ class acp_bbcodes
'EMAIL' => '(' . get_preg_expression('email') . ')',
'TEXT' => '(.*?)',
'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
- 'INTTEXT' => ($utf8_pcre_properties) ? '([\p{L}\p{N}\-+,_. ]+)' : '([a-zA-Z0-9\-+,_. ]+)',
+ 'INTTEXT' => '([\p{L}\p{N}\-+,_. ]+)',
'IDENTIFIER' => '([a-zA-Z0-9-_]+)',
'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)',
'NUMBER' => '([0-9]+)',
@@ -476,7 +474,7 @@ class acp_bbcodes
$pad = 0;
$modifiers = 'i';
- $modifiers .= ($utf8 && $utf8_pcre_properties) ? 'u' : '';
+ $modifiers .= ($utf8) ? 'u' : '';
if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m))
{
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 2ed0eff81c..efb6cec8a5 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2811,31 +2811,19 @@ function get_preg_expression($mode)
* Depends on whether installed PHP version supports unicode properties
*
* @param string $word word template to be replaced
-* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
*
* @return string $preg_expr regex to use with word censor
*/
-function get_censor_preg_expression($word, $use_unicode = true)
+function get_censor_preg_expression($word)
{
// Unescape the asterisk to simplify further conversions
$word = str_replace('\*', '*', preg_quote($word, '#'));
- if ($use_unicode && phpbb_pcre_utf8_support())
- {
- // Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes
- $word = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*+(?=[\p{Nd}\p{L}_])#iu', '#^\*+#', '#\*+$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $word);
+ // Replace asterisk(s) inside the pattern, at the start and at the end of it with regexes
+ $word = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*+(?=[\p{Nd}\p{L}_])#iu', '#^\*+#', '#\*+$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $word);
- // Generate the final substitution
- $preg_expr = '#(?<![\p{Nd}\p{L}_-])(' . $word . ')(?![\p{Nd}\p{L}_-])#iu';
- }
- else
- {
- // Replace the asterisk inside the pattern, at the start and at the end of it with regexes
- $word = preg_replace(array('#(?<=\S)\*+(?=\S)#iu', '#^\*+#', '#\*+$#'), array('(\x20*?\S*?)', '\S*?', '\S*?'), $word);
-
- // Generate the final substitution
- $preg_expr = '#(?<!\S)(' . $word . ')(?!\S)#iu';
- }
+ // Generate the final substitution
+ $preg_expr = '#(?<![\p{Nd}\p{L}_-])(' . $word . ')(?![\p{Nd}\p{L}_-])#iu';
return $preg_expr;
}
@@ -4691,22 +4679,6 @@ function phpbb_user_session_handler()
}
/**
-* Check if PCRE has UTF-8 support
-* PHP may not be linked with the bundled PCRE lib and instead with an older version
-*
-* @return bool Returns true if PCRE (the regular expressions library) supports UTF-8 encoding
-*/
-function phpbb_pcre_utf8_support()
-{
- static $utf8_pcre_properties = null;
- if (is_null($utf8_pcre_properties))
- {
- $utf8_pcre_properties = (@preg_match('/\p{L}/u', 'a') !== false);
- }
- return $utf8_pcre_properties;
-}
-
-/**
* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float)
*
* @param string $input A numeric string.
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 8655203754..31019061a9 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -501,3 +501,12 @@ function phpbb_get_plural_form($rule, $number)
$language = $phpbb_container->get('language');
return $language->get_plural_form($number, $rule);
}
+
+/**
+* @return bool Always true
+* @deprecated 3.2.0-dev
+*/
+function phpbb_pcre_utf8_support()
+{
+ return true;
+}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index e8c2fbcbfa..85b6f2be62 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1647,89 +1647,37 @@ function validate_username($username, $allowed_username = false)
return 'INVALID_CHARS';
}
- $mbstring = $pcre = false;
-
- // generic UTF-8 character types supported?
- if (phpbb_pcre_utf8_support())
- {
- $pcre = true;
- }
- else if (function_exists('mb_ereg_match'))
- {
- mb_regex_encoding('UTF-8');
- $mbstring = true;
- }
-
switch ($config['allow_name_chars'])
{
case 'USERNAME_CHARS_ANY':
- $pcre = true;
$regex = '.+';
break;
case 'USERNAME_ALPHA_ONLY':
- $pcre = true;
$regex = '[A-Za-z0-9]+';
break;
case 'USERNAME_ALPHA_SPACERS':
- $pcre = true;
$regex = '[A-Za-z0-9-[\]_+ ]+';
break;
case 'USERNAME_LETTER_NUM':
- if ($pcre)
- {
- $regex = '[\p{Lu}\p{Ll}\p{N}]+';
- }
- else if ($mbstring)
- {
- $regex = '[[:upper:][:lower:][:digit:]]+';
- }
- else
- {
- $pcre = true;
- $regex = '[a-zA-Z0-9]+';
- }
+ $regex = '[\p{Lu}\p{Ll}\p{N}]+';
break;
case 'USERNAME_LETTER_NUM_SPACERS':
- if ($pcre)
- {
- $regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+';
- }
- else if ($mbstring)
- {
- $regex = '[-\]_+ \[[:upper:][:lower:][:digit:]]+';
- }
- else
- {
- $pcre = true;
- $regex = '[-\]_+ [a-zA-Z0-9]+';
- }
+ $regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+';
break;
case 'USERNAME_ASCII':
default:
- $pcre = true;
$regex = '[\x01-\x7F]+';
break;
}
- if ($pcre)
+ if (!preg_match('#^' . $regex . '$#u', $username))
{
- if (!preg_match('#^' . $regex . '$#u', $username))
- {
- return 'INVALID_CHARS';
- }
- }
- else if ($mbstring)
- {
- mb_ereg_search_init($username, '^' . $regex . '$');
- if (!mb_ereg_search())
- {
- return 'INVALID_CHARS';
- }
+ return 'INVALID_CHARS';
}
$sql = 'SELECT username
@@ -1784,35 +1732,10 @@ function validate_password($password)
return false;
}
- $pcre = $mbstring = false;
-
- // generic UTF-8 character types supported?
- if (phpbb_pcre_utf8_support())
- {
- $upp = '\p{Lu}';
- $low = '\p{Ll}';
- $num = '\p{N}';
- $sym = '[^\p{Lu}\p{Ll}\p{N}]';
- $pcre = true;
- }
- else if (function_exists('mb_ereg_match'))
- {
- mb_regex_encoding('UTF-8');
- $upp = '[[:upper:]]';
- $low = '[[:lower:]]';
- $num = '[[:digit:]]';
- $sym = '[^[:upper:][:lower:][:digit:]]';
- $mbstring = true;
- }
- else
- {
- $upp = '[A-Z]';
- $low = '[a-z]';
- $num = '[0-9]';
- $sym = '[^A-Za-z0-9]';
- $pcre = true;
- }
-
+ $upp = '\p{Lu}';
+ $low = '\p{Ll}';
+ $num = '\p{N}';
+ $sym = '[^\p{Lu}\p{Ll}\p{N}]';
$chars = array();
switch ($config['pass_complex'])
@@ -1835,24 +1758,11 @@ function validate_password($password)
$chars[] = $upp;
}
- if ($pcre)
+ foreach ($chars as $char)
{
- foreach ($chars as $char)
+ if (!preg_match('#' . $char . '#u', $password))
{
- if (!preg_match('#' . $char . '#u', $password))
- {
- return 'INVALID_CHARS';
- }
- }
- }
- else if ($mbstring)
- {
- foreach ($chars as $char)
- {
- if (mb_ereg($char, $password) === false)
- {
- return 'INVALID_CHARS';
- }
+ return 'INVALID_CHARS';
}
}
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 9fe598d7fb..8526195664 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -1250,10 +1250,25 @@ class parse_message extends bbcode_firstpass
return (!$update_this_message) ? $return_message : $this->warn_msg;
}
+ // Remove quotes that are nested too deep
+ if ($config['max_quote_depth'] > 0)
+ {
+ $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode(
+ $this->message,
+ 'quote',
+ $config['max_quote_depth']
+ );
+ }
+
// Check for errors
$errors = $parser->get_errors();
if ($errors)
{
+ foreach ($errors as $i => $args)
+ {
+ // Translate each error with $user->lang()
+ $errors[$i] = call_user_func_array(array($user, 'lang'), $args);
+ }
$this->warn_msg = array_merge($this->warn_msg, $errors);
return (!$update_this_message) ? $return_message : $this->warn_msg;
diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php
index 141f90c7ae..51edfec6f7 100644
--- a/phpBB/phpbb/notification/type/quote.php
+++ b/phpBB/phpbb/notification/type/quote.php
@@ -21,6 +21,11 @@ namespace phpbb\notification\type;
class quote extends \phpbb\notification\type\post
{
/**
+ * @var \phpbb\textformatter\utils_interface
+ */
+ protected $utils;
+
+ /**
* Get notification type name
*
* @return string
@@ -31,13 +36,6 @@ class quote extends \phpbb\notification\type\post
}
/**
- * regular expression to match to find usernames
- *
- * @var string
- */
- protected static $regular_expression_match = '#\[quote=&quot;(.+?)&quot;#';
-
- /**
* Language key used to output the text
*
* @var string
@@ -77,17 +75,16 @@ class quote extends \phpbb\notification\type\post
'ignore_users' => array(),
), $options);
- $usernames = false;
- preg_match_all(self::$regular_expression_match, $post['post_text'], $usernames);
+ $usernames = $this->utils->get_outermost_quote_authors($post['post_text']);
- if (empty($usernames[1]))
+ if (empty($usernames))
{
return array();
}
- $usernames[1] = array_unique($usernames[1]);
+ $usernames = array_unique($usernames);
- $usernames = array_map('utf8_clean_string', $usernames[1]);
+ $usernames = array_map('utf8_clean_string', $usernames);
$users = array();
@@ -187,4 +184,14 @@ class quote extends \phpbb\notification\type\post
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
));
}
+
+ /**
+ * Set the utils service used to retrieve quote authors
+ *
+ * @param \phpbb\textformatter\utils_interface $utils
+ */
+ public function set_utils(\phpbb\textformatter\utils_interface $utils)
+ {
+ $this->utils = $utils;
+ }
}
diff --git a/phpBB/phpbb/textformatter/parser_interface.php b/phpBB/phpbb/textformatter/parser_interface.php
index 3cb9f8e977..ad611fb5b4 100644
--- a/phpBB/phpbb/textformatter/parser_interface.php
+++ b/phpBB/phpbb/textformatter/parser_interface.php
@@ -82,7 +82,8 @@ interface parser_interface
/**
* Get the list of errors that were generated during last parsing
*
- * @return array
+ * @return array[] Array of arrays. Each array contains a lang string at index 0 plus any number
+ * of optional parameters
*/
public function get_errors();
diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php
index e46a0578d2..b7d0b2b90b 100644
--- a/phpBB/phpbb/textformatter/s9e/parser.php
+++ b/phpBB/phpbb/textformatter/s9e/parser.php
@@ -32,20 +32,14 @@ class parser implements \phpbb\textformatter\parser_interface
protected $parser;
/**
- * @var \phpbb\user User object, used for translating errors
- */
- protected $user;
-
- /**
* Constructor
*
* @param \phpbb\cache\driver_interface $cache
* @param string $key Cache key
- * @param \phpbb\user $user
* @param factory $factory
* @param \phpbb\event\dispatcher_interface $dispatcher
*/
- public function __construct(\phpbb\cache\driver\driver_interface $cache, $key, \phpbb\user $user, factory $factory, \phpbb\event\dispatcher_interface $dispatcher)
+ public function __construct(\phpbb\cache\driver\driver_interface $cache, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher)
{
$parser = $cache->get($key);
if (!$parser)
@@ -56,24 +50,21 @@ class parser implements \phpbb\textformatter\parser_interface
$this->dispatcher = $dispatcher;
$this->parser = $parser;
- $this->user = $user;
$parser = $this;
/**
* Configure the parser service
*
* Can be used to:
- * - toggle features according to the user's preferences,
- * - toggle BBCodes according to the user's permissions,
- * - register variables or custom parsers in the s9e\TextFormatter
- * - configure the s9e\TextFormatter parser
+ * - toggle features or BBCodes
+ * - register variables or custom parsers in the s9e\TextFormatter parser
+ * - configure the s9e\TextFormatter parser's runtime settings
*
* @event core.text_formatter_s9e_parser_setup
* @var \phpbb\textformatter\s9e\parser parser This parser service
- * @var \phpbb\user user Current user
* @since 3.2.0-a1
*/
- $vars = array('parser', 'user');
+ $vars = array('parser');
extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars)));
}
@@ -196,13 +187,12 @@ class parser implements \phpbb\textformatter\parser_interface
/**
* {@inheritdoc}
*
- * This will translate the log entries found in s9e\TextFormatter's logger into phpBB error
+ * This will convert the log entries found in s9e\TextFormatter's logger into phpBB error
* messages
*/
public function get_errors()
{
$errors = array();
-
foreach ($this->parser->getLogger()->get() as $entry)
{
list($type, $msg, $context) = $entry;
@@ -211,29 +201,29 @@ class parser implements \phpbb\textformatter\parser_interface
{
if ($context['tagName'] === 'E')
{
- $errors[] = $this->user->lang('TOO_MANY_SMILIES', $context['tagLimit']);
+ $errors[] = array('TOO_MANY_SMILIES', $context['tagLimit']);
}
else if ($context['tagName'] === 'URL')
{
- $errors[] = $this->user->lang('TOO_MANY_URLS', $context['tagLimit']);
+ $errors[] = array('TOO_MANY_URLS', $context['tagLimit']);
}
}
else if ($msg === 'MAX_FONT_SIZE_EXCEEDED')
{
- $errors[] = $this->user->lang($msg, $context['max_size']);
+ $errors[] = array($msg, $context['max_size']);
}
else if (preg_match('/^MAX_(?:FLASH|IMG)_(HEIGHT|WIDTH)_EXCEEDED$/D', $msg, $m))
{
- $errors[] = $this->user->lang($msg, $context['max_' . strtolower($m[1])]);
+ $errors[] = array($msg, $context['max_' . strtolower($m[1])]);
}
else if ($msg === 'Tag is disabled')
{
$name = strtolower($context['tag']->getName());
- $errors[] = $this->user->lang('UNAUTHORISED_BBCODE', '[' . $name . ']');
+ $errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']');
}
else if ($msg === 'UNABLE_GET_IMAGE_SIZE')
{
- $errors[] = $this->user->lang($msg);
+ $errors[] = array($msg);
}
}
diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php
index 2018bbf519..e21dedecc4 100644
--- a/phpBB/phpbb/textformatter/s9e/utils.php
+++ b/phpBB/phpbb/textformatter/s9e/utils.php
@@ -35,6 +35,31 @@ class utils implements \phpbb\textformatter\utils_interface
}
/**
+ * Get a list of quote authors, limited to the outermost quotes
+ *
+ * @param string $xml Parsed text
+ * @return string[] List of authors
+ */
+ public function get_outermost_quote_authors($xml)
+ {
+ $authors = array();
+ if (strpos($xml, '<QUOTE ') === false)
+ {
+ return $authors;
+ }
+
+ $dom = new \DOMDocument;
+ $dom->loadXML($xml);
+ $xpath = new \DOMXPath($dom);
+ foreach ($xpath->query('//QUOTE[not(ancestor::QUOTE)]/@author') as $author)
+ {
+ $authors[] = $author->textContent;
+ }
+
+ return $authors;
+ }
+
+ /**
* Remove given BBCode and its content, at given nesting depth
*
* @param string $xml Parsed text
diff --git a/phpBB/phpbb/textformatter/utils_interface.php b/phpBB/phpbb/textformatter/utils_interface.php
index 132dc8ece4..6d3fd13021 100644
--- a/phpBB/phpbb/textformatter/utils_interface.php
+++ b/phpBB/phpbb/textformatter/utils_interface.php
@@ -29,6 +29,14 @@ interface utils_interface
public function clean_formatting($text);
/**
+ * Get a list of quote authors, limited to the outermost quotes
+ *
+ * @param string $text Parsed text
+ * @return string[] List of authors
+ */
+ public function get_outermost_quote_authors($text);
+
+ /**
* Remove given BBCode and its content, at given nesting depth
*
* @param string $text Parsed text
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 2d01922c80..a4fb4d7a8d 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1578,11 +1578,22 @@ if (!sizeof($error) && $preview)
}
}
+// Remove quotes that would become nested too deep before decoding the text
+$generate_quote = ($mode == 'quote' && !$submit && !$preview && !$refresh);
+if ($generate_quote && $config['max_quote_depth'] > 0 && preg_match('#^<[rt][ >]#', $message_parser->message))
+{
+ $message_parser->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode(
+ $message_parser->message,
+ 'quote',
+ $config['max_quote_depth'] - 1
+ );
+}
+
// Decode text for message display
$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid;
$message_parser->decode_message($post_data['bbcode_uid']);
-if ($mode == 'quote' && !$submit && !$preview && !$refresh)
+if ($generate_quote)
{
if ($config['allow_bbcode'])
{