Fixed handling of HTML code in i18n input fields
authorAlexander Ebert <ebert@woltlab.com>
Wed, 12 Jun 2013 12:41:00 +0000 (14:41 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 12 Jun 2013 12:41:00 +0000 (14:41 +0200)
wcfsetup/install/files/js/WCF.js

index 99c5278017d1d378b0d9e0ab5f2d1727ed8ecaf5..3e50c118a444a6400530b18c5dab0b37ec584ca3 100755 (executable)
@@ -3108,6 +3108,13 @@ WCF.MultipleLanguageInput = Class.extend({
                this._values = values;
                this._availableLanguages = availableLanguages;
                
+               // unescape values
+               if ($.getLength(this._values)) {
+                       for (var $key in this._values) {
+                               this._values[$key] = WCF.String.unescapeHTML(this._values[$key]);
+                       }
+               }
+               
                // default to current user language
                this._languageID = LANGUAGE_ID;
                if (this._element.length == 0) {
@@ -3328,7 +3335,7 @@ WCF.MultipleLanguageInput = Class.extend({
                                this._values[$languageID] = '';
                        }
                        
-                       $('<input type="hidden" name="' + $elementID + '_i18n[' + $languageID + ']" value="' + this._values[$languageID] + '" />').appendTo($form);
+                       $('<input type="hidden" name="' + $elementID + '_i18n[' + $languageID + ']" value="' + WCF.String.escapeHTML(this._values[$languageID]) + '" />').appendTo($form);
                }
                
                // remove name attribute to prevent conflict with i18n values
@@ -3424,6 +3431,16 @@ WCF.String = {
         */
        ucfirst: function(string) {
                return String(string).substring(0, 1).toUpperCase() + string.substring(1);
+       },
+       
+       /**
+        * Unescapes special HTML-characters within a string
+        * 
+        * @param       string          string
+        * @return      string
+        */
+       unescapeHTML: function (string) {
+               return String(string).replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
        }
 };