Ui/Sparklines: Remove img src before putting it into DOM

SVG chart was fetched although we removed image tags
from DOM. This happens when text is converted into
browser DOM model to use with javascript. Small
regex remove img source attribute to avoid using
network bandwidth for unknown resources.

fixes #6124
This commit is contained in:
Marius Hein 2014-06-06 13:52:45 +02:00
parent 140f307e0a
commit a75796c64d
2 changed files with 17 additions and 1 deletions

View File

@ -269,7 +269,7 @@
if (this.processRedirectHeader(req)) return;
// div helps getting an XML tree
var $resp = $('<div>' + req.responseText + '</div>');
var $resp = $('<div>' + icinga.ui.removeImageSourceFromSparklines(req.responseText) + '</div>');
var active = false;
var rendered = false;
var classes;

View File

@ -657,6 +657,22 @@
);
},
/**
* Find all svg charts and removes src attributes for sparklines
*
* @param {string} text
* @returns {string}
*/
removeImageSourceFromSparklines: function(text) {
var match, sourceMatch;
var re = new RegExp(/(src=".+chart.php[^"]+")/g);
var reSource = new RegExp(/src="([^"]+)"/);
while ((match = re.exec(text))) {
text = text.replace(match[0], '');
}
return text;
},
initializeControls: function (parent) {
var self = this;