【问题标题】:Use of bypassSecurityTrustResourceUrl is giving SafeValue must use [property] in result使用 bypassSecurityTrustResourceUrl 给 SafeValue must use [property] in result
【发布时间】:2021-04-08 06:14:31
【问题描述】:

我正在尝试使用 bypassSecurityTrustResourceUrl 解析图像,但在输出中我得到了

SafeValue must use [property]=binding: data:image/jpeg;base64,(actual data) (see http://g.co/ng/security#xss)

如下图所示

这是我的代码

  loadImages(): void {
    this.projectsDetailService.getById(this.param_id).
    subscribe((data: any) => {
      console.log("Step 1")
      this.projectList = data;
      for (var index in this.projectList) {
        this.images = this.projectList[index].img;
        this.objectURL = 'data:image/jpeg;base64,' + this.images;
        this.thumbnail1 = this.sanitizer.bypassSecurityTrustResourceUrl(this.objectURL);
        this.projectList[index].img = this.thumbnail1;
        console.log("Data is "+this.thumbnail1);

      }
       
      
      }
       );
      }
 

即使我想在 html 文件中使用它,我也会收到以下错误

【问题讨论】:

    标签: angular image-processing angular-dom-sanitizer


    【解决方案1】:

    正如错误描述中提到的,你必须使用属性绑定的方式来摆脱这个错误。在此处查看 Günter Zöchbauer 的确切解决方案。 Safe value must use [property]=binding after bypass security with DomSanitizer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 2018-04-13
      • 2018-07-06
      • 2022-12-17
      相关资源
      最近更新 更多