Docs/errors 5200 5201#69504
Open
arturovt wants to merge 2 commits into
Open
Conversation
Adds a reference page for `NG05200`, thrown by `DomSanitizer` when a value is bound to a `<script>` element without being marked trusted via `bypassSecurityTrustScript`. Covers why Angular rejects script content outright, how to reproduce the error, the escape hatch, and the XSS caveat.
Adds a reference page for `NG05201`, thrown by `DomSanitizer` when a value is bound to a resource-loading attribute (`<iframe src>`, `<link href>`, etc.) without being marked trusted via `bypassSecurityTrustResourceUrl`. Covers why Angular rejects resource URLs outright, lists all affected elements and attributes, and documents the escape hatch with its XSS caveat.
SkyZeroZx
reviewed
Jun 24, 2026
| export class Example { | ||
| safeScript: SafeScript; | ||
|
|
||
| constructor(sanitizer: DomSanitizer) { |
Contributor
There was a problem hiding this comment.
NIT :
Suggested change
| constructor(sanitizer: DomSanitizer) { | |
| constructor( ) { | |
| const sanitizer = inject(DomSanitizer); | |
| } |
SkyZeroZx
reviewed
Jun 24, 2026
| Look for a template binding that targets a `<script>` element: | ||
|
|
||
| ```html | ||
| <script [innerHTML]="myScript"></script> |
Contributor
There was a problem hiding this comment.
This is not a good example; the Angular Compiler removes script when writing it directly in the template.
SkyZeroZx
reviewed
Jun 24, 2026
| @@ -0,0 +1,36 @@ | |||
| # Unsafe value used in a script context | |||
Contributor
There was a problem hiding this comment.
I have some doubts about whether we should document this. As far as I understand and know, it's not currently possible to pass JavaScript directly, at least within the script tag, so I don't think it would apply, given that the use of createComponent was also recently restricted.
See
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See individual commits.