[ticket/11768] Preserve comments in custom BBCodes

PHPBB3-11768
This commit is contained in:
JoshyPHP 2015-03-21 12:32:17 +01:00
parent 3cd5ca8de1
commit 69dae16ba7
3 changed files with 47 additions and 0 deletions

View file

@ -180,6 +180,10 @@ class factory implements \phpbb\textformatter\cache_interface
// Don't automatically ignore text in places where text is not allowed // Don't automatically ignore text in places where text is not allowed
$configurator->rulesGenerator->remove('IgnoreTextIfDisallowed'); $configurator->rulesGenerator->remove('IgnoreTextIfDisallowed');
// Don't remove comments and instead convert them to xsl:comment elements
$configurator->templateNormalizer->remove('RemoveComments');
$configurator->templateNormalizer->add('TransposeComments');
// Set the rendering engine and configure it to save to the cache dir // Set the rendering engine and configure it to save to the cache dir
$configurator->rendering->engine = 'PHP'; $configurator->rendering->engine = 'PHP';
$configurator->rendering->engine->cacheDir = $this->cache_dir; $configurator->rendering->engine->cacheDir = $this->cache_dir;

View file

@ -178,6 +178,21 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
$this->assertSame($expected, $renderer->render($parser->parse($original))); $this->assertSame($expected, $renderer->render($parser->parse($original)));
} }
/**
* @testdox Preserves comments in custom BBCodes
*/
public function test_preserve_comments()
{
$fixture = __DIR__ . '/fixtures/preserve_comments.xml';
$container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture);
$parser = $container->get('text_formatter.parser');
$renderer = $container->get('text_formatter.renderer');
$original = '[X]';
$expected = '<!-- comment -->';
$this->assertSame($expected, $renderer->render($parser->parse($original)));
}
/** /**
* @testdox Accepts unsafe custom BBCodes * @testdox Accepts unsafe custom BBCodes
*/ */

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_bbcodes">
<column>bbcode_id</column>
<column>bbcode_tag</column>
<column>bbcode_helpline</column>
<column>display_on_posting</column>
<column>bbcode_match</column>
<column>bbcode_tpl</column>
<column>first_pass_match</column>
<column>first_pass_replace</column>
<column>second_pass_match</column>
<column>second_pass_replace</column>
<row>
<value>13</value>
<value>X</value>
<value></value>
<value>1</value>
<value>[X][/X]</value>
<value><![CDATA[<!-- comment -->]]></value>
<value><![CDATA[!\[x\]\[/x\]!i]]></value>
<value><![CDATA[[x:$uid][/x:$uid]]]></value>
<value><![CDATA[[x:$uid][/x:$uid]]]></value>
<value></value>
</row>
</table>
</dataset>