mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
修复<keyword>组件的安全问题
This commit is contained in:
@@ -13,7 +13,7 @@ Vue.component("keyword", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let slot = this.$slots["default"][0]
|
let slot = this.$slots["default"][0]
|
||||||
let text = slot.text
|
let text = this.encodeHTML(slot.text)
|
||||||
if (word.length > 0) {
|
if (word.length > 0) {
|
||||||
text = text.replace(new RegExp("(" + word + ")", "ig"), "<span style=\"border: 1px #ccc dashed; color: #ef4d58\">$1</span>")
|
text = text.replace(new RegExp("(" + word + ")", "ig"), "<span style=\"border: 1px #ccc dashed; color: #ef4d58\">$1</span>")
|
||||||
}
|
}
|
||||||
@@ -23,5 +23,13 @@ Vue.component("keyword", {
|
|||||||
text: text
|
text: text
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
encodeHTML: function (s) {
|
||||||
|
s = s.replace("&", "&")
|
||||||
|
s = s.replace("<", "<")
|
||||||
|
s = s.replace(">", ">")
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
},
|
||||||
template: `<span><span style="display: none"><slot></slot></span><span v-html="text"></span></span>`
|
template: `<span><span style="display: none"><slot></slot></span><span v-html="text"></span></span>`
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user