mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 03:04:09 +02:00
[ticket/13935] Allow more admin-configurable schemes in post links
PHPBB3-13935
This commit is contained in:
@@ -205,4 +205,45 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
$crawler->filter('#preview .signature')->html()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_allowed_schemes_links()
|
||||
{
|
||||
$text = 'http://example.org/ tcp://localhost:22/ServiceName';
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
// Post with default settings
|
||||
$crawler = self::request('GET', 'posting.php?mode=post&f=2');
|
||||
$form = $crawler->selectButton('Preview')->form(array(
|
||||
'subject' => 'Test subject',
|
||||
'message' => $text,
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContains(
|
||||
'<a href="http://example.org/" class="postlink">http://example.org/</a> tcp://localhost:22/ServiceName',
|
||||
$crawler->filter('#preview .content')->html()
|
||||
);
|
||||
|
||||
// Update allowed schemes
|
||||
$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[allowed_schemes_links]'] = 'https,tcp';
|
||||
$form->setValues($values);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertEquals(1, $crawler->filter('.successbox')->count());
|
||||
|
||||
// Post with new settings
|
||||
$crawler = self::request('GET', 'posting.php?mode=post&f=2');
|
||||
$form = $crawler->selectButton('Preview')->form(array(
|
||||
'subject' => 'Test subject',
|
||||
'message' => $text,
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContains(
|
||||
'http://example.org/ <a href="tcp://localhost:22/ServiceName" class="postlink">tcp://localhost:22/ServiceName</a>',
|
||||
$crawler->filter('#preview .content')->html()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -473,8 +473,30 @@ class phpbb_test_case_helpers
|
||||
$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
|
||||
$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);
|
||||
|
||||
// Create a user if none was provided, and add the common lang strings
|
||||
@@ -537,12 +559,8 @@ class phpbb_test_case_helpers
|
||||
$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
|
||||
$auth = ($container->has('auth')) ? $container->get('auth') : new \phpbb\auth\auth;
|
||||
$renderer->configure_quote_helper($quote_helper);
|
||||
$renderer->configure_smilies_path($config, $path_helper);
|
||||
$renderer->configure_user($user, $config, $auth);
|
||||
|
@@ -49,6 +49,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
$dal,
|
||||
$this->cache,
|
||||
$this->dispatcher,
|
||||
new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')),
|
||||
$this->get_cache_dir(),
|
||||
'_foo_parser',
|
||||
'_foo_renderer'
|
||||
|
Reference in New Issue
Block a user