From daf30b89f133aee0beb09d6bd1d00decc471ba46 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Aug 2023 22:04:23 +0200 Subject: [PATCH] [ticket/17176] Limit characters for bbcode uid PHPBB3-17176 --- phpBB/includes/functions.php | 2 +- phpBB/includes/message_parser.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 379422b819..61a156ae65 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -36,7 +36,7 @@ function gen_rand_string($num_chars = 8) $output = ''; for ($i = 0; $i < $num_chars; $i++) { - $rand = random_int(0, $size-1); + $rand = random_int(0, $size - 1); $output .= $range[$rand]; } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index e82b2168b4..337b6ccab8 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1056,7 +1056,8 @@ class parse_message extends bbcode_firstpass function __construct($message = '') { // Init BBCode UID - $this->bbcode_uid = substr(base_convert(unique_id(), 16, 36), 0, BBCODE_UID_LEN); + $unique_id = preg_replace('/[^0-9a-f]/', '', unique_id()); + $this->bbcode_uid = substr(base_convert($unique_id, 16, 36), 0, BBCODE_UID_LEN); $this->message = $message; }