Fixed displayed error messages
authorAlexander Ebert <ebert@woltlab.com>
Tue, 15 Aug 2017 15:34:51 +0000 (17:34 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 15 Aug 2017 15:34:51 +0000 (17:34 +0200)
wcfsetup/install/files/js/WCF.Message.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/Reply.js
wcfsetup/install/files/lib/system/exception/ValidateActionException.class.php

index 148a853856c6da2f4378eb5b9fdfb1bd54271d56..53427a76ed967c3df41fbdb25349b54be9734072 100644 (file)
@@ -497,7 +497,9 @@ if (COMPILER_TARGET_DEFAULT) {
                                $innerError = $('<small class="innerError" />').appendTo(this._textarea.parent());
                        }
                        
-                       $innerError.html((data.returnValues.errorType === 'empty' ? WCF.Language.get('wcf.global.form.error.empty') : data.returnValues.errorMessage));
+                       var message = (data.returnValues.errorType === 'empty' ? WCF.Language.get('wcf.global.form.error.empty') : data.returnValues.errorMessage);
+                       if (data.returnValues.realErrorMessage) message = data.returnValues.realErrorMessage;
+                       $innerError.html(message);
                        
                        return false;
                }
index 45ba8725d2075127c2e288a86c22b22953b18807..b8f6dc738c48c166f40d1af7669bf50923310271 100644 (file)
@@ -696,7 +696,7 @@ define(
                        this._restoreEditor();
                        
                        //noinspection JSUnresolvedVariable
-                       if (!data || data.returnValues === undefined || data.returnValues.errorType === undefined) {
+                       if (!data || data.returnValues === undefined || data.returnValues.realErrorMessage === undefined) {
                                return true;
                        }
                        
@@ -709,7 +709,7 @@ define(
                        }
                        
                        //noinspection JSUnresolvedVariable
-                       innerError.textContent = data.returnValues.errorType;
+                       innerError.textContent = data.returnValues.realErrorMessage;
                        
                        return false;
                },
index 272f1e8b940c285085212e1c1d78751be3d38d6b..959ec965cbd6e43d8ecd1c6bf7410e7a70713631 100644 (file)
@@ -283,7 +283,7 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Dom/ChangeListener', 'Dom/U
                 */
                _handleError: function(data) {
                        //noinspection JSUnresolvedVariable
-                       this.throwError(this._textarea, data.returnValues.errorType);
+                       this.throwError(this._textarea, data.returnValues.realErrorMessage);
                },
                
                /**
@@ -397,7 +397,7 @@ define(['Ajax', 'Core', 'EventHandler', 'Language', 'Dom/ChangeListener', 'Dom/U
                        this._hideLoadingOverlay();
                        
                        //noinspection JSUnresolvedVariable
-                       if (data === null || data.returnValues === undefined || data.returnValues.errorType === undefined) {
+                       if (data === null || data.returnValues === undefined || data.returnValues.realErrorMessage === undefined) {
                                return true;
                        }
                        
index a3492182fcf2aef6b550963ff0edc089162bfbca..bd61d92cb0c96731cb2c7e10f80f820cf9669101 100644 (file)
@@ -29,7 +29,9 @@ class ValidateActionException extends \Exception {
        public function __construct($fieldName, $errorMessage = 'empty', array $variables = []) {
                $this->errorMessage = $errorMessage;
                if (mb_strpos($this->errorMessage, '.') === false) {
-                       $this->errorMessage = WCF::getLanguage()->get('wcf.global.form.error.'.$this->errorMessage);
+                       if (preg_match('~^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$~', $this->errorMessage)) {
+                               $this->errorMessage = WCF::getLanguage()->get('wcf.global.form.error.'.$this->errorMessage);
+                       }
                }
                else {
                        $this->errorMessage = WCF::getLanguage()->getDynamicVariable($this->errorMessage, $variables);