From befc6506534f19e7bd1b15adea563d541846a9d9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 14 Nov 2024 12:21:02 +0100 Subject: [PATCH] Return a sane list of defaults if the selected highlighters are empty In previous versions it was possible that the selection got lost, eventually breaking the implementation. --- .../lib/system/bbcode/BBCodeHandler.class.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php index 60814a938b..ea228ee98d 100644 --- a/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/BBCodeHandler.class.php @@ -189,7 +189,30 @@ class BBCodeHandler extends SingletonFactory */ public function getCodeBlockLanguages(): array { - return \explode("\n", StringUtil::unifyNewlines(\MESSAGE_PUBLIC_HIGHLIGHTERS)); + $highlighters = \explode("\n", StringUtil::unifyNewlines(\MESSAGE_PUBLIC_HIGHLIGHTERS)); + if ($highlighters !== []) { + return $highlighters; + } + + return [ + 'c', + 'cpp', + 'csharp', + 'css', + 'go', + 'html', + 'java', + 'javascript', + 'json', + 'php', + 'python', + 'ruby', + 'rust', + 'sql', + 'typescript', + 'xml', + 'yaml', + ]; } /** -- 2.20.1