Skip to content

Commit 23a76ec

Browse files
authored
Merge pull request #17 from kwangsooshin/feature/escape-html
Fix: escape the HTML entity
2 parents c94d07e + 354670f commit 23a76ec

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

log_viewer/templates/log_viewer/logfile_viewer.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ <h1 class="pull-left">{% if custom_file_list_title %}{{ custom_file_list_title }
6060
</div>
6161

6262
<script>
63+
var entityMap = {
64+
'&': '&amp;',
65+
'<': '&lt;',
66+
'>': '&gt;',
67+
'"': '&quot;',
68+
"'": '&#39;',
69+
'/': '&#x2F;',
70+
'`': '&#x60;',
71+
'=': '&#x3D;'
72+
};
73+
function escapeHtml (string) {
74+
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
75+
return entityMap[s];
76+
});
77+
}
78+
6379
function loadDataTable(table_name, url_json) {
6480
$(table_name).DataTable({
6581
pageLength: {{ page_length }},
@@ -73,7 +89,8 @@ <h1 class="pull-left">{% if custom_file_list_title %}{{ custom_file_list_title }
7389
var next_page = response.next_page || 1;
7490

7591
response.logs.forEach(function(text, numb, logs){
76-
new_logs.push([numb+1, text])
92+
text = escapeHtml(text);
93+
new_logs.push([numb+1, text]);
7794
});
7895

7996
callback({

0 commit comments

Comments
 (0)