Add a safe-guard against misbehaving metacodes
authorAlexander Ebert <ebert@woltlab.com>
Thu, 9 Jan 2025 11:02:55 +0000 (12:02 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 9 Jan 2025 11:02:55 +0000 (12:02 +0100)
wcfsetup/install/files/lib/system/html/node/AbstractHtmlNodeProcessor.class.php

index c082a869db7e74d9a749c80dda5b62c0f28b13e5..f93aee3416da97995f600cc13876480263be3493 100644 (file)
@@ -121,6 +121,16 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor
                     $obj = $data['object'];
                     $string = $obj->replaceTag($data['data']);
 
+                    if (!\is_string($string) && !\is_numeric($string)) {
+                        throw new \RuntimeException(
+                            \sprintf(
+                                "%s::replaceTag() returned %s but a string or number was expected.",
+                                \get_class($obj),
+                                \gettype($string),
+                            ),
+                        );
+                    }
+
                     if (!isset($data['data']['skipInnerContent']) || $data['data']['skipInnerContent'] !== true) {
                         if (\str_contains($string, '<!-- META_CODE_INNER_CONTENT -->')) {
                             return \str_replace('<!-- META_CODE_INNER_CONTENT -->', $matches['content'], $string);