diff --git a/lib/map/labellayer.js b/lib/map/labellayer.js index a32ce9c2e55681955576b1faa0192cb4ed20ecf5..63ff62e6f1600bc1315dfcfc78d6aed98bef6093 100644 --- a/lib/map/labellayer.js +++ b/lib/map/labellayer.js @@ -87,7 +87,7 @@ define(['leaflet', 'rbush', 'helper', 'moment'], m.on('click', function () { router.fullUrl({ node: d.node_id }); }); - m.bindTooltip(d.hostname); + m.bindTooltip(helper.escape(d.hostname)); dict[d.node_id] = m; @@ -114,7 +114,7 @@ define(['leaflet', 'rbush', 'helper', 'moment'], line.setStyle(opts); }; - line.bindTooltip(d.source.hostname + ' – ' + d.target.hostname + + line.bindTooltip(helper.escape(d.source.hostname + ' – ' + d.target.hostname) + '<br><strong>' + helper.showDistance(d) + ' / ' + helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq) + '<br>' + d.type + '</strong>'); line.on('click', function () { diff --git a/lib/utils/helper.js b/lib/utils/helper.js index 429f4eb0830bffc82c69351c324b62e365968f29..41f7b1cf73aa73c8bdd1b2fce4d257a6bac71a80 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -196,5 +196,11 @@ define({ btn.classList.add('ion-full-enter'); } } + }, + escape: function escape(string) { + return string.replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); } });