diff options
36 files changed, 787 insertions, 63 deletions
diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html index f96da7e26a..f61be27c9b 100644 --- a/phpBB/adm/style/acp_ext_list.html +++ b/phpBB/adm/style/acp_ext_list.html @@ -7,7 +7,7 @@ <p>{L_EXTENSIONS_EXPLAIN}</p> <fieldset class="quick"> - <span class="small"><a href="{U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE_ALL}</a> • <a href="javascript:phpbb.toggleDisplay('version_check_settings');">{L_SETTINGS}</a></span> + <span class="small"><a href="https://www.phpbb.com/go/customise/extensions/3.1" target="_blank">{L_BROWSE_EXTENSIONS_DATABASE}</a> • <a href="{U_VERSIONCHECK_FORCE}">{L_VERSIONCHECK_FORCE_UPDATE_ALL}</a> • <a href="javascript:phpbb.toggleDisplay('version_check_settings');">{L_SETTINGS}</a></span> </fieldset> <form id="version_check_settings" method="post" action="{U_ACTION}" style="display:none"> @@ -98,6 +98,12 @@ <table class="table1"> <tr> + <th>{L_EXTENSION_INSTALL_HEADLINE}</th> + </tr> + <tr> + <td class="row3">{L_EXTENSION_INSTALL_EXPLAIN}</td> + </tr> + <tr> <th>{L_EXTENSION_UPDATE_HEADLINE}</th> </tr> <tr> diff --git a/phpBB/adm/style/acp_language.html b/phpBB/adm/style/acp_language.html index 4439f519e0..f708eb1508 100644 --- a/phpBB/adm/style/acp_language.html +++ b/phpBB/adm/style/acp_language.html @@ -68,6 +68,10 @@ <p>{L_ACP_LANGUAGE_PACKS_EXPLAIN}</p> + <fieldset class="quick"> + <span class="small"><a href="https://www.phpbb.com/go/customise/language-packs/3.1" target="_blank">{L_BROWSE_LANGUAGE_PACKS_DATABASE}</a></span> + </fieldset> + <table class="table1 zebra-table"> <thead> <tr> diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index 86e666c4ed..92ceaebc08 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -19,7 +19,7 @@ {S_HIDDEN_FIELDS} <div style="text-align: center;"> - <input type="submit" name="confirm" value="{L_YES}" class="button2" /> + <input type="submit" name="confirm" value="{L_YES}" class="button2" /> <input type="submit" name="cancel" value="{L_NO}" class="button2" /> </div> @@ -32,6 +32,10 @@ <!-- IF L_EXPLAIN --><p>{L_EXPLAIN}</p><!-- ENDIF --> +<fieldset class="quick"> + <span class="small"><a href="https://www.phpbb.com/go/customise/styles/3.1" target="_blank">{L_BROWSE_STYLES_DATABASE}</a></span> +</fieldset> + <form id="acp_styles" method="post" action="{U_ACTION}"> {S_HIDDEN_FIELDS} {S_FORM_TOKEN} diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 27dbc48321..cff4bd6289 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -220,12 +220,12 @@ "source": { "type": "git", "url": "https://github.com/s9e/TextFormatter.git", - "reference": "85ac4557e7fc504e74ec0a672680af8481fe329c" + "reference": "326a5a0bbaee59a3d5542fc8e38fe41971931cce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/85ac4557e7fc504e74ec0a672680af8481fe329c", - "reference": "85ac4557e7fc504e74ec0a672680af8481fe329c", + "url": "https://api.github.com/repos/s9e/TextFormatter/zipball/326a5a0bbaee59a3d5542fc8e38fe41971931cce", + "reference": "326a5a0bbaee59a3d5542fc8e38fe41971931cce", "shasum": "" }, "require": { @@ -270,7 +270,7 @@ "parser", "shortcodes" ], - "time": "2015-06-13 12:25:49" + "time": "2015-07-05 23:13:46" }, { "name": "symfony/config", diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index f0ae6c8ab4..f39218ed9c 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -140,3 +140,19 @@ services: - @dbal.conn tags: - { name: console.command } + + console.command.reparser.list: + class: phpbb\console\command\reparser\list_all + arguments: + - @user + - @text_reparser_collection + tags: + - { name: console.command } + + console.command.reparser.reparse: + class: phpbb\console\command\reparser\reparse + arguments: + - @user + - @text_reparser_collection + tags: + - { name: console.command } diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index f7983c57bf..00cdc03f14 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -461,7 +461,7 @@ function mcp_post_details($id, $mode, $action) */ function change_poster(&$post_info, $userdata) { - global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_log; + global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_log, $phpbb_dispatcher; if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) { diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 5cc158de5f..596364cefd 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -407,7 +407,7 @@ class mcp_queue $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { - $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; + $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang['ELLIPSIS']) . '</option>'; } $sort_days = $total = 0; diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 72733f3d0c..5afbe5062e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -855,28 +855,6 @@ class bbcode_firstpass extends bbcode else if (preg_match('#^quote(?:="(.*?)")?$#is', $buffer, $m) && substr($out, -1, 1) == '[') { $this->parsed_items['quote']++; - - // the buffer holds a valid opening tag - if ($config['max_quote_depth'] && sizeof($close_tags) >= $config['max_quote_depth']) - { - if ($config['max_quote_depth'] == 1) - { - // Depth 1 - no nesting is allowed - $error_ary['quote_depth'] = $user->lang('QUOTE_NO_NESTING'); - } - else - { - // There are too many nested quotes - $error_ary['quote_depth'] = $user->lang('QUOTE_DEPTH_EXCEEDED', (int) $config['max_quote_depth']); - } - - $out .= $buffer . $tok; - $tok = '[]'; - $buffer = ''; - - continue; - } - array_push($close_tags, '/quote:' . $this->bbcode_uid); if (isset($m[1]) && $m[1]) @@ -1308,6 +1286,12 @@ class parse_message extends bbcode_firstpass // Parse this message $this->message = $parser->parse(htmlspecialchars_decode($this->message, ENT_QUOTES)); + // Remove quotes that are nested too deep + if ($config['max_quote_depth'] > 0) + { + $this->remove_nested_quotes($config['max_quote_depth']); + } + // Check for "empty" message. We do not check here for maximum length, because bbcode, smilies, etc. can add to the length. // The maximum length check happened before any parsings. if ($mode === 'post' && utf8_clean_string($this->message) === '') @@ -1905,6 +1889,63 @@ class parse_message extends bbcode_firstpass } /** + * Remove nested quotes at given depth in current parsed message + * + * @param integer $max_depth Depth limit + * @return null + */ + public function remove_nested_quotes($max_depth) + { + global $phpbb_container; + + if (preg_match('#^<[rt][ >]#', $this->message)) + { + $this->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( + $this->message, + 'quote', + $max_depth + ); + + return; + } + + // Capture all [quote] and [/quote] tags + preg_match_all('(\\[/?quote(?:="(.*?)")?:' . $this->bbcode_uid . '\\])', $this->message, $matches, PREG_OFFSET_CAPTURE); + + // Iterate over the quote tags to mark the ranges that must be removed + $depth = 0; + $ranges = array(); + $start_pos = 0; + foreach ($matches[0] as $match) + { + if ($match[0][1] === '/') + { + --$depth; + if ($depth == $max_depth) + { + $end_pos = $match[1] + strlen($match[0]); + $length = $end_pos - $start_pos; + $ranges[] = array($start_pos, $length); + } + } + else + { + ++$depth; + if ($depth == $max_depth + 1) + { + $start_pos = $match[1]; + } + } + } + + foreach (array_reverse($ranges) as $range) + { + list($start_pos, $length) = $range; + $this->message = substr_replace($this->message, '', $start_pos, $length); + } + } + + /** * Setter function for passing the plupload object * * @param \phpbb\plupload\plupload $plupload The plupload object diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index bacb33c70a..e5d6789764 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -68,6 +68,12 @@ $lang = array_merge($lang, array( 'EXTENSION_NAME' => 'Extension Name', 'EXTENSION_ACTIONS' => 'Actions', 'EXTENSION_OPTIONS' => 'Options', + 'EXTENSION_INSTALL_HEADLINE'=> 'Installing an extension', + 'EXTENSION_INSTALL_EXPLAIN' => '<ol> + <li>Download an extension from phpBB’s extensions database</li> + <li>Unzip the extension and upload it to the <samp>ext/</samp> directory of your phpBB board</li> + <li>Enable the extension, here in the Extensions manager</li> + </ol>', 'EXTENSION_UPDATE_HEADLINE' => 'Updating an extension', 'EXTENSION_UPDATE_EXPLAIN' => '<ol> <li>Disable the extension</li> @@ -119,6 +125,8 @@ $lang = array_merge($lang, array( 'FORCE_UNSTABLE' => 'Always check for unstable versions', 'EXTENSIONS_VERSION_CHECK_SETTINGS' => 'Version check settings', + 'BROWSE_EXTENSIONS_DATABASE' => 'Browse extensions database', + 'META_FIELD_NOT_SET' => 'Required meta field %s has not been set.', 'META_FIELD_INVALID' => 'Meta field %s is invalid.', )); diff --git a/phpBB/language/en/acp/language.php b/phpBB/language/en/acp/language.php index f46e78efd4..d14491ae75 100644 --- a/phpBB/language/en/acp/language.php +++ b/phpBB/language/en/acp/language.php @@ -73,4 +73,6 @@ $lang = array_merge($lang, array( 'THOSE_MISSING_LANG_VARIABLES' => 'The following language variables are missing from the “%s” language pack', 'UNINSTALLED_LANGUAGE_PACKS' => 'Uninstalled language packs', + + 'BROWSE_LANGUAGE_PACKS_DATABASE' => 'Browse language packs database', )); diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index e6b05c8282..0d91eb3704 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -83,4 +83,6 @@ $lang = array_merge($lang, array( 'STYLE_USED_BY' => 'Used by (including robots)', 'UNINSTALL_DEFAULT' => 'You cannot uninstall the default style.', + + 'BROWSE_STYLES_DATABASE' => 'Browse styles database', )); diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php index 0e7dc39b95..9eca60fb68 100644 --- a/phpBB/language/en/cli.php +++ b/phpBB/language/en/cli.php @@ -61,6 +61,12 @@ $lang = array_merge($lang, array( 'CLI_DESCRIPTION_OPTION_SAFE_MODE' => 'Run in Safe Mode (without extensions).', 'CLI_DESCRIPTION_OPTION_SHELL' => 'Launch the shell.', 'CLI_DESCRIPTION_PURGE_EXTENSION' => 'Purges the specified extension.', + 'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.', + 'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.', + 'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN' => 'Lowest record ID to process', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX' => 'Highest record ID to process', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE' => 'Approximate number of records to process at a time', 'CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH' => 'Recalculates the user_email_hash column of the users table.', 'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value', 'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value', @@ -78,4 +84,8 @@ $lang = array_merge($lang, array( 'CLI_EXTENSIONS_ENABLED' => 'Enabled', 'CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS' => 'Successfully recalculated all email hashes.', + + 'CLI_REPARSER_REPARSE_REPARSING' => 'Reparsing %1$s (range %2$d..%3$d)', + 'CLI_REPARSER_REPARSE_REPARSING_START' => 'Reparsing %s...', + 'CLI_REPARSER_REPARSE_SUCCESS' => 'Reparsing ended with success', )); diff --git a/phpBB/language/en/help_bbcode.php b/phpBB/language/en/help_bbcode.php index 0a8d30581a..989e5fc26e 100644 --- a/phpBB/language/en/help_bbcode.php +++ b/phpBB/language/en/help_bbcode.php @@ -90,7 +90,7 @@ $help = array( ), array( 0 => 'Linking to another site', - 1 => 'phpBB BBCode supports a number of ways of creating URIs (Uniform Resource Indicators) better known as URLs.<ul><li>The first of these uses the <strong>[url=][/url]</strong> tag, whatever you type after the = sign will cause the contents of that tag to act as a URL. For example to link to phpBB.com you could use:<br /><br /><strong>[url=http://www.phpbb.com/]</strong>Visit phpBB!<strong>[/url]</strong><br /><br />This would generate the following link, <a href="http://www.phpbb.com/">Visit phpBB!</a> Please notice that the link opens in the same window or a new window depending on the users browser preferences.</li><li>If you want the URL itself displayed as the link you can do this by simply using:<br /><br /><strong>[url]</strong>http://www.phpbb.com/<strong>[/url]</strong><br /><br />This would generate the following link, <a href="http://www.phpbb.com/">http://www.phpbb.com/</a></li><li>Additionally, phpBB features something called <i>Magic Links</i>, this will turn any syntactically correct URL into a link without you needing to specify any tags or even the leading http://. For example typing www.phpbb.com into your message will automatically lead to <a href="http://www.phpbb.com/">www.phpbb.com</a> being output when you view the message.</li><li>The same thing applies equally to email addresses, you can either specify an address explicitly for example:<br /><br /><strong>[email]</strong>no.one@domain.adr<strong>[/email]</strong><br /><br />which will output <a href="mailto:no.one@domain.adr">no.one@domain.adr</a> or you can just type no.one@domain.adr into your message and it will be automatically converted when you view.</li></ul>As with all the BBCode tags you can wrap URLs around any of the other tags such as <strong>[img][/img]</strong> (see next entry), <strong>[b][/b]</strong>, etc. As with the formatting tags it is up to you to ensure the correct open and close order is following, for example:<br /><br /><strong>[url=http://www.phpbb.com/][img]</strong>http://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/url][/img]</strong><br /><br />is <span style="text-decoration: underline">not</span> correct which may lead to your post being deleted so take care.' + 1 => 'phpBB BBCode supports a number of ways of creating URIs (Uniform Resource Indicators) better known as URLs.<ul><li>The first of these uses the <strong>[url=][/url]</strong> tag, whatever you type after the = sign will cause the contents of that tag to act as a URL. For example to link to phpBB.com you could use:<br /><br /><strong>[url=https://www.phpbb.com/]</strong>Visit phpBB!<strong>[/url]</strong><br /><br />This would generate the following link, <a href="https://www.phpbb.com/">Visit phpBB!</a> Please notice that the link opens in the same window or a new window depending on the users browser preferences.</li><li>If you want the URL itself displayed as the link you can do this by simply using:<br /><br /><strong>[url]</strong>https://www.phpbb.com/<strong>[/url]</strong><br /><br />This would generate the following link, <a href="https://www.phpbb.com/">https://www.phpbb.com/</a></li><li>Additionally, phpBB features something called <i>Magic Links</i>, this will turn any syntactically correct URL into a link without you needing to specify any tags or even the leading https://. For example typing www.phpbb.com into your message will automatically lead to <a href="https://www.phpbb.com/">www.phpbb.com</a> being output when you view the message.</li><li>The same thing applies equally to email addresses, you can either specify an address explicitly for example:<br /><br /><strong>[email]</strong>no.one@domain.adr<strong>[/email]</strong><br /><br />which will output <a href="mailto:no.one@domain.adr">no.one@domain.adr</a> or you can just type no.one@domain.adr into your message and it will be automatically converted when you view.</li></ul>As with all the BBCode tags you can wrap URLs around any of the other tags such as <strong>[img][/img]</strong> (see next entry), <strong>[b][/b]</strong>, etc. As with the formatting tags it is up to you to ensure the correct open and close order is following, for example:<br /><br /><strong>[url=https://www.phpbb.com/][img]</strong>https://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/url][/img]</strong><br /><br />is <span style="text-decoration: underline">not</span> correct which may lead to your post being deleted so take care.' ), array( 0 => '--', @@ -98,7 +98,7 @@ $help = array( ), array( 0 => 'Adding an image to a post', - 1 => 'phpBB BBCode incorporates a tag for including images in your posts. Two very important things to remember when using this tag are: many users do not appreciate lots of images being shown in posts and secondly the image you display must already be available on the internet (it cannot exist only on your computer for example, unless you run a webserver!). To display an image you must surround the URL pointing to the image with <strong>[img][/img]</strong> tags. For example:<br /><br /><strong>[img]</strong>http://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/img]</strong><br /><br />As noted in the URL section above you can wrap an image in a <strong>[url][/url]</strong> tag if you wish, e.g.<br /><br /><strong>[url=http://www.phpbb.com/][img]</strong>http://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/img][/url]</strong><br /><br />would generate:<br /><br /><a href="http://www.phpbb.com/"><img src="http://www.phpbb.com/theme/images/logos/blue/160x52.png" alt="" /></a>' + 1 => 'phpBB BBCode incorporates a tag for including images in your posts. Two very important things to remember when using this tag are: many users do not appreciate lots of images being shown in posts and secondly the image you display must already be available on the internet (it cannot exist only on your computer for example, unless you run a webserver!). To display an image you must surround the URL pointing to the image with <strong>[img][/img]</strong> tags. For example:<br /><br /><strong>[img]</strong>https://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/img]</strong><br /><br />As noted in the URL section above you can wrap an image in a <strong>[url][/url]</strong> tag if you wish, e.g.<br /><br /><strong>[url=https://www.phpbb.com/][img]</strong>https://www.phpbb.com/theme/images/logos/blue/160x52.png<strong>[/img][/url]</strong><br /><br />would generate:<br /><br /><a href="https://www.phpbb.com/"><img src="https://www.phpbb.com/theme/images/logos/blue/160x52.png" alt="" /></a>' ), array( 0 => 'Adding attachments into a post', diff --git a/phpBB/phpbb/console/command/reparser/list_all.php b/phpBB/phpbb/console/command/reparser/list_all.php new file mode 100644 index 0000000000..1589836ddd --- /dev/null +++ b/phpBB/phpbb/console/command/reparser/list_all.php @@ -0,0 +1,69 @@ +<?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\console\command\reparser; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class list_all extends \phpbb\console\command\command +{ + /** + * @var string[] Names of the reparser services + */ + protected $reparser_names; + + /** + * Constructor + * + * @param \phpbb\user $user + * @param \phpbb\di\service_collection $reparsers + */ + public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers) + { + parent::__construct($user); + $this->reparser_names = array(); + foreach ($reparsers as $name => $reparser) + { + // Store the names without the "text_reparser." prefix + $this->reparser_names[] = str_replace('text_reparser.', '', $name); + } + } + + /** + * Sets the command name and description + * + * @return null + */ + protected function configure() + { + $this + ->setName('reparser:list') + ->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_LIST')) + ; + } + + /** + * Executes the command reparser:reparse + * + * @param InputInterface $input + * @param OutputInterface $output + * @return integer + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('<info>' . implode(', ', $this->reparser_names) . '</info>'); + + return 0; + } +} diff --git a/phpBB/phpbb/console/command/reparser/reparse.php b/phpBB/phpbb/console/command/reparser/reparse.php new file mode 100644 index 0000000000..52075dd0ac --- /dev/null +++ b/phpBB/phpbb/console/command/reparser/reparse.php @@ -0,0 +1,188 @@ +<?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\console\command\reparser; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +class reparse extends \phpbb\console\command\command +{ + /** + * @var \phpbb\di\service_collection + */ + protected $reparsers; + + /** + * @var SymfonyStyle + */ + protected $io; + + /** + * Constructor + * + * @param \phpbb\user $user + * @param \phpbb\di\service_collection $reparser_collection + */ + public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers) + { + require_once __DIR__ . '/../../../../includes/functions_content.php'; + + $this->reparsers = $reparsers; + parent::__construct($user); + } + + /** + * Sets the command name and description + * + * @return null + */ + protected function configure() + { + $this + ->setName('reparser:reparse') + ->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE')) + ->addArgument('reparser-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1')) + ->addOption( + 'range-min', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN'), + 1 + ) + ->addOption( + 'range-max', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX') + ) + ->addOption( + 'range-size', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE'), + 100 + ); + ; + } + + /** + * Executes the command reparser:reparse + * + * @param InputInterface $input + * @param OutputInterface $output + * @return integer + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->io = new SymfonyStyle($input, $output); + + $name = $input->getArgument('reparser-name'); + if (isset($name)) + { + // Allow "post_text" to be an alias for "text_reparser.post_text" + if (!isset($this->reparsers[$name])) + { + $name = 'text_reparser.' . $name; + } + $this->reparse($input, $output, $name); + } + else + { + foreach ($this->reparsers as $name => $service) + { + $this->reparse($input, $output, $name); + } + } + + $this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS')); + + return 0; + } + + /** + * Reparse all text handled by given reparser within given range + * + * @param InputInterface $input + * @param OutputInterface $output + * @param string $name Reparser name + * @return null + */ + protected function reparse(InputInterface $input, OutputInterface $output, $name) + { + $reparser = $this->reparsers[$name]; + + // Start at range-max if specified or at the highest ID otherwise + $max = (is_null($input->getOption('range-max'))) ? $reparser->get_max_id() : $input->getOption('range-max'); + $min = $input->getOption('range-min'); + $size = $input->getOption('range-size'); + + if ($max === 0) + { + return; + } + + $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $min, $max)); + + $progress = $this->io->createProgressBar($max); + if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) + { + $progress->setFormat('<info>[%percent:3s%%]</info> %message%'); + $progress->setOverwrite(false); + } + else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) + { + $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%'); + $progress->setOverwrite(false); + } + else + { + $this->io->newLine(2); + $progress->setFormat( + " %current:s%/%max:s% %bar% %percent:3s%%\n" . + " %message% %elapsed:6s%/%estimated:-6s% %memory:6s%\n"); + $progress->setBarWidth(60); + } + + $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', str_replace('text_reparser.', '', $name))); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) + { + $progress->setEmptyBarCharacter('░'); // light shade character \u2591 + $progress->setProgressCharacter(''); + $progress->setBarCharacter('▓'); // dark shade character \u2593 + } + + $progress->start(); + + // Start from $max and decrement $current by $size until we reach $min + $current = $max; + while ($current >= $min) + { + $start = max($min, $current + 1 - $size); + $end = max($min, $current); + + $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $start, $end)); + $reparser->reparse_range($start, $end); + + $current = $start - 1; + $progress->setProgress($max + 1 - $start); + } + $progress->finish(); + + $this->io->newLine(2); + } +} diff --git a/phpBB/phpbb/di/ordered_service_collection.php b/phpBB/phpbb/di/ordered_service_collection.php new file mode 100644 index 0000000000..046012ae5b --- /dev/null +++ b/phpBB/phpbb/di/ordered_service_collection.php @@ -0,0 +1,117 @@ +<?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\di; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Collection of services in a specified order + */ +class ordered_service_collection extends service_collection +{ + /** + * @var bool + */ + protected $is_ordered; + + /** + * @var array + */ + protected $service_ids; + + /** + * Constructor + * + * @param ContainerInterface $container Container object + */ + public function __construct(ContainerInterface $container) + { + $this->is_ordered = false; + $this->service_ids = array(); + + parent::__construct($container); + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return new service_collection_iterator($this); + } + + /** + * {@inheritdoc} + */ + public function offsetExists($index) + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return parent::offsetExists($index); + } + + /** + * {@inheritdoc} + */ + public function offsetGet($index) + { + if (!$this->is_ordered) + { + $this->sort_services(); + } + + return parent::offsetGet($index); + } + + /** + * Adds a service ID to the collection + * + * @param string $service_id + * @param int $order + */ + public function add($service_id, $order = 0) + { + $order = (int) $order; + $this->service_ids[$order][] = $service_id; + $this->is_ordered = false; + } + + protected function sort_services() + { + if ($this->is_ordered) + { + return; + } + + $this->exchangeArray(array()); + ksort($this->service_ids); + foreach ($this->service_ids as $service_order_group) + { + foreach ($service_order_group as $service_id) + { + $this->offsetSet($service_id, null); + } + } + + $this->is_ordered = true; + } +} diff --git a/phpBB/phpbb/di/pass/collection_pass.php b/phpBB/phpbb/di/pass/collection_pass.php index a5c054674e..ccc1250c20 100644 --- a/phpBB/phpbb/di/pass/collection_pass.php +++ b/phpBB/phpbb/di/pass/collection_pass.php @@ -37,7 +37,16 @@ class collection_pass implements CompilerPassInterface foreach ($container->findTaggedServiceIds($data[0]['tag']) as $service_id => $service_data) { - $definition->addMethodCall('add', array($service_id)); + if (substr($definition->getClass(), -strlen('ordered_service_collection')) === 'ordered_service_collection') + { + $arguments = array($service_id, $service_data[0]['order']); + } + else + { + $arguments = array($service_id); + } + + $definition->addMethodCall('add', $arguments); } } } diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php index 0d031ab52d..31bc156e99 100644 --- a/phpBB/phpbb/di/service_collection_iterator.php +++ b/phpBB/phpbb/di/service_collection_iterator.php @@ -32,7 +32,7 @@ class service_collection_iterator extends \ArrayIterator */ public function __construct(service_collection $collection, $flags = 0) { - parent::__construct($collection, $flags); + parent::__construct($collection->getArrayCopy(), $flags); $this->collection = $collection; } diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index cd4e593fb1..2f6498197f 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -66,7 +66,7 @@ class factory implements \phpbb\textformatter\cache_interface protected $default_definitions = array( 'attachment' => '[ATTACHMENT index={NUMBER} filename={TEXT;useContent}]', 'b' => '[B]{TEXT}[/B]', - 'code' => '[CODE]{TEXT}[/CODE]', + 'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]', 'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]', 'email' => '[EMAIL={EMAIL;useContent} subject={TEXT;optional;postFilter=rawurlencode} body={TEXT;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]', 'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]', diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php index 87a4268d0d..ed6c2376c7 100644 --- a/phpBB/phpbb/textreparser/base.php +++ b/phpBB/phpbb/textreparser/base.php @@ -47,11 +47,22 @@ abstract class base implements reparser_interface { if (!isset($record['enable_bbcode'], $record['enable_smilies'], $record['enable_magic_url'])) { - $record += array( - 'enable_bbcode' => $this->guess_bbcodes($record), - 'enable_smilies' => $this->guess_smilies($record), - 'enable_magic_url' => $this->guess_magic_url($record), - ); + if (isset($record['options'])) + { + $record += array( + 'enable_bbcode' => (bool) ($record['options'] & OPTION_FLAG_BBCODE), + 'enable_smilies' => (bool) ($record['options'] & OPTION_FLAG_SMILIES), + 'enable_magic_url' => (bool) ($record['options'] & OPTION_FLAG_LINKS), + ); + } + else + { + $record += array( + 'enable_bbcode' => $this->guess_bbcodes($record), + 'enable_smilies' => $this->guess_smilies($record), + 'enable_magic_url' => $this->guess_magic_url($record), + ); + } } // Those BBCodes are disabled based on context and user permissions and that value is never @@ -92,7 +103,7 @@ abstract class base implements reparser_interface } } - if (substr($record['text'], 0, 2) == '<r') + if (substr($record['text'], 0, 2) === '<r') { // Look for the closing tag inside of a e element, in an element of the same name, e.g. // <e>[/url]</e></URL> @@ -124,7 +135,7 @@ abstract class base implements reparser_interface } } - if (substr($record['text'], 0, 2) == '<r') + if (substr($record['text'], 0, 2) === '<r') { // Look for a closing tag inside of an e element return (bool) preg_match('(<e>\\[/\\w+\\]</e>)', $match); diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php index 7798e4b20b..0302dc3082 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_description.php +++ b/phpBB/phpbb/textreparser/plugins/forum_description.php @@ -24,6 +24,7 @@ class forum_description extends \phpbb\textreparser\row_based_plugin 'id' => 'forum_id', 'text' => 'forum_desc', 'bbcode_uid' => 'forum_desc_uid', + 'options' => 'forum_desc_options', ); } diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php index 57c666a556..ce550225f2 100644 --- a/phpBB/phpbb/textreparser/plugins/forum_rules.php +++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php @@ -24,6 +24,7 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin 'id' => 'forum_id', 'text' => 'forum_rules', 'bbcode_uid' => 'forum_rules_uid', + 'options' => 'forum_rules_options', ); } diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php index ddd0e1d1c5..3346ccf25e 100644 --- a/phpBB/phpbb/textreparser/plugins/group_description.php +++ b/phpBB/phpbb/textreparser/plugins/group_description.php @@ -24,6 +24,7 @@ class group_description extends \phpbb\textreparser\row_based_plugin 'id' => 'group_id', 'text' => 'group_desc', 'bbcode_uid' => 'group_desc_uid', + 'options' => 'group_desc_options', ); } diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php index 7b803146c4..44cacfae62 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_option.php +++ b/phpBB/phpbb/textreparser/plugins/poll_option.php @@ -48,7 +48,7 @@ class poll_option extends \phpbb\textreparser\base */ protected function get_records_by_range($min_id, $max_id) { - $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.bbcode_uid + $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' AND t.topic_id = o.topic_id diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index b447004527..038ae0c366 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -31,7 +31,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin */ protected function get_records_by_range_query($min_id, $max_id) { - $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.bbcode_uid + $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' AND t.poll_max_options > 0 diff --git a/phpBB/posting.php b/phpBB/posting.php index 327004b1bf..eafae332c6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1338,7 +1338,6 @@ if ($submit || $preview || $refresh) 'enable_urls' => (bool) $post_data['enable_urls'], 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, - 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), @@ -1586,13 +1585,12 @@ 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)) +if ($generate_quote && $config['max_quote_depth'] > 0) { - $message_parser->message = $phpbb_container->get('text_formatter.utils')->remove_bbcode( - $message_parser->message, - 'quote', - $config['max_quote_depth'] - 1 - ); + $tmp_bbcode_uid = $message_parser->bbcode_uid; + $message_parser->bbcode_uid = $post_data['bbcode_uid']; + $message_parser->remove_nested_quotes($config['max_quote_depth'] - 1); + $message_parser->bbcode_uid = $tmp_bbcode_uid; } // Decode text for message display diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index ccedf19604..0d53a53d8e 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -34,7 +34,7 @@ function popup(url, width, height, name) { function pageJump(item) { 'use strict'; - var page = item.val(), + var page = parseInt(item.val(), 10), perPage = item.attr('data-per-page'), baseUrl = item.attr('data-base-url'), startName = item.attr('data-start-name'); diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php new file mode 100644 index 0000000000..47e6d23744 --- /dev/null +++ b/tests/di/ordered_service_collection_test.php @@ -0,0 +1,51 @@ +<?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. + * + */ + +class phpbb_ordered_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\ordered_service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + $container->set('foobar', new StdClass); + $container->set('barfoo', new StdClass); + + $this->service_collection = new \phpbb\di\ordered_service_collection($container); + $this->service_collection->add('foo', 7); + $this->service_collection->add('bar', 3); + $this->service_collection->add('barfoo', 5); + $this->service_collection->add('foobar', 2); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foobar', 'bar', 'barfoo', 'foo'), $service_names); + } +} diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php new file mode 100644 index 0000000000..5b51254a4a --- /dev/null +++ b/tests/di/service_collection_test.php @@ -0,0 +1,47 @@ +<?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. + * + */ + +class phpbb_service_collection_test extends \phpbb_test_case +{ + /** + * @var \phpbb\di\service_collection + */ + protected $service_collection; + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $container->set('foo', new StdClass); + $container->set('bar', new StdClass); + + $this->service_collection = new \phpbb\di\service_collection($container); + $this->service_collection->add('foo'); + $this->service_collection->add('bar'); + + parent::setUp(); + } + + public function test_service_collection() + { + $service_names = array(); + + // Test the iterator + foreach ($this->service_collection as $name => $service) + { + $service_names[] = $name; + $this->assertInstanceOf('StdClass', $service); + } + + $this->assertSame(array('foo', 'bar'), $service_names); + } +} diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index 40bec9ceee..c67976301f 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -15,6 +15,17 @@ require_once __DIR__ . '/../../../phpBB/includes/functions_content.php'; class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case { + public function test_bbcode_code_lang_is_saved() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $parser = $container->get('text_formatter.parser'); + + $original = '[code]...[/code][code=php]...[/code]'; + $expected = '<r><CODE><s>[code]</s>...<e>[/code]</e></CODE><CODE lang="php"><s>[code=php]</s>...<e>[/code]</e></CODE></r>'; + + $this->assertXmlStringEqualsXmlString($expected, $parser->parse($original)); + } + /** * @dataProvider get_default_formatting_tests */ diff --git a/tests/text_processing/tickets_data/PHPBB3-10989.html b/tests/text_processing/tickets_data/PHPBB3-10989.html index f003ad3dfa..cd24df60e5 100644 --- a/tests/text_processing/tickets_data/PHPBB3-10989.html +++ b/tests/text_processing/tickets_data/PHPBB3-10989.html @@ -1,6 +1,6 @@ <blockquote><div><cite>Lorem wrote:</cite>[quote="Lorem"<blockquote class="uncited"><div> Suspendisse iaculis porta tempor. Nulla.</div></blockquote> Nullam a tortor sit amet.</div></blockquote> - Proin ac mi eget magna. + Proin ac mi eget magna.<br> <blockquote><div><cite>Lorem wrote:</cite>Quisque fermentum tortor quis odio scelerisque consequat fermentum urna gravida. In semper vehicula condimentum. Donec suscipit ante imperdiet augue rhoncus.</div></blockquote> diff --git a/tests/text_reparser/plugins/fixtures/forums.xml b/tests/text_reparser/plugins/fixtures/forums.xml index 39c172c969..c12c8d6d48 100644 --- a/tests/text_reparser/plugins/fixtures/forums.xml +++ b/tests/text_reparser/plugins/fixtures/forums.xml @@ -5,87 +5,109 @@ <column>forum_parents</column> <column>forum_desc</column> <column>forum_desc_uid</column> + <column>forum_desc_options</column> <column>forum_rules</column> <column>forum_rules_uid</column> + <column>forum_rules_options</column> <row> <value>1</value> <value></value> <value>This row should be [b]ignored[/b]</value> <value>abcd1234</value> + <value>0</value> <value>This row should be [b]ignored[/b]</value> <value>abcd1234</value> + <value>0</value> </row> <row> <value>2</value> <value></value> <value>[b]Not bold[/b] :) http://example.org</value> <value>abcd1234</value> + <value>0</value> <value>[b]Not bold[/b] :) http://example.org</value> <value>abcd1234</value> + <value>0</value> </row> <row> <value>3</value> <value></value> <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value> <value>abcd1234</value> + <value>1</value> <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value> <value>abcd1234</value> + <value>1</value> </row> <row> <value>4</value> <value></value> <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value> <value>abcd1234</value> + <value>2</value> <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value> <value>abcd1234</value> + <value>2</value> </row> <row> <value>5</value> <value></value> <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value> <value>abcd1234</value> + <value>4</value> <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value> <value>abcd1234</value> + <value>4</value> </row> <row> <value>6</value> <value></value> <value><![CDATA[[flash=123,345:abcd1234]http://example.org/flash.swf[/flash:abcd1234]]]></value> <value>abcd1234</value> + <value>1</value> <value><![CDATA[[flash=123,345:abcd1234]http://example.org/flash.swf[/flash:abcd1234]]]></value> <value>abcd1234</value> + <value>1</value> </row> <row> <value>7</value> <value></value> <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value> <value>abcd1234</value> + <value>0</value> <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value> <value>abcd1234</value> + <value>0</value> </row> <row> <value>8</value> <value></value> <value><![CDATA[[img:abcd1234]http://example.org/img.png[/img:abcd1234]]]></value> <value>abcd1234</value> + <value>1</value> <value><![CDATA[[img:abcd1234]http://example.org/img.png[/img:abcd1234]]]></value> <value>abcd1234</value> + <value>1</value> </row> <row> <value>9</value> <value></value> <value><![CDATA[[img]http://example.org/img.png[/img]]]></value> <value>abcd1234</value> + <value>0</value> <value><![CDATA[[img]http://example.org/img.png[/img]]]></value> <value>abcd1234</value> + <value>0</value> </row> <row> <value>1000</value> <value></value> <value>This row should be [b]ignored[/b]</value> <value>abcd1234</value> + <value>0</value> <value>This row should be [b]ignored[/b]</value> <value>abcd1234</value> + <value>0</value> </row> </table> </dataset> diff --git a/tests/text_reparser/plugins/fixtures/groups.xml b/tests/text_reparser/plugins/fixtures/groups.xml index d3df0131a3..15151426bc 100644 --- a/tests/text_reparser/plugins/fixtures/groups.xml +++ b/tests/text_reparser/plugins/fixtures/groups.xml @@ -38,25 +38,25 @@ <row> <value>6</value> <value><![CDATA[[flash=123,345:abcd1234]http://example.org/flash.swf[/flash:abcd1234]]]></value> - <value>7</value> + <value>1</value> <value>abcd1234</value> </row> <row> <value>7</value> <value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value> - <value>7</value> + <value>1</value> <value>abcd1234</value> </row> <row> <value>8</value> <value><![CDATA[[img:abcd1234]http://example.org/img.png[/img:abcd1234]]]></value> - <value>7</value> + <value>1</value> <value>abcd1234</value> </row> <row> <value>9</value> <value><![CDATA[[img]http://example.org/img.png[/img]]]></value> - <value>7</value> + <value>1</value> <value>abcd1234</value> </row> <row> diff --git a/tests/text_reparser/plugins/fixtures/poll_options.xml b/tests/text_reparser/plugins/fixtures/poll_options.xml index c2fad9f764..48ba024315 100644 --- a/tests/text_reparser/plugins/fixtures/poll_options.xml +++ b/tests/text_reparser/plugins/fixtures/poll_options.xml @@ -31,6 +31,21 @@ </row> <row> <value>1</value> + <value>11</value> + <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value> + </row> + <row> + <value>1</value> + <value>12</value> + <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value> + </row> + <row> + <value>1</value> + <value>13</value> + <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value> + </row> + <row> + <value>1</value> <value>123</value> <value>This row should be [b]ignored[/b]</value> </row> @@ -42,10 +57,40 @@ </table> <table name="phpbb_posts"> <column>post_id</column> + <column>enable_bbcode</column> + <column>enable_smilies</column> + <column>enable_magic_url</column> <column>post_text</column> <column>bbcode_uid</column> <row> <value>1</value> + <value>1</value> + <value>1</value> + <value>1</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>11</value> + <value>1</value> + <value>0</value> + <value>0</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>12</value> + <value>0</value> + <value>1</value> + <value>0</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>13</value> + <value>0</value> + <value>0</value> + <value>1</value> <value></value> <value>abcd1234</value> </row> @@ -65,6 +110,21 @@ <value>This row should be [b]ignored[/b]</value> </row> <row> + <value>11</value> + <value>11</value> + <value>BBCode</value> + </row> + <row> + <value>12</value> + <value>12</value> + <value>Smilies</value> + </row> + <row> + <value>13</value> + <value>13</value> + <value>Magic URLs</value> + </row> + <row> <value>123</value> <value>1</value> <value>This row should be [b]ignored[/b]</value> diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml index 9baf813c97..2960d640a9 100644 --- a/tests/text_reparser/plugins/fixtures/polls.xml +++ b/tests/text_reparser/plugins/fixtures/polls.xml @@ -2,10 +2,40 @@ <dataset> <table name="phpbb_posts"> <column>post_id</column> + <column>enable_bbcode</column> + <column>enable_smilies</column> + <column>enable_magic_url</column> <column>post_text</column> <column>bbcode_uid</column> <row> <value>1</value> + <value>0</value> + <value>0</value> + <value>0</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>0</value> + <value>0</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>3</value> + <value>0</value> + <value>1</value> + <value>0</value> + <value></value> + <value>abcd1234</value> + </row> + <row> + <value>4</value> + <value>0</value> + <value>0</value> + <value>1</value> <value></value> <value>abcd1234</value> </row> @@ -26,22 +56,22 @@ </row> <row> <value>3</value> - <value>1</value> + <value>2</value> <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value> </row> <row> <value>4</value> - <value>1</value> + <value>3</value> <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value> </row> <row> <value>5</value> - <value>1</value> + <value>4</value> <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value> </row> <row> <value>6</value> - <value>1</value> + <value>2</value> <value><![CDATA[[flash=123,345:abcd1234]http://example.org/flash.swf[/flash:abcd1234]]]></value> </row> <row> @@ -51,7 +81,7 @@ </row> <row> <value>8</value> - <value>1</value> + <value>2</value> <value><![CDATA[[img:abcd1234]http://example.org/img.png[/img:abcd1234]]]></value> </row> <row> diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index e043858597..acabda2146 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -49,7 +49,7 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case public function testReparse() { $reparser = $this->get_reparser(); - $reparser->reparse_range(2, 3); + $reparser->reparse_range(2, 13); $sql = 'SELECT topic_id, poll_option_id, poll_option_text FROM ' . POLL_OPTIONS_TABLE . ' @@ -85,6 +85,21 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case 'poll_option_text' => '<r><URL url="http://example.org">http://example.org</URL></r>', ), array( + 'topic_id' => 11, + 'poll_option_id' => 1, + 'poll_option_text' => '<r><B><s>[b]</s>Bold<e>[/b]</e></B> :) http://example.org</r>', + ), + array( + 'topic_id' => 12, + 'poll_option_id' => 1, + 'poll_option_text' => '<r>[b]Not bold[/b] <E>:)</E> http://example.org</r>', + ), + array( + 'topic_id' => 13, + 'poll_option_id' => 1, + 'poll_option_text' => '<r>[b]Not bold[/b] :) <URL url="http://example.org">http://example.org</URL></r>', + ), + array( 'topic_id' => 123, 'poll_option_id' => 1, 'poll_option_text' => 'This row should be [b]ignored[/b]', |