mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-03 21:15:42 +02:00
[ticket/217] Adjust patch, add tests
PHPBB3-217
This commit is contained in:
parent
16ab0d8c26
commit
6585d938d2
@ -102,7 +102,7 @@ class bbcode_firstpass extends bbcode
|
||||
/**
|
||||
* Init bbcode data for later parsing
|
||||
*/
|
||||
function bbcode_init()
|
||||
function bbcode_init($no_custom_bbcode = false)
|
||||
{
|
||||
static $rowset;
|
||||
|
||||
@ -117,7 +117,7 @@ class bbcode_firstpass extends bbcode
|
||||
'attachment' => array('bbcode_id' => 12, 'regexp' => array('#\[attachment=([0-9]+)\](.*?)\[/attachment\]#uise' => "\$this->bbcode_attachment('\$1', '\$2')")),
|
||||
'b' => array('bbcode_id' => 1, 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->bbcode_strong('\$1')")),
|
||||
'i' => array('bbcode_id' => 2, 'regexp' => array('#\[i\](.*?)\[/i\]#uise' => "\$this->bbcode_italic('\$1')")),
|
||||
'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](?(1)((?s).*(?-s))|(.*))\[/url\]#uiUe' => "\$this->validate_url('\$2', '\$3')")),
|
||||
'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](?(1)((?s).*(?-s))|(.*))\[/url\]#uiUe' => "\$this->validate_url('\$2', ('\$3') ? '\$3' : '\$4')")),
|
||||
'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](.*)\[/img\]#uiUe' => "\$this->bbcode_img('\$1')")),
|
||||
'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?\d+)\](.*?)\[/size\]#uise' => "\$this->bbcode_size('\$1', '\$2')")),
|
||||
'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!uise' => "\$this->bbcode_color('\$1', '\$2')")),
|
||||
@ -135,6 +135,11 @@ class bbcode_firstpass extends bbcode
|
||||
$this->parsed_items[$tag] = 0;
|
||||
}
|
||||
|
||||
if ($no_custom_bbcode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($rowset))
|
||||
{
|
||||
global $db;
|
||||
@ -970,7 +975,7 @@ class bbcode_firstpass extends bbcode
|
||||
}
|
||||
|
||||
// Is this a link to somewhere inside this board? If so then remove the session id from the url
|
||||
if (strpos($url, generate_board_url()) !== false && strpos($url, 'sid=') !== false)
|
||||
if (strpos($url, @generate_board_url()) !== false && strpos($url, 'sid=') !== false)
|
||||
{
|
||||
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}&/', '\1', $url);
|
||||
$url = preg_replace('/(&|\?)sid=[0-9a-f]{32}$/', '', $url);
|
||||
|
41
tests/bbcode/url_bbcode_test.php
Normal file
41
tests/bbcode/url_bbcode_test.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php';
|
||||
|
||||
class phpbb_url_bbcode_test extends phpbb_test_case
|
||||
{
|
||||
public function url_bbcode_test_data()
|
||||
{
|
||||
return array(
|
||||
array('[url]http://www.phpbb.com/community/[/url]'),
|
||||
array('[url=http://www.phpbb.com/community/]One line URL text[/url]'),
|
||||
array("[url=http://www.phpbb.com/community/]Multiline\x0AURL\x0Atext[/url]"),
|
||||
array("test [url] test \x0A test [url=http://www.phpbb.com/]test[/url] test"),
|
||||
array("test [url=http://www.phpbb.com/]test \x0A [url]http://phpbb.com[/url] test"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider url_bbcode_test_data
|
||||
*/
|
||||
public function test_url($message)
|
||||
{
|
||||
$bbcode = new bbcode_firstpass();
|
||||
$bbcode->message = $message;
|
||||
$bbcode->bbcode_init(true);
|
||||
$bbcode->parse_bbcode();
|
||||
$this->assertNotEquals($bbcode->message, '[url][/url]');
|
||||
$this->assertNotEquals($bbcode->message, $message);
|
||||
$this->assertNotEquals($bbcode->message, NULL);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user