mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
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:
parent
140f307e0a
commit
a75796c64d
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user