Implemented modifier fixes from pull request #133
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Aug 2011 14:20:56 +0000 (16:20 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Aug 2011 14:20:56 +0000 (16:20 +0200)
I've omitted the pull request, since we do want to keep 'encodeJS' for better reading. Anyway, credits for this fix go to TimWolla.

wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/lib/system/template/TemplateEngine.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/files/lib/system/template/plugin/EncodeJSModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php [deleted file]

index 7078500cca2acbfa6ba3e4c348ed91bcabcd3ba4..2e7eef05022fe389d2c131b19a548a992a602081 100644 (file)
@@ -18,7 +18,7 @@
        <script type="text/javascript" src="{@RELATIVE_WCF_DIR}acp/js/WCF.ACP.js"></script>
        <script type="text/javascript">
                //<![CDATA[
-               WCF.User.init({$__wcf->user->userID}, '{@$__wcf->user->username|encodejs}');
+               WCF.User.init({$__wcf->user->userID}, '{@$__wcf->user->username|encodeJS}');
                //]]>
        </script>
        
index 5a14c7f9df954073da65b7ced5c00a832ca8911e..219ef32c8a4cb5a68fb07f5e7575f1134bbdc6c3 100644 (file)
@@ -482,7 +482,7 @@ class TemplateEngine extends SingletonFactory {
         * @return      string                          class name
         */
        public function getPluginClassName($type, $tag) {
-               return $this->pluginNamespace.StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($tag)).StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)).'TemplatePlugin';
+               return $this->pluginNamespace.StringUtil::firstCharToUpperCase($tag).StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)).'TemplatePlugin';
        }
        
        /**
index b0ba8138e9d3ce8ef696fe50a77926c94a21783a..1e32b2f28334ef0e47d2e72c8a072b467c93da2f 100644 (file)
@@ -1093,7 +1093,7 @@ class TemplateScriptingCompiler {
                                                }
                                                
                                                // handle modifier name
-                                               $modifierData['name'] = StringUtil::toLowerCase($values[$i]);
+                                               $modifierData['name'] = $values[$i];
                                                $className = $this->template->getPluginClassName('modifier', $modifierData['name']);
                                                if (class_exists($className)) {
                                                        $modifierData['className'] = $className;
diff --git a/wcfsetup/install/files/lib/system/template/plugin/EncodeJSModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/EncodeJSModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..8a5b66e
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\util\StringUtil;
+
+/**
+ * The 'encodeJS' modifier formats a string for usage in a single quoted javascript string. 
+ * Escapes single quotes and new lines.
+ * 
+ * Usage:
+ * {$string|encodeJS}
+ * {"bl''ah"|encodeJS}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class EncodeJSModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // escape backslash
+               $tagArgs[0] = StringUtil::replace("\\", "\\\\", $tagArgs[0]);
+               
+               // escape singe quote
+               $tagArgs[0] = StringUtil::replace("'", "\'", $tagArgs[0]);
+               
+               // escape new lines
+               $tagArgs[0] = StringUtil::replace("\n", '\n', $tagArgs[0]);
+               
+               // escape slashes
+               $tagArgs[0] = StringUtil::replace("/", '\/', $tagArgs[0]);
+               
+               return $tagArgs[0];
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php
deleted file mode 100644 (file)
index eb517f2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\TemplateEngine;
-use wcf\util\StringUtil;
-
-/**
- * The 'encodejs' modifier formats a string for usage in a single quoted javascript string. 
- * Escapes single quotes and new lines.
- * 
- * Usage:
- * {$string|encodejs}
- * {"bl''ah"|encodejs}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class EncodejsModifierTemplatePlugin implements IModifierTemplatePlugin {
-       /**
-        * @see wcf\system\template\IModifierTemplatePlugin::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               // escape backslash
-               $tagArgs[0] = StringUtil::replace("\\", "\\\\", $tagArgs[0]);
-               
-               // escape singe quote
-               $tagArgs[0] = StringUtil::replace("'", "\'", $tagArgs[0]);
-               
-               // escape new lines
-               $tagArgs[0] = StringUtil::replace("\n", '\n', $tagArgs[0]);
-               
-               // escape slashes
-               $tagArgs[0] = StringUtil::replace("/", '\/', $tagArgs[0]);
-               
-               return $tagArgs[0];
-       }
-}