Skip to content

Commit 72420ff

Browse files
authored
Bugfix: DOM text reinterpreted as HTM
1 parent a7949ce commit 72420ff

File tree

1 file changed

+15
-3
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-hdinsight/hdinsight_jobview_html/com.microsoft.hdinsight/hdinsight/job/html/js

1 file changed

+15
-3
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-hdinsight/hdinsight_jobview_html/com.microsoft.hdinsight/hdinsight/job/html/js/tipsy.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
// released under the MIT license
55

66
(function($) {
7-
7+
function escapeHtml(text) {
8+
return text.replace(/[&<>"']/g, function(match) {
9+
const escapeMap = {
10+
'&': '&amp;',
11+
'<': '&lt;',
12+
'>': '&gt;',
13+
'"': '&quot;',
14+
"'": '&#39;'
15+
};
16+
return escapeMap[match];
17+
});
18+
}
19+
820
function maybeCall(thing, ctx) {
921
return (typeof thing == 'function') ? (thing.call(ctx)) : thing;
1022
}
@@ -115,7 +127,7 @@
115127
}
116128
if (typeof $e.context.nearestViewportElement == 'object'){
117129
if ($e.children('title').length){
118-
$e.append('<original-title>' + ($e.children('title').text() || '') + '</original-title>')
130+
$e.append('<original-title>' + escapeHtml($e.children('title').text() || '') + '</original-title>')
119131
.children('title').remove();
120132
}
121133
}
@@ -285,4 +297,4 @@
285297
return dir.ns + (dir.ew ? dir.ew : '');
286298
};
287299
};
288-
})(jQuery);
300+
})(jQuery);

0 commit comments

Comments
 (0)