Vue sanitize a href url

r7xajy2e  于 2023-11-21  发布在  Vue.js
关注(0)|答案(1)|浏览(127)

所以伙计们,我有一个问题,比如Make sure bypassing Vue built-in sanitization is safe here.在vue js中有一个href URL,这个URL是我从我的API中获得的,然后我试图使用@braintree/sanitize-url进行清理,然后像这样将它放在我的Vue.prototype.$sanitize

import { sanitizeUrl } from "@braintree/sanitize-url"

Vue.prototype.$sanitize = sanitizeUrl

字符串
然后我把它用在我的组件上,

data: () => ({
  sanitizeUrl: null
}),
created() {
  // BEFORE SANITIZE : "https://codepen.io/"
  // AFTER SANITIZED : "https://codepen.io/"

  this.sanitizeUrl = this.$sanitize(this.obj.info.url)
}
<a
  :href="sanitizeUrl"
  target="_blank"
  rel="noreferrer noopener nofollow"
/>

的数据
一切都很好,但声纳云仍然检测到这个URL还没有像Make sure bypassing Vue built-in sanitization is safe here.一样被清理
我如何从我的API中清理这个URL?谢谢大家

92vpleto

92vpleto1#

用这个帮我清除bug

:href="sanitizeUrl ? sanitizeUrl : ''"

字符串

相关问题