From 784945d6379a5685cde7334732d0579dc1d9fc2d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 18 Jul 2023 12:04:30 +0200 Subject: [PATCH] Provide a sane width attribute for attachments --- .../files/lib/system/bbcode/AttachmentBBCode.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php index 149d82c9ef..82188dfb75 100644 --- a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php @@ -65,7 +65,10 @@ final class AttachmentBBCode extends AbstractBBCode { $alignment = $attributes[1] ?? ''; $thumbnail = $this->renderImageAsThumbnail($attachment, $outputType, $attributes[2] ?? false); - $width = $attributes[3] ?? '100%'; + $width = $attributes[3] ?? ''; + if (!\preg_match('~^(?:100%|\d{2}(?:\.\d{2})?%)$~', $width)) { + $width = '100%'; + } if ($thumbnail) { -- 2.20.1