mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge pull request #4059 from JoshyPHP/ticket/14323
[ticket/14323] Added support for truncating long URLs
This commit is contained in:
@@ -315,7 +315,7 @@ class phpbb_test_case_helpers
|
||||
public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null)
|
||||
{
|
||||
static $first_run;
|
||||
global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $user;
|
||||
global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user;
|
||||
|
||||
$cache_dir = __DIR__ . '/../tmp/';
|
||||
|
||||
@@ -473,14 +473,18 @@ class phpbb_test_case_helpers
|
||||
{
|
||||
$config = $container->get('config');
|
||||
}
|
||||
else
|
||||
elseif (!isset($config))
|
||||
{
|
||||
$config = new \phpbb\config\config(array());
|
||||
}
|
||||
$default_config = array(
|
||||
'allow_nocensors' => false,
|
||||
'allow_nocensors' => false,
|
||||
'allowed_schemes_links' => 'http,https,ftp',
|
||||
'smilies_path' => 'images/smilies',
|
||||
'script_path' => '/phpbb',
|
||||
'server_name' => 'localhost',
|
||||
'server_port' => 80,
|
||||
'server_protocol' => 'http://',
|
||||
'smilies_path' => 'images/smilies',
|
||||
);
|
||||
foreach ($default_config as $config_name => $config_value)
|
||||
{
|
||||
@@ -490,8 +494,14 @@ class phpbb_test_case_helpers
|
||||
}
|
||||
}
|
||||
|
||||
// Create a fake request
|
||||
if (!isset($request))
|
||||
{
|
||||
$request = new phpbb_mock_request;
|
||||
}
|
||||
|
||||
// Create and register the text_formatter.s9e.factory service
|
||||
$factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, $cache_dir, $cache_key_parser, $cache_key_renderer);
|
||||
$factory = new \phpbb\textformatter\s9e\factory($dal, $cache, $dispatcher, $config, new \phpbb\textformatter\s9e\link_helper, $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
|
||||
|
@@ -225,6 +225,36 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
|
||||
'... www.example.org ...',
|
||||
'... <a href="http://www.example.org" class="postlink">www.example.org</a> ...'
|
||||
),
|
||||
array(
|
||||
// From make_clickable_test.php
|
||||
'www.phpbb.com/community/?',
|
||||
'<a href="http://www.phpbb.com/community/" class="postlink">www.phpbb.com/community/</a>?'
|
||||
),
|
||||
array(
|
||||
// From make_clickable_test.php
|
||||
'http://www.phpbb.com/community/path/to/long/url/file.ext#section',
|
||||
'<a href="http://www.phpbb.com/community/path/to/long/url/file.ext#section" class="postlink">http://www.phpbb.com/community/path/to/ ... xt#section</a>'
|
||||
),
|
||||
array(
|
||||
'http://localhost/ http://localhost/phpbb/ http://localhost/phpbb/viewforum.php?f=1',
|
||||
'<a href="http://localhost/" class="postlink">http://localhost/</a> <a href="http://localhost/phpbb/" class="postlink">http://localhost/phpbb/</a> <a href="http://localhost/phpbb/viewforum.php?f=1" class="postlink">viewforum.php?f=1</a>'
|
||||
),
|
||||
array(
|
||||
'http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
||||
'<a href="http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx</a>'
|
||||
),
|
||||
array(
|
||||
'[url]http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0[/url]',
|
||||
'<a href="http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0" class="postlink">http://example.org/0xxxxxxxxxxxxxxxxxxx ... xxxxxxxxx0</a>'
|
||||
),
|
||||
array(
|
||||
'[URL]http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0[/url]',
|
||||
'<a href="http://example.org/0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0" class="postlink">http://example.org/0xxxxxxxxxxxxxxxxxxx ... xxxxxxxxx0</a>'
|
||||
),
|
||||
array(
|
||||
'[url=http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx[/url]',
|
||||
'<a href="http://example.org/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</a>'
|
||||
),
|
||||
array(
|
||||
'[quote="[url=http://example.org]xxx[/url]"]...[/quote]',
|
||||
'<blockquote><div><cite><a href="http://example.org" class="postlink">xxx</a> wrote:</cite>...</div></blockquote>'
|
||||
|
@@ -35,7 +35,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
|
||||
public function get_factory()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
global $config, $phpbb_root_path, $request, $user;
|
||||
$this->cache = new phpbb_mock_cache;
|
||||
$dal = new \phpbb\textformatter\data_access(
|
||||
$this->new_dbal(),
|
||||
@@ -50,11 +50,22 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
$this->cache,
|
||||
$this->dispatcher,
|
||||
new \phpbb\config\config(array('allowed_schemes_links' => 'http,https,ftp')),
|
||||
new \phpbb\textformatter\s9e\link_helper,
|
||||
$this->get_cache_dir(),
|
||||
'_foo_parser',
|
||||
'_foo_renderer'
|
||||
);
|
||||
|
||||
// Global objects required by generate_board_url()
|
||||
$config = new \phpbb\config\config(array(
|
||||
'script_path' => '/phpbb',
|
||||
'server_name' => 'localhost',
|
||||
'server_port' => 80,
|
||||
'server_protocol' => 'http://',
|
||||
));
|
||||
$request = new phpbb_mock_request;
|
||||
$user = new phpbb_mock_user;
|
||||
|
||||
return $factory;
|
||||
}
|
||||
|
||||
@@ -128,14 +139,14 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
public function test_local_url()
|
||||
{
|
||||
global $config, $user, $request;
|
||||
$config = array(
|
||||
$config = new \phpbb\config\config(array(
|
||||
'force_server_vars' => true,
|
||||
'server_protocol' => 'http://',
|
||||
'server_name' => 'path',
|
||||
'server_port' => 80,
|
||||
'script_path' => '/to',
|
||||
'cookie_secure' => false
|
||||
);
|
||||
));
|
||||
$user = new phpbb_mock_user;
|
||||
$request = new phpbb_mock_request;
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
<a href="http://www.tx-gaming.net/warzone/tournament.php?tourney%5Bid%5D=34&action=brackets" class="postlink">http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets</a><br>
|
||||
<a href="http://www.tx-gaming.net/warzone/tournament.php?tourney%5Bid%5D=34&action=brackets" class="postlink">link</a>
|
||||
<a href="http://example.org/?tourney%5Bid%5D=34&action=brackets" class="postlink">http://example.org/?tourney[id]=34&action=brackets</a><br>
|
||||
<a href="http://example.org/?tourney%5Bid%5D=34&action=brackets" class="postlink">link</a>
|
@@ -1,2 +1,2 @@
|
||||
[url]http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets[/url]
|
||||
[url="http://www.tx-gaming.net/warzone/tournament.php?tourney[id]=34&action=brackets"]link[/url]
|
||||
[url]http://example.org/?tourney[id]=34&action=brackets[/url]
|
||||
[url="http://example.org/?tourney[id]=34&action=brackets"]link[/url]
|
@@ -1 +1 @@
|
||||
<a href="http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid%5B%5D=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search" class="postlink">http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid[]=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search</a>
|
||||
<a href="http://www.phpbb.com/community/search.php?keywords=bogus&terms=all&author=&fid%5B%5D=46&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search" class="postlink">http://www.phpbb.com/community/search.p ... mit=Search</a>
|
Reference in New Issue
Block a user