From b939bc7ca8d189af19efad90d38ff49479964ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:41:30 +0100 Subject: [PATCH] Check GET parameters in image embedding This is a great candidate for the tests! --- js/plugins.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 4230365..d5f1bc4 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -251,8 +251,14 @@ plugins.factory('userPlugins', function() { */ var imagePlugin = new Plugin( urlPlugin(function(url) { - if (url.match(/\.(png|gif|jpg|jpeg)$/i)) { - + var embed = false; + // Check the get parameters as well, they might contain an image to load + var segments = url.split(/[?&]/).forEach(function(param) { + if (param.match(/\.(png|gif|jpg|jpeg)$/i)) { + embed = true; + } + }); + if (embed) { /* A fukung.net URL may end by an image extension but is not a direct link. */ if (url.indexOf("^https?://fukung.net/v/") != -1) { url = url.replace(/.*\//, "http://media.fukung.net/imgs/");