aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2019-12-12 18:16:55 +0100
committerMarc Alexander <admin@m-a-styles.de>2019-12-12 18:16:55 +0100
commit4a950750f4735a410b057f09462ce770697d0301 (patch)
tree9e762ba814ffa82d1e33cb7ee0b63cd9e7972a24 /phpBB
parent1f00e160ab69b2a709793abc1829cc6e91e07b93 (diff)
parent5813b5fbee2ac332f14dee2da7df9c3dfd6c2719 (diff)
downloadforums-4a950750f4735a410b057f09462ce770697d0301.tar
forums-4a950750f4735a410b057f09462ce770697d0301.tar.gz
forums-4a950750f4735a410b057f09462ce770697d0301.tar.bz2
forums-4a950750f4735a410b057f09462ce770697d0301.tar.xz
forums-4a950750f4735a410b057f09462ce770697d0301.zip
Merge pull request #5772 from JoshyPHP/ticket/16252
[ticket/16252] Ignore non-BBCodes when looking for unauthorized markup
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/textformatter/s9e/parser.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php
index a36fc63141..f7e4668980 100644
--- a/phpBB/phpbb/textformatter/s9e/parser.php
+++ b/phpBB/phpbb/textformatter/s9e/parser.php
@@ -15,6 +15,7 @@ namespace phpbb\textformatter\s9e;
use s9e\TextFormatter\Parser\AttributeFilters\UrlFilter;
use s9e\TextFormatter\Parser\Logger;
+use s9e\TextFormatter\Parser\Tag;
/**
* s9e\TextFormatter\Parser adapter
@@ -219,7 +220,7 @@ class parser implements \phpbb\textformatter\parser_interface
{
$errors[] = array($msg, $context['max_' . strtolower($m[1])]);
}
- else if ($msg === 'Tag is disabled')
+ else if ($msg === 'Tag is disabled' && $this->is_a_bbcode($context['tag']))
{
$name = strtolower($context['tag']->getName());
$errors[] = array('UNAUTHORISED_BBCODE', '[' . $name . ']');
@@ -396,4 +397,21 @@ class parser implements \phpbb\textformatter\parser_interface
return $url;
}
+
+ /**
+ * Test whether given tag consumes text that looks like BBCode-styled markup
+ *
+ * @param Tag $tag Original tag
+ * @return bool
+ */
+ protected function is_a_bbcode(Tag $tag)
+ {
+ if ($tag->getLen() < 3)
+ {
+ return false;
+ }
+ $markup = substr($this->parser->getText(), $tag->getPos(), $tag->getLen());
+
+ return (bool) preg_match('(^\\[\\w++.*?\\]$)s', $markup);
+ }
}