当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript DomSanitizer.sanitize方法代码示例

本文整理汇总了TypeScript中@angular/platform-browser.DomSanitizer.sanitize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DomSanitizer.sanitize方法的具体用法?TypeScript DomSanitizer.sanitize怎么用?TypeScript DomSanitizer.sanitize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/platform-browser.DomSanitizer的用法示例。


在下文中一共展示了DomSanitizer.sanitize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: serviceError

  serviceError(json: any) {
    const message = this.satinizer.sanitize(SecurityContext.HTML, json.message);
    const code = this.satinizer.sanitize(SecurityContext.HTML, json.code);

    const html = this.satinizer.bypassSecurityTrustHtml(`
      <div class="sn-title">Error</div>
      <div class="sn-content">
        ${message} </br>Code: ${code}
      </div>
  `);
    return this.html(html, 'error');
  }
开发者ID:sergiocosus,项目名称:ventamatic.frontend,代码行数:12,代码来源:notify.service.ts

示例2: transform

	transform(value: any, context?: SecurityContext | string | String) {
		if (!value) {
			return value;
		}
		if (typeof context === "undefined") {
			context = SecurityContext.HTML;
		}
		if (context instanceof String) {
			context = context.toString();
		}
		if (typeof context === "string" || context instanceof String) {
			context = SecurityContext[context.replace("-", "_").toUpperCase()];
		}
		switch (context) {
			case SecurityContext.HTML:
				return this.domSanitizer.bypassSecurityTrustHtml(value);
			case SecurityContext.RESOURCE_URL:
				return this.domSanitizer.bypassSecurityTrustResourceUrl(value);
			case SecurityContext.SCRIPT:
				return this.domSanitizer.bypassSecurityTrustScript(value);
			case SecurityContext.STYLE:
				return this.domSanitizer.bypassSecurityTrustStyle(value);
			case SecurityContext.URL:
				return this.domSanitizer.bypassSecurityTrustUrl(value);
		}
		return this.domSanitizer.sanitize(context as SecurityContext, value);
	}
开发者ID:nibo-ai,项目名称:nit-pipes,代码行数:27,代码来源:safe.pipe.ts

示例3:

 this.settings.getCustomPage().subscribe(x => {
     x.html = this.sanitizer.sanitize(SecurityContext.HTML, this.sanitizer.bypassSecurityTrustHtml(x.html));
     this.form = this.fb.group({
         enabled: [x.enabled],
         title: [x.title, [Validators.required]],
         html: [x.html, [Validators.required]],
         fontAwesomeIcon: [x.fontAwesomeIcon, [Validators.required]],
     });
 });
开发者ID:tidusjar,项目名称:PlexRequests.Net,代码行数:9,代码来源:custompage.component.ts

示例4: it

    it('should sanitize when markedOptions.sanitize is true and no sanitizer function is provided', () => {

      const markedOptions: MarkedOptions = { sanitize: true };
      const mockRaw = '### Markdown-x';
      const sanitized = domSanitizer.sanitize(SecurityContext.HTML, parse(mockRaw));
      const unsanitized = parse(mockRaw);

      expect(markdownService.compile(mockRaw, false, markedOptions)).toBe(sanitized);
      expect(markdownService.compile(mockRaw, false, markedOptions)).not.toBe(unsanitized);
    });
开发者ID:joebell1329,项目名称:ngx-markdown,代码行数:10,代码来源:markdown.service.spec.ts

示例5: transform

	transform(value: any, context?: SecurityContext | string | String) {
		if (!value) {
			return value;
		}
		if (typeof context === "undefined") {
			context = SecurityContext.HTML;
		}
		if (context instanceof String) {
			context = context.toString();
		}
		if (typeof context === "string" || context instanceof String) {
			context = SecurityContext[context.replace("-", "_").toUpperCase()];
		}
		return this.domSanitizer.sanitize(context as SecurityContext, value);
	}
开发者ID:nibo-ai,项目名称:nit-pipes,代码行数:15,代码来源:sanitize.pipe.ts

示例6: prompt

 get prompt() {
   const state = this.getPlugState();
   // Run this when a new prompt is set.
   if (this.lastPromptId !== state.id) {
     this.lastPromptId = state.id;
     const safeHtml =
         this.sanitizer.sanitize(SecurityContext.HTML, state.message)
             .replace(/&#10;/g, '<br>');  // Convert newlines.
     this.lastPromptHtml = this.sanitizer.bypassSecurityTrustHtml(safeHtml);
     this.focusSelf();
     if (state.default) {
       this.setResponse(state.default);
     }
   }
   return this.lastPromptHtml;
 }
开发者ID:kdsudac,项目名称:openhtf,代码行数:16,代码来源:user-input-plug.component.ts

示例7: _readBalance

  private _readBalance(data, from, json, self){
    var label = "", type;

    var start = data.indexOf('class="balance"', from);
    if (start < 0) return;
    var end = data.indexOf('</table>', start);
    if (end < 0) return;
    var tablehtml = data.substring(start, end);

    var html = '<table>' + tablehtml.substring(tablehtml.indexOf('>')+1).replace(/\n/g,"") + '</table>';
    var doc = document.implementation.createHTMLDocument("");
    //doc.body.innerHTML = this.sanitizer.bypassSecurityTrustHtml(html);
    doc.body.innerHTML = this.sanitizer.sanitize(SecurityContext.HTML, html).toString();
    [].forEach.call(doc.querySelectorAll('thead tr th:first-of-type'), function(el) {
      label = self._clean(el.innerHTML);
    });

    if (label.indexOf('nternet') > 0) type = "mb";
    if (label.indexOf('essages') > 0) type = "texts";
    if (label.indexOf('inutes') > 0) type = "mins";
    if (label.indexOf('redit') > 0) type = "credit";

    json[type] = {"label": label, "headings":[], "rows":[], "total":""};

    var index=0;
    [].forEach.call(doc.querySelectorAll('tbody tr th'), function(el) {
      json[type].headings[index] = self._clean(el.innerHTML);
      index++;
    });
    [].forEach.call(doc.querySelectorAll('tbody tr'), function(row) {
      var values = [];
      var index=0;
      [].forEach.call(row.querySelectorAll('td'), function(el) {
        values[index] = self._clean(el.innerHTML);
        index++;
      });
      if (values && values[0]) {
        if (values[0].indexOf('otal') > 0) json[type].total = values[2];
        else json[type].rows.push(values);
      }
    });

    self._readBalance(data, end+1, json, self);
  }
开发者ID:barshociaj,项目名称:ThreeBalance,代码行数:44,代码来源:threews.ts

示例8: transform

 transform(html: string) : SafeHtml {
   return this.sanitizer.sanitize(SecurityContext.HTML, html);
 }
开发者ID:tageler,项目名称:tageler-web,代码行数:3,代码来源:sanitizeHTML.pipe.ts

示例9: transform

 transform(value) {
     return this.sanitizer.sanitize(SecurityContext.NONE, value);
 }
开发者ID:strongbox,项目名称:strongbox-web-ui,代码行数:3,代码来源:code-snippet.pipe.ts

示例10: it

 it('should store the captcha on getting new captcha', () => {
   imageCaptchaService.getCaptcha.and.returnValue(of({ image: '<svg>captcha</svg>' }))
   component.getNewCaptcha()
   const sanitezedCaptcha = domSanitizer.sanitize(SecurityContext.HTML, component.captcha)
   expect(sanitezedCaptcha).toBe('<svg>captcha</svg>')
 })
开发者ID:bkimminich,项目名称:juice-shop,代码行数:6,代码来源:data-export.component.spec.ts


注:本文中的@angular/platform-browser.DomSanitizer.sanitize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。