lint errors blocking 做了一些研究但没有成功

lint errors blocking did some research but not successful

(no-inner-html) app/components/sports.ts[717, 9]:使用 html() 函数将字符串写入 innerHTML 是不安全的:$( '.tubing').html(health.title)

if (health.title == "waterS") {
      let that = this;
      let recordPlayersWeight = {};
      this.futureParrot = [];
      this.pastParrot = [];
      this.peacockService.getResponse(health.url, 'get', null)
        .subscribe(recordPlayersWeight => {
            this.gridData = recordPlayersWeight.waterDtos;
            that._recordPlayersWeightSource.recordPlayersWeight(this.gridData);
          },
          err => {
          }
        );
    }

    that.window = $("#TigerwatersPopup");
    that.window.kendoWindow({
      width: "60%",
      title: false,
      visible: false,
      resizable: false,
      actions: [],
      draggable: false,
      modal: true,
      open: function() {
        $("html, body").css("overflow", "hidden");
        that.isVisible = true;
        $('.tubing').html(health.title);

当您使用 jQuery 的 .html() 功能时,可能会不小心将 "unsafe" 元素添加到您的页面,例如 iframe 标记或源标记。如果您添加的 html 是由恶意用户提交的(例如,作为查询的一部分或在表单中输入的数据),您就是在给他们攻击您的机会。这是一种代码注入攻击(参见 https://en.wikipedia.org/wiki/Code_injection)。

在你的情况下,你似乎只是想将纯文本放入 .tubing 元素中,所以这样做更安全

$('.tubing').text( health.title );

它的作用是 "escapes" 任何 HTML 特殊字符,如 <>,以便它们显示为文本而不是被视为元素。这是安全的,可以防止攻击者注入代码,并且不会触发 lint 规则。