Link protocol was not preserved on insert/edit
authorAlexander Ebert <ebert@woltlab.com>
Sat, 10 Mar 2018 22:06:40 +0000 (23:06 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 10 Mar 2018 22:06:40 +0000 (23:06 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabLink.js

index 074a7be799ad180f4d35b79184da8d6d904840c7..9fe94fdd51cdce54bb37bd8abc4c6c2d5e580ff9 100644 (file)
@@ -33,6 +33,21 @@ $.Redactor.prototype.WoltLabLink = function() {
                        
                        this.link.show = this.WoltLabLink.show.bind(this);
                        
+                       var mpParse = this.link.parse;
+                       this.link.parse = (function(link) {
+                               var isHttps = false;
+                               if (link.url.match(/^(https:)?\/\//)) {
+                                       isHttps = true;
+                               }
+                               
+                               link = mpParse.call(this, link);
+                               
+                               // the link validation assumes http:// regardless of the previously set value
+                               if (isHttps) link.url = link.url.replace(/^http:/, 'https:');
+                               
+                               return link;
+                       }).bind(this);
+                       
                        require(['WoltLabSuite/Core/Ui/Redactor/Link'], function(UiRedactorLink) {
                                _dialogApi = UiRedactorLink;
                        });