Skip to content

Commit 0331473

Browse files
PaloMiklopkozlowski-opensource
authored andcommitted
docs(platform-browser): Sanitize method has more explicit documentation (#48765)
PR Close #48765
1 parent 84ad4d0 commit 0331473

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/platform-browser/src/security/dom_sanitization_service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ export interface SafeResourceUrl extends SafeValue {}
8989
@Injectable({providedIn: 'root', useExisting: forwardRef(() => DomSanitizerImpl)})
9090
export abstract class DomSanitizer implements Sanitizer {
9191
/**
92-
* Sanitizes a value for use in the given SecurityContext.
92+
* Gets a safe value from either a known safe value or a value with unknown safety.
9393
*
94-
* If value is trusted for the context, this method will unwrap the contained safe value and use
95-
* it directly. Otherwise, value will be sanitized to be safe in the given context, for example
96-
* by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
97-
* is responsible to make sure that the value can definitely be safely used in the given context.
94+
* If the given value is already a `SafeValue`, this method returns the unwrapped value.
95+
* If the security context is HTML and the given value is a plain string, this method
96+
* sanitizes the string, removing any potentially unsafe content.
97+
* For any other security context, this method throws an error if provided
98+
* with a plain string.
9899
*/
99100
abstract sanitize(context: SecurityContext, value: SafeValue|string|null): string|null;
100101

0 commit comments

Comments
 (0)