Merge branch '3.3.x'

This commit is contained in:
Marc Alexander 2020-11-11 21:50:11 +01:00
commit 40a598b93e
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 16 additions and 5 deletions

View file

@ -532,7 +532,7 @@ function strip_bbcode(&$text, $uid = '')
if (preg_match('#^<[rt][ >]#', $text)) if (preg_match('#^<[rt][ >]#', $text))
{ {
$text = $phpbb_container->get('text_formatter.utils')->clean_formatting($text); $text = utf8_htmlspecialchars($phpbb_container->get('text_formatter.utils')->clean_formatting($text));
} }
else else
{ {

View file

@ -15,6 +15,9 @@ namespace phpbb\textformatter\s9e;
/** /**
* Text manipulation utilities * Text manipulation utilities
*
* In this implementation, "plain text" refers to regular text as it would be inputted by a user.
* "Parsed text" is XML suitable to be reinserted into the database.
*/ */
class utils implements \phpbb\textformatter\utils_interface class utils implements \phpbb\textformatter\utils_interface
{ {
@ -31,7 +34,7 @@ class utils implements \phpbb\textformatter\utils_interface
// Insert a space before <s> and <e> then remove formatting // Insert a space before <s> and <e> then remove formatting
$xml = preg_replace('#<[es]>#', ' $0', $xml); $xml = preg_replace('#<[es]>#', ' $0', $xml);
return utf8_htmlspecialchars(\s9e\TextFormatter\Utils::removeFormatting($xml)); return \s9e\TextFormatter\Utils::removeFormatting($xml);
} }
/** /**

View file

@ -15,6 +15,10 @@ namespace phpbb\textformatter;
/** /**
* Used to manipulate a parsed text * Used to manipulate a parsed text
*
* In this interface, "plain text" refers to regular text as it would be inputted by a user.
* "Parsed text" refers to whichever form is returned by the implementation after parsing, which
* should be suitable to be reinserted into the database.
*/ */
interface utils_interface interface utils_interface
{ {
@ -73,7 +77,7 @@ interface utils_interface
* Return whether or not a parsed text represent an empty text. * Return whether or not a parsed text represent an empty text.
* *
* @param string $text Parsed text * @param string $text Parsed text
* @return bool Tue if the original text is empty * @return bool True if the original text is empty
*/ */
public function is_empty($text); public function is_empty($text);
} }

View file

@ -60,13 +60,17 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case
'<t>Plain text</t>', '<t>Plain text</t>',
'Plain text' 'Plain text'
), ),
array(
'<t>Plain &amp; boring</t>',
'Plain & boring'
),
array( array(
"<t>Multi<br/>\nline</t>", "<t>Multi<br/>\nline</t>",
"Multi\nline" "Multi\nline"
), ),
array( array(
'<r><B><s>[b]</s>bold<e>[/b]</e></B></r>', '<r><B><s>[b]</s>bold<e>[/b]</e></B> &amp; <I><s>[i]</s>italic<e>[/i]</e></I></r>',
' bold ' ' bold & italic '
) )
); );
} }