mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
Merge pull request #3698 from s9e/ticket/13935
[ticket/13935] Allow more admin-configurable schemes in post links * s9e/ticket/13935: [ticket/13935] Removed cache invalidation from acp_board [ticket/13935] Removed UI [ticket/13935] Allow more admin-configurable schemes in post links
This commit is contained in:
commit
cbe74844b0
6 changed files with 69 additions and 7 deletions
|
@ -32,6 +32,7 @@ services:
|
||||||
- @text_formatter.data_access
|
- @text_formatter.data_access
|
||||||
- @cache.driver
|
- @cache.driver
|
||||||
- @dispatcher
|
- @dispatcher
|
||||||
|
- @config
|
||||||
- %text_formatter.cache.dir%
|
- %text_formatter.cache.dir%
|
||||||
- %text_formatter.cache.parser.key%
|
- %text_formatter.cache.parser.key%
|
||||||
- %text_formatter.cache.renderer.key%
|
- %text_formatter.cache.renderer.key%
|
||||||
|
|
|
@ -41,6 +41,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_pm', '1'
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_smilies', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_smilies', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_smilies', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_smilies', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_topic_notify', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_topic_notify', '1');
|
||||||
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allowed_schemes_links', 'http,https,ftp');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('assets_version', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('assets_version', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1');
|
||||||
|
|
24
phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php
Normal file
24
phpBB/phpbb/db/migration/data/v320/allowed_schemes_links.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?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\db\migration\data\v320;
|
||||||
|
|
||||||
|
class allowed_schemes_links extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('config.add', array('allowed_schemes_links', 'http,https,ftp')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,11 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
*/
|
*/
|
||||||
protected $cache_key_renderer;
|
protected $cache_key_renderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \phpbb\config\config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Custom tokens used in bbcode.html and their corresponding token from the definition
|
* @var array Custom tokens used in bbcode.html and their corresponding token from the definition
|
||||||
*/
|
*/
|
||||||
|
@ -127,16 +132,18 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
* @param \phpbb\textformatter\data_access $data_access
|
* @param \phpbb\textformatter\data_access $data_access
|
||||||
* @param \phpbb\cache\driver\driver_interface $cache
|
* @param \phpbb\cache\driver\driver_interface $cache
|
||||||
* @param \phpbb\event\dispatcher_interface $dispatcher
|
* @param \phpbb\event\dispatcher_interface $dispatcher
|
||||||
|
* @param \phpbb\config\config $config
|
||||||
* @param string $cache_dir Path to the cache dir
|
* @param string $cache_dir Path to the cache dir
|
||||||
* @param string $cache_key_parser Cache key used for the parser
|
* @param string $cache_key_parser Cache key used for the parser
|
||||||
* @param string $cache_key_renderer Cache key used for the renderer
|
* @param string $cache_key_renderer Cache key used for the renderer
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, $cache_dir, $cache_key_parser, $cache_key_renderer)
|
public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, $cache_dir, $cache_key_parser, $cache_key_renderer)
|
||||||
{
|
{
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->cache_dir = $cache_dir;
|
$this->cache_dir = $cache_dir;
|
||||||
$this->cache_key_parser = $cache_key_parser;
|
$this->cache_key_parser = $cache_key_parser;
|
||||||
$this->cache_key_renderer = $cache_key_renderer;
|
$this->cache_key_renderer = $cache_key_renderer;
|
||||||
|
$this->config = $config;
|
||||||
$this->data_access = $data_access;
|
$this->data_access = $data_access;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +197,16 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||||
$vars = array('configurator');
|
$vars = array('configurator');
|
||||||
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars)));
|
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars)));
|
||||||
|
|
||||||
|
// Reset the list of allowed schemes
|
||||||
|
foreach ($configurator->urlConfig->getAllowedSchemes() as $scheme)
|
||||||
|
{
|
||||||
|
$configurator->urlConfig->disallowScheme($scheme);
|
||||||
|
}
|
||||||
|
foreach (explode(',', $this->config['allowed_schemes_links']) as $scheme)
|
||||||
|
{
|
||||||
|
$configurator->urlConfig->allowScheme(trim($scheme));
|
||||||
|
}
|
||||||
|
|
||||||
// Convert newlines to br elements by default
|
// Convert newlines to br elements by default
|
||||||
$configurator->rootRules->enableAutoLineBreaks();
|
$configurator->rootRules->enableAutoLineBreaks();
|
||||||
|
|
||||||
|
|
|
@ -468,8 +468,30 @@ class phpbb_test_case_helpers
|
||||||
$phpbb_dispatcher = $dispatcher;
|
$phpbb_dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up the a minimum config
|
||||||
|
if ($container->has('config'))
|
||||||
|
{
|
||||||
|
$config = $container->get('config');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$config = new \phpbb\config\config(array());
|
||||||
|
}
|
||||||
|
$default_config = array(
|
||||||
|
'allow_nocensors' => false,
|
||||||
|
'allowed_schemes_links' => 'http,https,ftp',
|
||||||
|
'smilies_path' => 'images/smilies',
|
||||||
|
);
|
||||||
|
foreach ($default_config as $config_name => $config_value)
|
||||||
|
{
|
||||||
|
if (!isset($config[$config_name]))
|
||||||
|
{
|
||||||
|
$config[$config_name] = $config_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create and register the text_formatter.s9e.factory service
|
// Create and register the text_formatter.s9e.factory service
|
||||||
$factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $cache_dir, $cache_key_parser, $cache_key_renderer);
|
$factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, $cache_dir, $cache_key_parser, $cache_key_renderer);
|
||||||
$container->set('text_formatter.s9e.factory', $factory);
|
$container->set('text_formatter.s9e.factory', $factory);
|
||||||
|
|
||||||
// Create a user if none was provided, and add the common lang strings
|
// Create a user if none was provided, and add the common lang strings
|
||||||
|
@ -532,12 +554,8 @@ class phpbb_test_case_helpers
|
||||||
$dispatcher
|
$dispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
$config = ($container->has('config'))
|
|
||||||
? $container->get('config')
|
|
||||||
: new \phpbb\config\config(array('smilies_path' => 'images/smilies', 'allow_nocensors' => false));
|
|
||||||
$auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth;
|
|
||||||
|
|
||||||
// Calls configured in services.yml
|
// Calls configured in services.yml
|
||||||
|
$auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth;
|
||||||
$renderer->configure_quote_helper($quote_helper);
|
$renderer->configure_quote_helper($quote_helper);
|
||||||
$renderer->configure_smilies_path($config, $path_helper);
|
$renderer->configure_smilies_path($config, $path_helper);
|
||||||
$renderer->configure_user($user, $config, $auth);
|
$renderer->configure_user($user, $config, $auth);
|
||||||
|
|
|
@ -49,6 +49,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||||
$dal,
|
$dal,
|
||||||
$this->cache,
|
$this->cache,
|
||||||
$this->dispatcher,
|
$this->dispatcher,
|
||||||
|
new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')),
|
||||||
$this->get_cache_dir(),
|
$this->get_cache_dir(),
|
||||||
'_foo_parser',
|
'_foo_parser',
|
||||||
'_foo_renderer'
|
'_foo_renderer'
|
||||||
|
|
Loading…
Add table
Reference in a new issue