Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Misleading concepts about sanitize in template syntax #3408

Open
trotyl opened this issue Mar 22, 2017 · 2 comments
Open

Misleading concepts about sanitize in template syntax #3408

trotyl opened this issue Mar 22, 2017 · 2 comments
Assignees

Comments

@trotyl
Copy link
Contributor

trotyl commented Mar 22, 2017

In the Content security part of Template Syntax chapter, there is the content:

<!--
  Angular generates warnings for these two lines as it sanitizes them
  WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).
 -->
<p><span>"{{evilTitle}}" is the <i>interpolated</i> evil title.</span></p>
<p>"<span [innerHTML]="evilTitle"></span>" is the <i>property bound</i> evil title.</p>

It says that, Angular will generate warnings for these two lines. However, it actually just generate warning for the second line, nothing for the first line, an example is here in http://embed.plnkr.co/kS1vNt2hT7KfOtlKT2Qu/ . (Technically that's not wrong, but misleading enough)

And for the first line, there's actually nothing about sanitize, it's just because Angular does not use a string-based template, the structure and data have been separated all the time. So the interpolation environment is not HTML-awareness, using HTML there will be same as using HTML in an iOS Label, it's the natural result to show the text as-is, without any pre-processing.

Since the interpolation context is not HTML-aware at design level (Angular is platform-agnostic), it's not accurate to say it sanitize the HTML in this condition.

@ghost
Copy link

ghost commented Apr 4, 2017

@trotyl , my head started spinning, whilst trying to understand this. May I ask: which action do you suggest?

@trotyl
Copy link
Contributor Author

trotyl commented Apr 4, 2017

@lazaridis-com At least remove:

Angular generates warnings for these two lines as it sanitizes them

as Angular won't generate warning for one of them, it's a fact, not an opinion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants