From: Alexander Ebert Date: Thu, 28 Jul 2016 15:42:15 +0000 (+0200) Subject: Added link validation for quotes X-Git-Tag: 3.0.0_Beta_1~931 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8fb2f0f45fc4a2788f4696594b4d2788f5261afc;p=GitHub%2FWoltLab%2FWCF.git Added link validation for quotes --- diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index cd19fe024d..fd5ff2922e 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -79,6 +79,7 @@ 'wcf.editor.quote.title': '{lang __literal=true}wcf.editor.quote.title{/lang}', 'wcf.editor.quote.url': '{lang}wcf.editor.quote.url{/lang}', 'wcf.editor.quote.url.description': '{lang}wcf.editor.quote.url.description{/lang}', + 'wcf.editor.quote.url.error.invalid': '{lang}wcf.editor.quote.url.error.invalid{/lang}', 'wcf.editor.spoiler.label': '{lang}wcf.editor.spoiler.label{/lang}', 'wcf.editor.spoiler.label.description': '{lang}wcf.editor.spoiler.label.description{/lang}', diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Quote.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Quote.js index f1bdd6a270..b9871e66be 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Quote.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Quote.js @@ -173,10 +173,25 @@ define(['Core', 'EventHandler', 'EventKey', 'Language', 'StringUtil', 'Dom/Util' event.preventDefault(); var id = 'redactor-quote-' + this._elementId; + var urlInput = elById(id + '-url'); + var innerError = elBySel('.innerError', urlInput.parentNode); + if (innerError !== null) elRemove(innerError); - ['author', 'url'].forEach((function (attr) { - elData(this._blockquote, attr, elById(id + '-' + attr).value); - }).bind(this)); + var url = urlInput.value.replace(/\u200B/g, '').trim(); + // simple test to check if it at least looks like it could be a valid url + if (url.length && !/^https?:\/\/[^\/]+/.test(url)) { + innerError = elCreate('small'); + innerError.className = 'innerError'; + innerError.textContent = Language.get('wcf.editor.quote.url.error.invalid'); + urlInput.parentNode.insertBefore(innerError, urlInput.nextElementSibling); + return; + } + + // set author + elData(this._blockquote, 'author', elById(id + '-author').value); + + // set url + elData(this._blockquote, 'url', url); this._setTitle(this._blockquote); this._editor.caret.after(this._blockquote); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 94c29c12c0..9c56410197 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2281,6 +2281,7 @@ Fehler sind beispielsweise: + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 793d2b9276..5a4be539a9 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2258,6 +2258,7 @@ Errors are: +