【问题标题】:Security Error with <object> tag in angular application角度应用程序中带有 <object> 标记的安全错误
【发布时间】:2017-07-27 11:55:23
【问题描述】:

我正在添加带有标签的新 HMTL 页面。

<object *ngIf='displayUrl' resize-to-tile type="text/html" 
        [attr.data]="displayUrl" >
</object>



  this.displayUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.parameters.items.data.params.items[0].value);

但我有下一个错误:

SafeValue 必须使用 [property]=binding: undefined(请参阅 http://g.co/ng/security#xss) SafeValue 必须使用 [property]=binding: 未定义(见http://g.co/ng/security#xss

我该如何解决?

【问题讨论】:

    标签: javascript angular security object typescript


    【解决方案1】:

    删除attr.

    [data]="displayUrl" >
    

    bypassSecurityXxx 返回的值被封装在一个类中。
    属性绑定只支持字符串值,因此[attr.xxx] 会破坏清理。

    &lt;object&gt; 元素有一个data 属性,因此attr. 无论如何都不是必需的https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement

    【讨论】:

      猜你喜欢
      • 2014-05-08
      • 2018-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 1970-01-01
      • 2020-08-25
      • 2021-10-12
      相关资源
      最近更新 更多