1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-20 23:51:28 +01:00

Merge pull request #51 from phpbb/ticket/security/243

[ticket/security/243] Limit size BBCode to int
This commit is contained in:
Marc Alexander 2019-08-25 18:28:08 +02:00
commit 79be901cea
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
6 changed files with 16 additions and 4 deletions

View File

@ -140,6 +140,7 @@ $lang = array_merge($lang, array(
'IMAGES_ARE_OFF' => '[img] is <em>OFF</em>',
'IMAGES_ARE_ON' => '[img] is <em>ON</em>',
'INVALID_FILENAME' => '%s is an invalid filename.',
'INVALID_FONT_SIZE' => 'The font size you supplied is invalid: %s',
'LOAD' => 'Load',
'LOAD_DRAFT' => 'Load draft',

View File

@ -110,7 +110,7 @@ class factory implements \phpbb\textformatter\cache_interface
'i' => '<span style="font-style: italic"><xsl:apply-templates/></span>',
'u' => '<span style="text-decoration: underline"><xsl:apply-templates/></span>',
'img' => '<img src="{IMAGEURL}" class="postimage" alt="{L_IMAGE}"/>',
'size' => '<span style="font-size: {FONTSIZE}%; line-height: normal"><xsl:apply-templates/></span>',
'size' => '<span><xsl:attribute name="style"><xsl:text>font-size: </xsl:text><xsl:value-of select="substring(@size, 1, 4)"/><xsl:text>%; line-height: normal</xsl:text></xsl:attribute><xsl:apply-templates/></span>',
'color' => '<span style="color: {COLOR}"><xsl:apply-templates/></span>',
'email' => '<a>
<xsl:attribute name="href">

View File

@ -228,6 +228,10 @@ class parser implements \phpbb\textformatter\parser_interface
{
$errors[] = array($msg);
}
else if ($msg === 'INVALID_FONT_SIZE')
{
$errors[] = [$msg, $context['invalid_size']];
}
}
// Deduplicate error messages. array_unique() only works on strings so we have to serialize
@ -335,6 +339,13 @@ class parser implements \phpbb\textformatter\parser_interface
*/
static public function filter_font_size($size, $max_size, Logger $logger)
{
if (!is_numeric($size))
{
$logger->err('INVALID_FONT_SIZE', ['invalid_size' => htmlspecialchars($size)]);
return false;
}
if ($max_size && $size > $max_size)
{
$logger->err('MAX_FONT_SIZE_EXCEEDED', array('max_size' => $max_size));

View File

@ -64,7 +64,7 @@
<!-- BEGIN color --><span style="color: {COLOR}">{TEXT}</span><!-- END color -->
<!-- BEGIN size --><span style="font-size: {SIZE}%; line-height: 116%;">{TEXT}</span><!-- END size -->
<!-- BEGIN size --><span><xsl:attribute name="style"><xsl:text>font-size: </xsl:text><xsl:value-of select="substring(@size, 1, 4)"/><xsl:text>%; line-height: normal</xsl:text></xsl:attribute><xsl:apply-templates/></span><!-- END size -->
<!-- BEGIN img --><img src="{URL}" class="postimage" alt="{L_IMAGE}" /><!-- END img -->

View File

@ -70,7 +70,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
),
array(
'[size=75]smaller[/size]',
'<span style="font-size:75%;line-height:normal">smaller</span>'
'<span style="font-size: 75%; line-height: normal">smaller</span>'
),
array(
'[quote]quoted[/quote]',

View File

@ -1 +1 @@
<span style="font-size:200%;line-height:normal"></span><div style="text-align:center"><span style="font-size:200%;line-height:normal">xxx</span></div>
<span style="font-size: 200%; line-height: normal"></span><div style="text-align:center"><span style="font-size: 200%; line-height: normal">xxx</span></div>