Browse Source

Prevent possible xss

sbkwgh 6 năm trước cách đây
mục cha
commit
6dc486f082
1 tập tin đã thay đổi với 2 bổ sung4 xóa
  1. 2 4
      frontend/src/main.js

+ 2 - 4
frontend/src/main.js

@@ -157,10 +157,8 @@ Vue.filter('formatDate', function (value, format = '', join = ' ') {
 });
 
 Vue.filter('stripTags', function (value) {
-	let div = document.createElement('div')
-	div.innerHTML = value
-
-	return div.textContent
+	let doc = new DOMParser().parseFromString(value, 'text/html')
+	return doc.body.textContent || ''
 });
 
 Vue.filter('truncate', function (value, length) {