Merge branch 'hotfix_1109_晒单列表防js注入攻击' into dev5.2
Showing
2 changed files
with
21 additions
and
2 deletions
@@ -115,7 +115,9 @@ var g = new common.grid({ | @@ -115,7 +115,9 @@ var g = new common.grid({ | ||
115 | } | 115 | } |
116 | }, { | 116 | }, { |
117 | display: '评价内容', | 117 | display: '评价内容', |
118 | - name: "content", | 118 | + render: function (item) { |
119 | + return encodeHtml(item.content); | ||
120 | + }, | ||
119 | style: "width:15%; word-break:break-all;" | 121 | style: "width:15%; word-break:break-all;" |
120 | } | 122 | } |
121 | , { | 123 | , { |
@@ -319,3 +321,20 @@ $('#batch-audit-fail').on('click', function () { | @@ -319,3 +321,20 @@ $('#batch-audit-fail').on('click', function () { | ||
319 | Bll.toast('批量审核不通过?', 'fail'); | 321 | Bll.toast('批量审核不通过?', 'fail'); |
320 | }); | 322 | }); |
321 | 323 | ||
324 | +// 对字符串中的特殊字符进行编码处理,防止js注入,形如 <script>alert(document.cookie)</script> | ||
325 | +function encodeHtml(str, reg) { | ||
326 | + return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g, function(a, b) { | ||
327 | + if (b) { | ||
328 | + return a; | ||
329 | + } else { | ||
330 | + return { | ||
331 | + '<': '<', | ||
332 | + '&': '&', | ||
333 | + '"': '"', | ||
334 | + '>': '>', | ||
335 | + "'": ''' | ||
336 | + }[a] | ||
337 | + } | ||
338 | + | ||
339 | + }) : ''; | ||
340 | +} |
-
Please register or login to post a comment