aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/config/default/container/services_feed.yml3
-rw-r--r--phpBB/phpbb/feed/feed_quote_helper.php35
-rw-r--r--phpBB/phpbb/feed/helper.php25
3 files changed, 49 insertions, 14 deletions
diff --git a/phpBB/config/default/container/services_feed.yml b/phpBB/config/default/container/services_feed.yml
index b7ef1f9b6d..20ed193e96 100644
--- a/phpBB/config/default/container/services_feed.yml
+++ b/phpBB/config/default/container/services_feed.yml
@@ -19,9 +19,8 @@ services:
arguments:
- '@config'
- '@path_helper'
+ - '@text_formatter.renderer'
- '@user'
- - '%core.root_path%'
- - '%core.php_ext%'
feed.forum:
class: phpbb\feed\forum
diff --git a/phpBB/phpbb/feed/feed_quote_helper.php b/phpBB/phpbb/feed/feed_quote_helper.php
new file mode 100644
index 0000000000..02a9b35dc0
--- /dev/null
+++ b/phpBB/phpbb/feed/feed_quote_helper.php
@@ -0,0 +1,35 @@
+<?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\feed;
+
+/**
+ * Modified quote_helper for feeds (basically just removing all attributes)
+ */
+class feed_quote_helper extends \phpbb\textformatter\s9e\quote_helper
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function inject_metadata($xml)
+ {
+ // In feeds we don't want any attributes, so delete all of them
+ return \s9e\TextFormatter\Utils::replaceAttributes(
+ $xml,
+ 'QUOTE',
+ function () {
+ return [];
+ }
+ );
+ }
+}
diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php
index 3bca8598a5..df7388331c 100644
--- a/phpBB/phpbb/feed/helper.php
+++ b/phpBB/phpbb/feed/helper.php
@@ -24,20 +24,25 @@ class helper
/** @var \phpbb\path_helper */
protected $path_helper;
+ /** @var \phpbb\textformatter\s9e\renderer */
+ protected $renderer;
+
/** @var \phpbb\user */
protected $user;
/**
* Constructor
*
- * @param \phpbb\config\config $config Config object
- * @param \phpbb\path_helper $path_helper Path helper object
- * @param \phpbb\user $user User object
+ * @param \phpbb\config\config $config Config object
+ * @param \phpbb\path_helper $path_helper Path helper object
+ * @param \phpbb\textformatter\s9e\renderer $renderer TextFormatter renderer object
+ * @param \phpbb\user $user User object
*/
- public function __construct(\phpbb\config\config $config, \phpbb\path_helper $path_helper, \phpbb\user $user)
+ public function __construct(\phpbb\config\config $config, \phpbb\path_helper $path_helper, \phpbb\textformatter\s9e\renderer $renderer, \phpbb\user $user)
{
$this->config = $config;
$this->path_helper = $path_helper;
+ $this->renderer = $renderer;
$this->user = $user;
}
@@ -99,16 +104,12 @@ class helper
return '';
}
- // Prepare some bbcodes for better parsing
- $content = preg_replace("#\[quote(=&quot;.*?&quot;)?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content);
-
- $content = generate_text_for_display($content, $uid, $bitfield, $options);
+ // Setup our own quote_helper to remove all attributes from quotes
+ $this->renderer->configure_quote_helper(new feed_quote_helper($this->user, $this->path_helper->get_phpbb_root_path(), $this->path_helper->get_php_ext()));
- // Add newlines
- $content = str_replace('<br />', '<br />' . "\n", $content);
+ $this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']);
- // Convert smiley Relative paths to Absolute path, Windows style
- $content = str_replace($this->path_helper->get_web_root_path() . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content);
+ $content = generate_text_for_display($content, $uid, $bitfield, $options);
// Remove "Select all" link and mouse events
$content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content);