ignore `{}` during template compilation
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 Jun 2016 13:06:55 +0000 (15:06 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 Jun 2016 13:06:55 +0000 (15:06 +0200)
This avoids empty JavaScript object literals being recognized as
template scripting tags

wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php

index 6b709f81e0c65775591a8eb25e46526cf2404423..f23793bb4ee3a897075536f27e91e89fca23f300 100644 (file)
@@ -239,7 +239,16 @@ class TemplateScriptingCompiler {
                $compiledTags = [];
                for ($i = 0, $j = count($templateTags); $i < $j; $i++) {
                        $this->currentLineNo += mb_substr_count($textBlocks[$i], "\n");
-                       $compiledTags[] = $this->compileTag($templateTags[$i], $identifier, $metaData);
+                       
+                       if ($templateTags[$i] === '') {
+                               // avoid empty JavaScript object literals being recognized
+                               // as template scripting tags
+                               $compiledTags[] = '{}';
+                       }
+                       else {
+                               $compiledTags[] = $this->compileTag($templateTags[$i], $identifier, $metaData);
+                       }
+                       
                        $this->currentLineNo += mb_substr_count($templateTags[$i], "\n");
                }