aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php143
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php14
-rw-r--r--build/code_sniffer/ruleset-minimum.xml3
-rw-r--r--phpBB/composer.lock112
-rw-r--r--phpBB/config/default/container/services.yml35
-rw-r--r--phpBB/config/default/container/services_routing.yml19
-rw-r--r--phpBB/config/default/container/services_twig.yml16
-rw-r--r--phpBB/config/development/config.yml2
-rw-r--r--phpBB/docs/events.md30
-rw-r--r--phpBB/includes/acp/acp_board.php3
-rw-r--r--phpBB/includes/bbcode.php2
-rw-r--r--phpBB/includes/functions_content.php16
-rw-r--r--phpBB/includes/functions_messenger.php2
-rw-r--r--phpBB/includes/message_parser.php10
-rw-r--r--phpBB/install/index.php7
-rw-r--r--phpBB/phpbb/auth/provider/oauth/token_storage.php6
-rw-r--r--phpBB/phpbb/controller/helper.php26
-rw-r--r--phpBB/phpbb/di/extension/container_configuration.php2
-rw-r--r--phpBB/phpbb/di/extension/core.php14
-rw-r--r--phpBB/phpbb/routing/router.php17
-rw-r--r--phpBB/phpbb/template/exception/user_object_not_available.php22
-rw-r--r--phpBB/phpbb/template/twig/environment.php2
-rw-r--r--phpBB/phpbb/template/twig/loader.php3
-rw-r--r--phpBB/phpbb/template/twig/node/definenode.php3
-rw-r--r--phpBB/phpbb/template/twig/node/includephp.php6
-rw-r--r--phpBB/phpbb/template/twig/tokenparser/defineparser.php7
-rw-r--r--phpBB/phpbb/template/twig/tokenparser/includephp.php3
-rw-r--r--phpBB/phpbb/template/twig/twig.php19
-rw-r--r--phpBB/posting.php13
-rw-r--r--phpBB/styles/prosilver/template/index_body.html8
-rw-r--r--phpBB/styles/prosilver/template/viewforum_body.html4
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_body.html2
-rw-r--r--tests/controller/common_helper_route.php4
-rw-r--r--tests/controller/controller_test.php2
-rw-r--r--tests/di/fixtures/config.php2
-rw-r--r--tests/di/fixtures/config/test/container/environment.yml11
-rw-r--r--tests/di/fixtures/other_config/test/container/environment.yml11
-rw-r--r--tests/extension/metadata_manager_test.php2
-rw-r--r--tests/functional/posting_test.php81
-rw-r--r--tests/notification/submit_post_type_topic_test.php2
-rw-r--r--tests/pagination/pagination_test.php2
-rw-r--r--tests/template/asset_test.php2
-rw-r--r--tests/template/template_allfolder_test.php2
-rw-r--r--tests/template/template_events_test.php2
-rw-r--r--tests/template/template_includecss_test.php2
-rw-r--r--tests/template/template_test_case.php2
-rw-r--r--tests/template/template_test_case_with_tree.php2
-rw-r--r--tests/text_processing/generate_text_for_storage_test.php120
48 files changed, 675 insertions, 145 deletions
diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
new file mode 100644
index 0000000000..885c38c5b4
--- /dev/null
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
@@ -0,0 +1,143 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+ * Checks that the opening brace of a control structures is on the line after.
+ * From Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff
+ */
+class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Registers the tokens that this sniff wants to listen for.
+ */
+ public function register()
+ {
+ return array(
+ T_IF,
+ T_ELSE,
+ T_FOREACH,
+ T_WHILE,
+ T_DO,
+ T_FOR,
+ T_SWITCH,
+ );
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in the
+ * stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ if (isset($tokens[$stackPtr]['scope_opener']) === false)
+ {
+ return;
+ }
+
+ /*
+ * ...
+ * }
+ * else if ()
+ * {
+ * ...
+ */
+ if ($tokens[$stackPtr]['code'] === T_ELSE && $tokens[$stackPtr + 2]['code'] === T_IF)
+ {
+ return;
+ }
+
+ $openingBrace = $tokens[$stackPtr]['scope_opener'];
+
+ /*
+ * ...
+ * do
+ * {
+ * <code>
+ * } while();
+ * ...
+ * }
+ * else
+ * {
+ * ...
+ */
+ if ($tokens[$stackPtr]['code'] === T_DO ||$tokens[$stackPtr]['code'] === T_ELSE)
+ {
+ $cs_line = $tokens[$stackPtr]['line'];
+ }
+ else
+ {
+ // The end of the function occurs at the end of the argument list. Its
+ // like this because some people like to break long function declarations
+ // over multiple lines.
+ $cs_line = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line'];
+ }
+
+ $braceLine = $tokens[$openingBrace]['line'];
+
+ $lineDifference = ($braceLine - $cs_line);
+
+ if ($lineDifference === 0)
+ {
+ $error = 'Opening brace should be on a new line';
+ $phpcsFile->addError($error, $openingBrace, 'BraceOnSameLine');
+ return;
+ }
+
+ if ($lineDifference > 1)
+ {
+ $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
+ $data = array(($lineDifference - 1));
+ $phpcsFile->addError($error, $openingBrace, 'BraceSpacing', $data);
+ return;
+ }
+
+ // We need to actually find the first piece of content on this line,
+ // as if this is a method with tokens before it (public, static etc)
+ // or an if with an else before it, then we need to start the scope
+ // checking from there, rather than the current token.
+ $lineStart = $stackPtr;
+ while (($lineStart = $phpcsFile->findPrevious(array(T_WHITESPACE), ($lineStart - 1), null, false)) !== false)
+ {
+ if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false)
+ {
+ break;
+ }
+ }
+
+ // We found a new line, now go forward and find the first non-whitespace
+ // token.
+ $lineStart = $phpcsFile->findNext(array(T_WHITESPACE), $lineStart, null, true);
+
+ // The opening brace is on the correct line, now it needs to be
+ // checked to be correctly indented.
+ $startColumn = $tokens[$lineStart]['column'];
+ $braceIndent = $tokens[$openingBrace]['column'];
+
+ if ($braceIndent !== $startColumn)
+ {
+ $error = 'Opening brace indented incorrectly; expected %s spaces, found %s';
+ $data = array(
+ ($startColumn - 1),
+ ($braceIndent - 1),
+ );
+ $phpcsFile->addError($error, $openingBrace, 'BraceIndent', $data);
+ }
+ }
+}
diff --git a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
index 18cb8ba82e..3618871b7a 100644
--- a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
@@ -195,6 +195,20 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
}
}
+ // Checks in catch blocks
+ $old_catch = $stackPtr;
+ while (($catch = $phpcsFile->findNext(T_CATCH, ($old_catch + 1))) !== false)
+ {
+ $old_catch = $catch;
+
+ $caught_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), $catch + 1);
+ $caught_class_name_end = $phpcsFile->findNext($find, $caught_class_name_start + 1, null, true);
+
+ $caught_class_name = trim($phpcsFile->getTokensAsString($caught_class_name_start, ($caught_class_name_end - $caught_class_name_start)));
+
+ $ok = $this->check($phpcsFile, $caught_class_name, $class_name_full, $class_name_short, $catch) ? true : $ok;
+ }
+
if (!$ok)
{
$error = 'There must not be unused USE statements.';
diff --git a/build/code_sniffer/ruleset-minimum.xml b/build/code_sniffer/ruleset-minimum.xml
index 33d0177390..13f122cae7 100644
--- a/build/code_sniffer/ruleset-minimum.xml
+++ b/build/code_sniffer/ruleset-minimum.xml
@@ -12,4 +12,7 @@
<!-- Tabs MUST be used for indentation -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
+ <!-- ALL braces MUST be on their own lines. -->
+ <rule ref="./phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php" />
+
</ruleset>
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.yml b/phpBB/config/default/container/services.yml
index 670ea3bd61..6577a44195 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -15,6 +15,7 @@ imports:
- { resource: services_password.yml }
- { resource: services_profilefield.yml }
- { resource: services_report.yml }
+ - { resource: services_routing.yml }
- { resource: services_text_formatter.yml }
- { resource: services_twig.yml }
- { resource: services_user.yml }
@@ -157,25 +158,6 @@ services:
- null
- %core.disable_super_globals%
- router:
- class: phpbb\routing\router
- arguments:
- - @filesystem
- - @ext.manager
- - %core.root_path%
- - %core.php_ext%
- - %core.environment%
-
- router.listener:
- class: Symfony\Component\HttpKernel\EventListener\RouterListener
- arguments:
- - @router
- - null
- - null
- - @request_stack
- tags:
- - { name: kernel.event_subscriber }
-
# WARNING: The Symfony request does not escape the input and should be used very carefully
# prefer the phpbb request (service @request) as possible
symfony_request:
@@ -186,21 +168,6 @@ services:
request_stack:
class: Symfony\Component\HttpFoundation\RequestStack
- template:
- class: phpbb\template\twig\twig
- arguments:
- - @path_helper
- - @config
- - @user
- - @template_context
- - @template.twig.environment
- - %core.template.cache_path%
- - @template.twig.extensions.collection
- - @ext.manager
-
- template_context:
- class: phpbb\template\context
-
upload_imagesize:
class: fastImageSize\fastImageSize
diff --git a/phpBB/config/default/container/services_routing.yml b/phpBB/config/default/container/services_routing.yml
new file mode 100644
index 0000000000..6749202c0d
--- /dev/null
+++ b/phpBB/config/default/container/services_routing.yml
@@ -0,0 +1,19 @@
+services:
+ router:
+ class: phpbb\routing\router
+ arguments:
+ - @filesystem
+ - %core.root_path%
+ - %core.php_ext%
+ - %core.environment%
+ - @ext.manager
+
+ router.listener:
+ class: Symfony\Component\HttpKernel\EventListener\RouterListener
+ arguments:
+ - @router
+ - null
+ - null
+ - @request_stack
+ tags:
+ - { name: kernel.event_subscriber }
diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml
index 9ab004731e..2799892376 100644
--- a/phpBB/config/default/container/services_twig.yml
+++ b/phpBB/config/default/container/services_twig.yml
@@ -12,6 +12,7 @@ services:
- %core.template.cache_path%
- @ext.manager
- @template.twig.loader
+ - []
template.twig.lexer:
class: phpbb\template\twig\lexer
@@ -47,3 +48,18 @@ services:
template.twig.extensions.debug:
class: Twig_Extension_Debug
+
+ template:
+ class: phpbb\template\twig\twig
+ arguments:
+ - @path_helper
+ - @config
+ - @template_context
+ - @template.twig.environment
+ - %core.template.cache_path%
+ - @user
+ - @template.twig.extensions.collection
+ - @ext.manager
+
+ template_context:
+ class: phpbb\template\context
diff --git a/phpBB/config/development/config.yml b/phpBB/config/development/config.yml
index f451eebe13..93ae07fb3f 100644
--- a/phpBB/config/development/config.yml
+++ b/phpBB/config/development/config.yml
@@ -5,4 +5,6 @@ core:
require_dev_dependencies: true
twig:
+ debug: true
+ auto_reload: true
enable_debug_extension: true
diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md
index a7bcd9f978..b7b5e7de61 100644
--- a/phpBB/docs/events.md
+++ b/phpBB/docs/events.md
@@ -1385,6 +1385,20 @@ viewforum_forum_name_prepend
* Since: 3.1.0-b3
* Purpose: Add content directly before the forum name link on the View forum screen
+viewforum_forum_title_after
+===
+* Locations:
+ + styles/prosilver/template/viewforum_body.html
+* Since: 3.1.5-RC1
+* Purpose: Add content directly after the forum title on the View forum screen
+
+viewforum_forum_title_before
+===
+* Locations:
+ + styles/prosilver/template/viewforum_body.html
+* Since: 3.1.5-RC1
+* Purpose: Add content directly before the forum title on the View forum screen
+
viewtopic_print_head_append
===
* Locations:
@@ -1497,6 +1511,22 @@ viewtopic_body_post_buttons_before
* Purpose: Add post button to posts (next to edit, quote etc), at the start of
the list.
+viewtopic_body_post_buttons_list_after
+===
+* Locations:
+ + styles/prosilver/template/viewtopic_body.html
+* Since: 3.1.5-RC1
+* Purpose: Add post button custom list to posts (next to edit, quote etc),
+after the original list.
+
+viewtopic_body_post_buttons_list_before
+===
+* Locations:
+ + styles/prosilver/template/viewtopic_body.html
+* Since: 3.1.5-RC1
+* Purpose: Add post button custom list to posts (next to edit, quote etc),
+before the original list.
+
viewtopic_body_postrow_custom_fields_after
===
* Locations:
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 965f1a6f70..ff3b50174b 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -515,7 +515,8 @@ class acp_board
if ($config_name == 'guest_style')
{
- if (isset($cfg_array[$config_name])) {
+ if (isset($cfg_array[$config_name]))
+ {
$this->guest_style_set($cfg_array[$config_name]);
}
continue;
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 150157e275..24eaddf067 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -138,7 +138,6 @@ class bbcode
$template = new \phpbb\template\twig\twig(
$phpbb_container->get('path_helper'),
$phpbb_container->get('config'),
- $phpbb_container->get('user'),
new \phpbb\template\context(),
new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
@@ -152,6 +151,7 @@ class bbcode
)
),
$phpbb_container->getParameter('core.root_path') . 'cache/',
+ $phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'),
$phpbb_extension_manager
);
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 60511d89a4..5cebc54eb2 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -560,10 +560,14 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text
* @param bool $allow_bbcode If BBCode is allowed (i.e. if BBCode is parsed)
* @param bool $allow_urls If urls is allowed
* @param bool $allow_smilies If smilies are allowed
+* @param bool $allow_img_bbcode
+* @param bool $allow_flash_bbcode
+* @param bool $allow_quote_bbcode
+* @param bool $allow_url_bbcode
*
* @return array An array of string with the errors that occurred while parsing
*/
-function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false)
+function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true)
{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
@@ -578,6 +582,10 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
* @var bool allow_bbcode Whether or not to parse BBCode
* @var bool allow_urls Whether or not to parse URLs
* @var bool allow_smilies Whether or not to parse Smilies
+ * @var bool allow_img_bbcode Whether or not to parse the [img] BBCode
+ * @var bool allow_flash_bbcode Whether or not to parse the [flash] BBCode
+ * @var bool allow_quote_bbcode Whether or not to parse the [quote] BBCode
+ * @var bool allow_url_bbcode Whether or not to parse the [url] BBCode
* @since 3.1.0-a1
*/
$vars = array(
@@ -588,6 +596,10 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
'allow_bbcode',
'allow_urls',
'allow_smilies',
+ 'allow_img_bbcode',
+ 'allow_flash_bbcode',
+ 'allow_quote_bbcode',
+ 'allow_url_bbcode',
);
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));
@@ -600,7 +612,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
}
$message_parser = new parse_message($text);
- $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies);
+ $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode);
$text = $message_parser->message;
$uid = $message_parser->bbcode_uid;
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 4cbe1eb425..6abfb40b01 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -633,7 +633,6 @@ class messenger
$this->template = new \phpbb\template\twig\twig(
$phpbb_container->get('path_helper'),
$phpbb_container->get('config'),
- $phpbb_container->get('user'),
new \phpbb\template\context(),
new \phpbb\template\twig\environment(
$phpbb_container->get('config'),
@@ -647,6 +646,7 @@ class messenger
)
),
$phpbb_container->getParameter('core.root_path') . 'cache/',
+ $phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'),
$phpbb_extension_manager
);
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 9fe598d7fb..f018d735a7 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -1250,6 +1250,16 @@ 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)
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 657825ca39..056c827669 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -138,6 +138,7 @@ $phpbb_container_builder->set_custom_parameters(array(
$phpbb_container = $phpbb_container_builder->get_container();
$phpbb_container->register('dbal.conn.driver')->setSynthetic(true);
$phpbb_container->register('template.twig.environment')->setSynthetic(true);
+$phpbb_container->register('language.loader')->setSynthetic(true);
$phpbb_container->compile();
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
@@ -288,16 +289,18 @@ $twig_environment = new \phpbb\template\twig\environment(
$phpbb_container->get('template.twig.loader')
);
+$language_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$phpbb_container->set('template.twig.environment', $twig_environment);
+$phpbb_container->set('language.loader', $language_loader);
$twig_context = new \phpbb\template\context();
$template = new \phpbb\template\twig\twig(
$phpbb_path_helper,
$config,
- $user,
$twig_context,
$twig_environment,
$cache_path,
- array(new \phpbb\template\twig\extension($twig_context, $user))
+ $user,
+ array($phpbb_container->get('template.twig.extensions.phpbb'))
);
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php
index 023cf402ca..f488c2022d 100644
--- a/phpBB/phpbb/auth/provider/oauth/token_storage.php
+++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php
@@ -117,7 +117,8 @@ class token_storage implements TokenStorageInterface
{
$service = $this->get_service_name_for_db($service);
- if ($this->cachedToken) {
+ if ($this->cachedToken)
+ {
return true;
}
@@ -232,7 +233,8 @@ class token_storage implements TokenStorageInterface
{
$service = $this->get_service_name_for_db($service);
- if ($this->cachedToken instanceof TokenInterface) {
+ if ($this->cachedToken instanceof TokenInterface)
+ {
return $this->cachedToken;
}
diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index 1518169458..3782512fa4 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -13,6 +13,7 @@
namespace phpbb\controller;
+use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RequestContext;
@@ -215,12 +216,31 @@ class helper
public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200)
{
array_unshift($parameters, $message);
+ $message_text = call_user_func_array(array($this->user, 'lang'), $parameters);
+ $message_title = $this->user->lang($title);
+
+ if ($this->request->is_ajax())
+ {
+ global $refresh_data;
+
+ return new JsonResponse(
+ array(
+ 'MESSAGE_TITLE' => $message_title,
+ 'MESSAGE_TEXT' => $message_text,
+ 'S_USER_WARNING' => false,
+ 'S_USER_NOTICE' => false,
+ 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null
+ ),
+ $code
+ );
+ }
+
$this->template->assign_vars(array(
- 'MESSAGE_TEXT' => call_user_func_array(array($this->user, 'lang'), $parameters),
- 'MESSAGE_TITLE' => $this->user->lang($title),
+ 'MESSAGE_TEXT' => $message_text,
+ 'MESSAGE_TITLE' => $message_title,
));
- return $this->render('message_body.html', $this->user->lang($title), $code);
+ return $this->render('message_body.html', $message_title, $code);
}
/**
diff --git a/phpBB/phpbb/di/extension/container_configuration.php b/phpBB/phpbb/di/extension/container_configuration.php
index ee58ec2b74..4cc7c7c0d1 100644
--- a/phpBB/phpbb/di/extension/container_configuration.php
+++ b/phpBB/phpbb/di/extension/container_configuration.php
@@ -34,6 +34,8 @@ class container_configuration implements ConfigurationInterface
->arrayNode('twig')
->addDefaultsIfNotSet()
->children()
+ ->booleanNode('debug')->defaultValue(null)->end()
+ ->booleanNode('auto_reload')->defaultValue(null)->end()
->booleanNode('enable_debug_extension')->defaultValue(false)->end()
->end()
->end()
diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php
index c71dc61280..c9e2d4dc5b 100644
--- a/phpBB/phpbb/di/extension/core.php
+++ b/phpBB/phpbb/di/extension/core.php
@@ -69,6 +69,20 @@ class core extends Extension
}
}
+ // Set the Twig options if defined in the environment
+ $definition = $container->getDefinition('template.twig.environment');
+ $twig_environment_options = $definition->getArgument(6);
+ if ($config['twig']['debug'])
+ {
+ $twig_environment_options['debug'] = true;
+ }
+ if ($config['twig']['auto_reload'])
+ {
+ $twig_environment_options['auto_reload'] = true;
+ }
+ // Replace the 6th argument, the options passed to the environment
+ $definition->replaceArgument(6, $twig_environment_options);
+
if ($config['twig']['enable_debug_extension'])
{
$definition = $container->getDefinition('template.twig.extensions.debug');
diff --git a/phpBB/phpbb/routing/router.php b/phpBB/phpbb/routing/router.php
index 7444f06253..dd5bffe22b 100644
--- a/phpBB/phpbb/routing/router.php
+++ b/phpBB/phpbb/routing/router.php
@@ -94,13 +94,14 @@ class router implements RouterInterface
* Construct method
*
* @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem helper
- * @param manager $extension_manager Extension manager
- * @param string $phpbb_root_path phpBB root path
- * @param string $php_ext PHP file extension
- * @param string $environment Name of the current environment
- * @param array $routing_files Array of strings containing paths to YAML files holding route information
+ * @param string $phpbb_root_path phpBB root path
+ * @param string $php_ext PHP file extension
+ * @param string $environment Name of the current environment
+ * @param manager|null $extension_manager Extension manager
+ * @param array $routing_files Array of strings containing paths to YAML files
+ * holding route information
*/
- public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, manager $extension_manager, $phpbb_root_path, $php_ext, $environment, $routing_files = array())
+ public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, $environment, manager $extension_manager = null, $routing_files = array())
{
$this->filesystem = $filesystem;
$this->extension_manager = $extension_manager;
@@ -172,7 +173,9 @@ class router implements RouterInterface
{
if ($this->route_collection == null || empty($this->routing_files))
{
- $this->find_routing_files($this->extension_manager->all_enabled(false))
+ $this->find_routing_files(
+ ($this->extension_manager !== null) ? $this->extension_manager->all_enabled(false) : array()
+ )
->find($this->phpbb_root_path);
}
diff --git a/phpBB/phpbb/template/exception/user_object_not_available.php b/phpBB/phpbb/template/exception/user_object_not_available.php
new file mode 100644
index 0000000000..62fd2743c1
--- /dev/null
+++ b/phpBB/phpbb/template/exception/user_object_not_available.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\template\exception;
+
+/**
+ * This exception is thrown when the user object was not set but it is required by the called method
+ */
+class user_object_not_available extends \phpbb\exception\runtime_exception
+{
+
+}
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index e7b8aeab89..6e75403159 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -65,7 +65,7 @@ class environment extends \Twig_Environment
$options = array_merge(array(
'cache' => (defined('IN_INSTALL')) ? false : $cache_path,
- 'debug' => defined('DEBUG'),
+ 'debug' => false,
'auto_reload' => (bool) $this->phpbb_config['load_tplcompile'],
'autoescape' => false,
), $options);
diff --git a/phpBB/phpbb/template/twig/loader.php b/phpBB/phpbb/template/twig/loader.php
index df8183c019..8b12188a77 100644
--- a/phpBB/phpbb/template/twig/loader.php
+++ b/phpBB/phpbb/template/twig/loader.php
@@ -115,7 +115,8 @@ class loader extends \Twig_Loader_Filesystem
// If this is in the cache we can skip the entire process below
// as it should have already been validated
- if (isset($this->cache[$name])) {
+ if (isset($this->cache[$name]))
+ {
return $this->cache[$name];
}
diff --git a/phpBB/phpbb/template/twig/node/definenode.php b/phpBB/phpbb/template/twig/node/definenode.php
index 695ec4281f..c110785c4b 100644
--- a/phpBB/phpbb/template/twig/node/definenode.php
+++ b/phpBB/phpbb/template/twig/node/definenode.php
@@ -31,7 +31,8 @@ class definenode extends \Twig_Node
{
$compiler->addDebugInfo($this);
- if ($this->getAttribute('capture')) {
+ if ($this->getAttribute('capture'))
+ {
$compiler
->write("ob_start();\n")
->subcompile($this->getNode('value'))
diff --git a/phpBB/phpbb/template/twig/node/includephp.php b/phpBB/phpbb/template/twig/node/includephp.php
index 826617e8e8..659495fd9e 100644
--- a/phpBB/phpbb/template/twig/node/includephp.php
+++ b/phpBB/phpbb/template/twig/node/includephp.php
@@ -47,7 +47,8 @@ class includephp extends \Twig_Node
return;
}
- if ($this->getAttribute('ignore_missing')) {
+ if ($this->getAttribute('ignore_missing'))
+ {
$compiler
->write("try {\n")
->indent()
@@ -76,7 +77,8 @@ class includephp extends \Twig_Node
->write("}\n")
;
- if ($this->getAttribute('ignore_missing')) {
+ if ($this->getAttribute('ignore_missing'))
+ {
$compiler
->outdent()
->write("} catch (\Twig_Error_Loader \$e) {\n")
diff --git a/phpBB/phpbb/template/twig/tokenparser/defineparser.php b/phpBB/phpbb/template/twig/tokenparser/defineparser.php
index cfee84a363..2b88d61118 100644
--- a/phpBB/phpbb/template/twig/tokenparser/defineparser.php
+++ b/phpBB/phpbb/template/twig/tokenparser/defineparser.php
@@ -33,7 +33,8 @@ class defineparser extends \Twig_TokenParser
$name = $this->parser->getExpressionParser()->parseExpression();
$capture = false;
- if ($stream->test(\Twig_Token::OPERATOR_TYPE, '=')) {
+ if ($stream->test(\Twig_Token::OPERATOR_TYPE, '='))
+ {
$stream->next();
$value = $this->parser->getExpressionParser()->parseExpression();
@@ -45,7 +46,9 @@ class defineparser extends \Twig_TokenParser
}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
- } else {
+ }
+ else
+ {
$capture = true;
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/phpBB/phpbb/template/twig/tokenparser/includephp.php b/phpBB/phpbb/template/twig/tokenparser/includephp.php
index 38196c5290..c09f7729b0 100644
--- a/phpBB/phpbb/template/twig/tokenparser/includephp.php
+++ b/phpBB/phpbb/template/twig/tokenparser/includephp.php
@@ -31,7 +31,8 @@ class includephp extends \Twig_TokenParser
$stream = $this->parser->getStream();
$ignoreMissing = false;
- if ($stream->test(\Twig_Token::NAME_TYPE, 'ignore')) {
+ if ($stream->test(\Twig_Token::NAME_TYPE, 'ignore'))
+ {
$stream->next();
$stream->expect(\Twig_Token::NAME_TYPE, 'missing');
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 0e4c619029..6b3cf32bc8 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -13,6 +13,8 @@
namespace phpbb\template\twig;
+use phpbb\template\exception\user_object_not_available;
+
/**
* Twig Template class.
*/
@@ -76,14 +78,14 @@ class twig extends \phpbb\template\base
*
* @param \phpbb\path_helper $path_helper
* @param \phpbb\config\config $config
- * @param \phpbb\user $user
* @param \phpbb\template\context $context template context
* @param \phpbb\template\twig\environment $twig_environment
* @param string $cache_path
+ * @param \phpbb\user|null $user
* @param array|\ArrayAccess $extensions
* @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked
*/
- public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\template\twig\environment $twig_environment, $cache_path, $extensions = array(), \phpbb\extension\manager $extension_manager = null)
+ public function __construct(\phpbb\path_helper $path_helper, $config, \phpbb\template\context $context, \phpbb\template\twig\environment $twig_environment, $cache_path, \phpbb\user $user = null, $extensions = array(), \phpbb\extension\manager $extension_manager = null)
{
$this->path_helper = $path_helper;
$this->phpbb_root_path = $path_helper->get_phpbb_root_path();
@@ -126,9 +128,16 @@ class twig extends \phpbb\template\base
* Get the style tree of the style preferred by the current user
*
* @return array Style tree, most specific first
+ *
+ * @throws \phpbb\template\exception\user_object_not_available When user service was not set
*/
public function get_user_style()
{
+ if ($this->user === null)
+ {
+ throw new user_object_not_available();
+ }
+
$style_list = array(
$this->user->style['style_path'],
);
@@ -344,11 +353,15 @@ class twig extends \phpbb\template\base
$context_vars['.'][0], // To get normal vars
array(
'definition' => new \phpbb\template\twig\definition(),
- 'user' => $this->user,
'loops' => $context_vars, // To get loops
)
);
+ if ($this->user instanceof \phpbb\user)
+ {
+ $vars['user'] = $this->user;
+ }
+
// cleanup
unset($vars['loops']['.']);
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'])
{
diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html
index f620b6e966..5ac2d2aca3 100644
--- a/phpBB/styles/prosilver/template/index_body.html
+++ b/phpBB/styles/prosilver/template/index_body.html
@@ -19,15 +19,15 @@
<form method="post" action="{S_LOGIN_ACTION}" class="headerspace">
<h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3>
<fieldset class="quick-login">
- <label for="username"><span>{L_USERNAME}{L_COLON}</span> <input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" /></label>
- <label for="password"><span>{L_PASSWORD}{L_COLON}</span> <input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" /></label>
+ <label for="username"><span>{L_USERNAME}{L_COLON}</span> <input type="text" tabindex="1" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" /></label>
+ <label for="password"><span>{L_PASSWORD}{L_COLON}</span> <input type="password" tabindex="2" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" /></label>
<!-- IF U_SEND_PASSWORD -->
<a href="{U_SEND_PASSWORD}">{L_FORGOT_PASS}</a>
<!-- ENDIF -->
<!-- IF S_AUTOLOGIN_ENABLED -->
- <span class="responsive-hide">|</span> <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
+ <span class="responsive-hide">|</span> <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" tabindex="4" name="autologin" id="autologin" /></label>
<!-- ENDIF -->
- <input type="submit" name="login" value="{L_LOGIN}" class="button2" />
+ <input type="submit" tabindex="5" name="login" value="{L_LOGIN}" class="button2" />
{S_LOGIN_REDIRECT}
</fieldset>
</form>
diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html
index a0a0cd547a..b1e9d1be2c 100644
--- a/phpBB/styles/prosilver/template/viewforum_body.html
+++ b/phpBB/styles/prosilver/template/viewforum_body.html
@@ -1,7 +1,7 @@
<!-- INCLUDE overall_header.html -->
-
+<!-- EVENT viewforum_forum_title_before -->
<h2 class="forum-title"><!-- EVENT viewforum_forum_name_prepend --><a href="{U_VIEW_FORUM}">{FORUM_NAME}</a><!-- EVENT viewforum_forum_name_append --></h2>
-
+<!-- EVENT viewforum_forum_title_after -->
<!-- IF FORUM_DESC or MODERATORS or U_MCP -->
<div>
<!-- NOTE: remove the style="display: none" when you want to have the forum description on the forum body -->
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html
index 5b8078877e..e976c36f7b 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -210,6 +210,7 @@
<h3 <!-- IF postrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><!-- IF postrow.POST_ICON_IMG --><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" /> <!-- ENDIF --><a href="#p{postrow.POST_ID}">{postrow.POST_SUBJECT}</a></h3>
+ <!-- EVENT viewtopic_body_post_buttons_list_before -->
<!-- IF not S_IS_BOT -->
<!-- IF postrow.U_EDIT or postrow.U_DELETE or postrow.U_REPORT or postrow.U_WARN or postrow.U_INFO or postrow.U_QUOTE -->
<ul class="post-buttons">
@@ -248,6 +249,7 @@
</ul>
<!-- ENDIF -->
<!-- ENDIF -->
+ <!-- EVENT viewtopic_body_post_buttons_list_after -->
<!-- EVENT viewtopic_body_postrow_post_details_before -->
<p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF --><span class="responsive-hide">{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> &raquo; </span>{postrow.POST_DATE} </p>
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index b01241e105..44e5e12ab0 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -107,7 +107,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->extension_manager = new phpbb_mock_extension_manager(
@@ -121,7 +121,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
)
);
- $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager);
$this->router->find_routing_files($this->extension_manager->all_enabled(false));
$this->router->find(dirname(__FILE__) . '/');
// Set correct current phpBB root path
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 5c0290ee6f..5781d3ebc1 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
public function test_router_find_files()
{
- $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager);
$router->find_routing_files($this->extension_manager->all_enabled(false));
$routes = $router->find(__DIR__)->get_routes();
diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php
index 04e20f63d8..f2e1145efa 100644
--- a/tests/di/fixtures/config.php
+++ b/tests/di/fixtures/config.php
@@ -8,4 +8,4 @@ $dbname = 'phpbb';
$dbuser = 'root';
$dbpasswd = '';
$table_prefix = 'phpbb_';
-$acm_type = '\phpbb\cache\driver\null';
+$acm_type = '\phpbb\cache\driver\dummy';
diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml
index f2a22ae109..0873078844 100644
--- a/tests/di/fixtures/config/test/container/environment.yml
+++ b/tests/di/fixtures/config/test/container/environment.yml
@@ -12,3 +12,14 @@ services:
dispatcher:
class: phpbb\db\driver\container_mock
+
+ template.twig.environment:
+ class: Exception
+ arguments:
+ - ~
+ - ~
+ - ~
+ - ~
+ - ~
+ - ~
+ - []
diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml
index c299bfc648..2aa29db2eb 100644
--- a/tests/di/fixtures/other_config/test/container/environment.yml
+++ b/tests/di/fixtures/other_config/test/container/environment.yml
@@ -12,3 +12,14 @@ services:
dispatcher:
class: phpbb\db\driver\container_mock
+
+ template.twig.environment:
+ class: Exception
+ arguments:
+ - ~
+ - ~
+ - ~
+ - ~
+ - ~
+ - ~
+ - []
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index aaaee3b2e5..53bd3d109b 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -111,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$lang = new \phpbb\language\language($lang_loader);
$this->user = new \phpbb\user($lang, '\phpbb\datetime');
- $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 7acf375c5d..5c083aef37 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -71,4 +71,85 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
$this->assertContains('&#128512;', $crawler->text());
}
+
+ /**
+ * @testdox max_quote_depth is applied to the text populating the posting form
+ */
+ public function test_quote_depth_form()
+ {
+ $text = '0[quote]1[quote]2[/quote]1[/quote]0';
+ $expected = array(
+ 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]',
+ 1 => '[quote="admin"]00[/quote]',
+ 2 => '[quote="admin"]0[quote]11[/quote]0[/quote]',
+ 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]',
+ );
+
+ $this->login();
+ $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic');
+ $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+ $quote_url = "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}";
+
+ $this->admin_login();
+ foreach ($expected as $quote_depth => $expected_text)
+ {
+ $this->set_quote_depth($quote_depth);
+ $crawler = self::request('GET', $quote_url);
+ $this->assertContains($expected_text, $crawler->filter('textarea#message')->text());
+ }
+ }
+
+ /**
+ * @testdox max_quote_depth is applied to the submitted text
+ */
+ public function test_quote_depth_submit()
+ {
+ $text = 'depth:0[quote]depth:1[quote]depth:2[quote]depth:3[/quote][/quote][/quote]';
+ $contains = array(
+ 0 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'),
+ 1 => array('depth:0', 'depth:1'),
+ 2 => array('depth:0', 'depth:1', 'depth:2'),
+ 3 => array('depth:0', 'depth:1', 'depth:2', 'depth:3'),
+ );
+ $not_contains = array(
+ 0 => array(),
+ 1 => array('depth:2', 'depth:3'),
+ 2 => array('depth:3'),
+ 3 => array(),
+ );
+
+ $this->login();
+ $this->admin_login();
+ $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic');
+
+ for ($quote_depth = 0; $quote_depth <= 2; ++$quote_depth)
+ {
+ $this->set_quote_depth($quote_depth);
+
+ $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+ $url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}";
+
+ $crawler = self::request('GET', $url);
+ $text_content = $crawler->filter('#p' . $post['post_id'])->text();
+ foreach ($contains[$quote_depth] as $contains_text)
+ {
+ $this->assertContains($contains_text, $text_content);
+ }
+ foreach ($not_contains[$quote_depth] as $not_contains_text)
+ {
+ $this->assertNotContains($not_contains_text, $text_content);
+ }
+ }
+ }
+
+ protected function set_quote_depth($depth)
+ {
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+ $values['config[max_quote_depth]'] = $depth;
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertEquals(1, $crawler->filter('.successbox')->count());
+ }
}
diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php
index c095fbc4ba..f14f305517 100644
--- a/tests/notification/submit_post_type_topic_test.php
+++ b/tests/notification/submit_post_type_topic_test.php
@@ -42,7 +42,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
),
)));
- $phpbb_log = $this->getMock('\phpbb\log\null');
+ $phpbb_log = $this->getMock('\phpbb\log\dummy');
}
/**
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 4916665a72..67c3d0a30f 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -41,7 +41,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $router = new phpbb_mock_router($filesystem, $manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router = new phpbb_mock_router($filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $manager);
$router->find_routing_files($manager->all_enabled(false));
$router->find(dirname(__FILE__) . '/');
diff --git a/tests/template/asset_test.php b/tests/template/asset_test.php
index f6ce0fe241..3d2fdd8959 100644
--- a/tests/template/asset_test.php
+++ b/tests/template/asset_test.php
@@ -22,7 +22,7 @@ class phpbb_template_asset_test extends phpbb_test_case
array('.', 'foo/bar', 'foo/bar'),
array('../', 'foo/bar', 'foo/bar'),
array('./phpBB/', 'foo/bar', 'foo/bar'),
- array('../', __DIR__ . '/foo/bar', '../phpbb/tests/template/foo/bar'),
+ array('../', __DIR__ . '/foo/bar', '../' . basename(dirname(dirname(__DIR__))) . '/tests/template/foo/bar'),
array('./', __DIR__ . '/foo/bar', './tests/template/foo/bar'),
array('./phpBB/', __DIR__ . '/foo/bar', 'tests/template/foo/bar'),
);
diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php
index 14a8e9d463..9a0f1f512e 100644
--- a/tests/template/template_allfolder_test.php
+++ b/tests/template/template_allfolder_test.php
@@ -75,7 +75,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
'autoescape' => false,
)
);
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template_path = $this->test_path . '/templates';
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 285e82188b..54e08652a1 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -169,7 +169,7 @@ Zeta test event in all',
'autoescape' => false,
)
);
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index 8c398d992b..062fc9493b 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -64,10 +64,10 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$this->template = new phpbb\template\twig\twig(
$this->phpbb_path_helper,
$config,
- $user,
$context,
$twig,
$cache_path,
+ $this->user,
array(new \phpbb\template\twig\extension($context, $this->user)),
new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index b1826571af..62eea0d361 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -115,7 +115,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index d0c49006fd..bf5de6b85e 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -56,7 +56,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php
index ffa06e4e02..474f6d8f0f 100644
--- a/tests/text_processing/generate_text_for_storage_test.php
+++ b/tests/text_processing/generate_text_for_storage_test.php
@@ -12,6 +12,7 @@
*/
require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once __DIR__ . '/../../phpBB/includes/functions_compatibility.php';
require_once __DIR__ . '/../../phpBB/includes/functions_content.php';
require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
@@ -36,7 +37,7 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca
/**
* @dataProvider get_text_formatter_tests
*/
- public function test_text_formatter($original, $expected, $allow_bbcode = true, $allow_urls = true, $allow_smilies = true, $setup = null)
+ public function test_text_formatter($original, $expected, $allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode, $setup = null)
{
$actual = $original;
$uid = '';
@@ -48,7 +49,7 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca
$setup();
}
- generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies);
+ generate_text_for_storage($actual, $uid, $bitfield, $flags, $allow_bbcode, $allow_urls, $allow_smilies, $allow_img_bbcode, $allow_flash_bbcode, $allow_quote_bbcode, $allow_url_bbcode);
$this->assertSame($expected, $actual);
}
@@ -58,15 +59,124 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_ca
return array(
array(
'Hello world',
- '<t>Hello world</t>'
+ '<t>Hello world</t>',
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
),
array(
'Hello [url=http://example.org]world[/url] :)',
- '<r>Hello <URL url="http://example.org"><s>[url=http://example.org]</s>world<e>[/url]</e></URL> <E>:)</E></r>'
+ '<r>Hello <URL url="http://example.org"><s>[url=http://example.org]</s>world<e>[/url]</e></URL> <E>:)</E></r>',
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
),
array(
'&<>"\'',
- '<t>&amp;&lt;&gt;"\'</t>'
+ '<t>&amp;&lt;&gt;"\'</t>',
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<t>[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]</t>',
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r><B><s>[b]</s>..<e>[/b]</e></B> http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]</r>',
+ true,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r>[b]..[/b] <URL url="http://example.org">http://example.org</URL> :) [img]<URL url="http://example.org/img.png">http://example.org/img.png</URL>[/img] [flash=123,123]<URL url="http://example.org/flash.swf">http://example.org/flash.swf</URL>[/flash] [quote]...[/quote] [url]<URL url="http://example.org">http://example.org</URL>[/url]</r>',
+ false,
+ true,
+ false,
+ false,
+ false,
+ false,
+ true,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r>[b]..[/b] http://example.org <E>:)</E> [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]</r>',
+ false,
+ false,
+ true,
+ false,
+ false,
+ false,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r><B><s>[b]</s>..<e>[/b]</e></B> http://example.org :) <IMG src="http://example.org/img.png"><s>[img]</s>http://example.org/img.png<e>[/img]</e></IMG> [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]</r>',
+ true,
+ false,
+ false,
+ true,
+ false,
+ false,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r><B><s>[b]</s>..<e>[/b]</e></B> http://example.org :) [img]http://example.org/img.png[/img] <FLASH height="123" url="http://example.org/flash.swf" width="123"><s>[flash=123,123]</s>http://example.org/flash.swf<e>[/flash]</e></FLASH> [quote]...[/quote] [url]http://example.org[/url]</r>',
+ true,
+ false,
+ false,
+ false,
+ true,
+ false,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r><B><s>[b]</s>..<e>[/b]</e></B> http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] <QUOTE><s>[quote]</s>...<e>[/quote]</e></QUOTE> [url]http://example.org[/url]</r>',
+ true,
+ false,
+ false,
+ false,
+ false,
+ true,
+ false,
+ ),
+ array(
+ '[b]..[/b] http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] [url]http://example.org[/url]',
+ '<r><B><s>[b]</s>..<e>[/b]</e></B> http://example.org :) [img]http://example.org/img.png[/img] [flash=123,123]http://example.org/flash.swf[/flash] [quote]...[/quote] <URL url="http://example.org"><s>[url]</s>http://example.org<e>[/url]</e></URL></r>',
+ true,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true,
),
);
}