diff options
author | Marc Alexander <admin@m-a-styles.de> | 2018-01-25 18:23:09 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2018-01-25 18:23:09 +0100 |
commit | c89051eb288ed14a401ba166df6bfdd6bb860833 (patch) | |
tree | e4ce665f6cd9418ebc26615a0345778531235272 /phpBB/phpbb/textformatter | |
parent | a74658091b19a8d8100b241ce6ac710e472918e8 (diff) | |
parent | 3c5b3254d151c052070aa1e5ef2efef7d850f95b (diff) | |
download | forums-c89051eb288ed14a401ba166df6bfdd6bb860833.tar forums-c89051eb288ed14a401ba166df6bfdd6bb860833.tar.gz forums-c89051eb288ed14a401ba166df6bfdd6bb860833.tar.bz2 forums-c89051eb288ed14a401ba166df6bfdd6bb860833.tar.xz forums-c89051eb288ed14a401ba166df6bfdd6bb860833.zip |
Merge pull request #5103 from JoshyPHP/ticket/15531
[ticket/15531] Log malformed BBCodes
Diffstat (limited to 'phpBB/phpbb/textformatter')
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/factory.php | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 1e85856898..c0bbc7b0e8 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -132,6 +132,11 @@ class factory implements \phpbb\textformatter\cache_interface protected $dispatcher; /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** * Constructor * * @param \phpbb\textformatter\data_access $data_access @@ -139,11 +144,12 @@ class factory implements \phpbb\textformatter\cache_interface * @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\config\config $config * @param \phpbb\textformatter\s9e\link_helper $link_helper + * @param \phpbb\log\log_interface $log * @param string $cache_dir Path to the cache dir * @param string $cache_key_parser Cache key used for the parser * @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, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, $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, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer) { $this->link_helper = $link_helper; $this->cache = $cache; @@ -153,6 +159,7 @@ class factory implements \phpbb\textformatter\cache_interface $this->config = $config; $this->data_access = $data_access; $this->dispatcher = $dispatcher; + $this->log = $log; } /** @@ -272,7 +279,7 @@ class factory implements \phpbb\textformatter\cache_interface // Add default BBCodes foreach ($this->get_default_bbcodes($configurator) as $bbcode) { - $configurator->BBCodes->addCustom($bbcode['usage'], new UnsafeTemplate($bbcode['template'])); + $this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']); } if (isset($configurator->tags['QUOTE'])) { @@ -299,17 +306,7 @@ class factory implements \phpbb\textformatter\cache_interface }, $row['bbcode_tpl'] ); - - try - { - $configurator->BBCodes->addCustom($row['bbcode_match'], new UnsafeTemplate($tpl)); - } - catch (\Exception $e) - { - /** - * @todo log an error? - */ - } + $this->add_bbcode($configurator, $row['bbcode_match'], $tpl); } // Load smilies @@ -419,6 +416,26 @@ class factory implements \phpbb\textformatter\cache_interface } /** + * Add a BBCode to given configurator + * + * @param Configurator $configurator + * @param string $usage + * @param string $template + * @return void + */ + protected function add_bbcode(Configurator $configurator, $usage, $template) + { + try + { + $configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template)); + } + catch (\Exception $e) + { + $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); + } + } + + /** * Configure the Autolink / Autoemail plugins used to linkify text * * @param \s9e\TextFormatter\Configurator $configurator |