From 42d814656a56146666413b96c045553f331eae67 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 3 Aug 2014 22:34:30 +0200 Subject: [PATCH] Added protection against unsupported URLs --- public_html/media/js/post-upload.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public_html/media/js/post-upload.js b/public_html/media/js/post-upload.js index 767d0977..b9e2c562 100644 --- a/public_html/media/js/post-upload.js +++ b/public_html/media/js/post-upload.js @@ -57,6 +57,18 @@ function bindUrlHandlerEvents() url = url.replace(/^\s+|\s+$/, ''); if (url == '') return; + protocol = /^(\w+):\/\//.exec(url) + if (!protocol) + url = 'http://' + url; + else + { + protocol = protocol[1].toLowerCase(); + if (protocol != 'http' && protocol != 'https') + { + alert('Unsupported protocol: ' + protocol); + return; + } + } $('#url-handler-wrapper input').val(''); addURLs([url]); });