From c934d3fcfdaaa1e8c2161577690fef9dcb41b1e1 Mon Sep 17 00:00:00 2001
From: Marc Alexander <admin@m-a-styles.de>
Date: Wed, 17 Jul 2019 22:02:32 +0200
Subject: [PATCH] [ticket/security/243] Limit size BBCode to 4 numeric
 characters

SECURITY-243
---
 phpBB/phpbb/textformatter/s9e/factory.php   | 2 +-
 phpBB/phpbb/textformatter/s9e/parser.php    | 2 +-
 phpBB/styles/prosilver/template/bbcode.html | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php
index 6191b9a315..d339e3311d 100644
--- a/phpBB/phpbb/textformatter/s9e/factory.php
+++ b/phpBB/phpbb/textformatter/s9e/factory.php
@@ -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(@FONTSIZE, 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">
diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php
index e30bc2b0d9..1bc56a8cb4 100644
--- a/phpBB/phpbb/textformatter/s9e/parser.php
+++ b/phpBB/phpbb/textformatter/s9e/parser.php
@@ -339,7 +339,7 @@ class parser implements \phpbb\textformatter\parser_interface
 	*/
 	static public function filter_font_size($size, $max_size, Logger $logger)
 	{
-		if (!is_int($size))
+		if (!is_numeric($size))
 		{
 			$logger->err('INVALID_FONT_SIZE', ['invalid_size' => htmlspecialchars($size)]);
 
diff --git a/phpBB/styles/prosilver/template/bbcode.html b/phpBB/styles/prosilver/template/bbcode.html
index 940c0ace29..f4ec94dbfe 100644
--- a/phpBB/styles/prosilver/template/bbcode.html
+++ b/phpBB/styles/prosilver/template/bbcode.html
@@ -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 -->