Vue sanitize a href url

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

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

  1. import { sanitizeUrl } from "@braintree/sanitize-url"
  2. Vue.prototype.$sanitize = sanitizeUrl

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

  1. data: () => ({
  2. sanitizeUrl: null
  3. }),
  4. created() {
  5. // BEFORE SANITIZE : "https://codepen.io/"
  6. // AFTER SANITIZED : "https://codepen.io/"
  7. this.sanitizeUrl = this.$sanitize(this.obj.info.url)
  8. }
  1. <a
  2. :href="sanitizeUrl"
  3. target="_blank"
  4. rel="noreferrer noopener nofollow"
  5. />

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

92vpleto

92vpleto1#

用这个帮我清除bug

  1. :href="sanitizeUrl ? sanitizeUrl : ''"

字符串

相关问题