docs(API): 翻译完了 DomSanitizer

This commit is contained in:
Zhicheng Wang 2018-09-04 17:20:54 +08:00
parent 7e8b60ce31
commit 84f95e5864
2 changed files with 52 additions and 1 deletions

View File

@ -89,7 +89,7 @@
[x] | core/AfterViewInit | 0.18
[x] | forms/ReactiveFormsModule | 0.18
[x] | common/http/HTTP_INTERCEPTORS | 0.18
[ ] | platform-browser/DomSanitizer | 0.18
[x] | platform-browser/DomSanitizer | 0.18
[ ] | core/PipeTransform | 0.18
[ ] | core/SimpleChange | 0.18
[ ] | core/SimpleChanges | 0.18

View File

@ -18,6 +18,7 @@ export {SecurityContext};
* Marker interface for a value that's safe to use in a particular context.
*
*
*
*/
export interface SafeValue {}
@ -25,6 +26,7 @@ export interface SafeValue {}
* Marker interface for a value that's safe to use as HTML.
*
*
* HTML
*/
export interface SafeHtml extends SafeValue {}
@ -32,6 +34,7 @@ export interface SafeHtml extends SafeValue {}
* Marker interface for a value that's safe to use as style (CSS).
*
*
* CSS
*/
export interface SafeStyle extends SafeValue {}
@ -39,6 +42,7 @@ export interface SafeStyle extends SafeValue {}
* Marker interface for a value that's safe to use as JavaScript.
*
*
* JavaScript
*/
export interface SafeScript extends SafeValue {}
@ -46,6 +50,7 @@ export interface SafeScript extends SafeValue {}
* Marker interface for a value that's safe to use as a URL linking to a document.
*
*
* URL
*/
export interface SafeUrl extends SafeValue {}
@ -53,6 +58,7 @@ export interface SafeUrl extends SafeValue {}
* Marker interface for a value that's safe to use as a URL to load executable code from.
*
*
* URL
*/
export interface SafeResourceUrl extends SafeValue {}
@ -60,41 +66,65 @@ export interface SafeResourceUrl extends SafeValue {}
* DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
* values to be safe to use in the different DOM contexts.
*
* DomSanitizer DOM XSS
*
* For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
* sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
* the website.
*
* `<a [href]="someValue">` URL`someValue`
* `javascript:` URL
*
* In specific situations, it might be necessary to disable sanitization, for example if the
* application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
* Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
* methods, and then binding to that value from the template.
*
* `javascript:`
* 使 `bypassSecurityTrust...`
*
* These situations should be very rare, and extraordinary care must be taken to avoid creating a
* Cross Site Scripting (XSS) security bug!
*
* XSS
*
* When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
* close as possible to the source of the value, to make it easy to verify no security bug is
* created by its use.
*
* 使 `bypassSecurityTrust...` 便使
*
* It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
* does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
* code. The sanitizer leaves safe values intact.
*
* 使 URL HTML
*
*
* @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
* sanitization for the value passed in. Carefully check and audit all values and code paths going
* into this call. Make sure any user data is appropriately escaped for this security context.
* For more detail, see the [Security Guide](http://g.co/ng/security).
*
*
* `bypassSecurityTrust...` API Anuglar
*
* escape
* [](http://g.co/ng/security)。
*/
export abstract class DomSanitizer implements Sanitizer {
/**
* Sanitizes a value for use in the given SecurityContext.
*
* SecurityContext 使 `value`
*
* If value is trusted for the context, this method will unwrap the contained safe value and use
* it directly. Otherwise, value will be sanitized to be safe in the given context, for example
* by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
* is responsible to make sure that the value can definitely be safely used in the given context.
*
* 使 `javascript:` URL
* 使
*/
abstract sanitize(context: SecurityContext, value: SafeValue|string|null): string|null;
@ -103,24 +133,37 @@ export abstract class DomSanitizer implements Sanitizer {
* is unsafe (e.g. contains `<script>` tags) and the code should be executed. The sanitizer will
* leave safe HTML intact, so in most situations this method should not be used.
*
* HTML HTML `<script>`使
* HTML 使
*
* **WARNING:** calling this method with untrusted user data exposes your application to XSS
* security risks!
*
* **** 使 XSS
*/
abstract bypassSecurityTrustHtml(value: string): SafeHtml;
/**
* Bypass security and trust the given value to be safe style value (CSS).
*
* CSS
*
* **WARNING:** calling this method with untrusted user data exposes your application to XSS
* security risks!
*
* **** 使 XSS
*/
abstract bypassSecurityTrustStyle(value: string): SafeStyle;
/**
* Bypass security and trust the given value to be safe JavaScript.
*
* JavaScript
*
* **WARNING:** calling this method with untrusted user data exposes your application to XSS
* security risks!
*
* **** 使 XSS
*/
abstract bypassSecurityTrustScript(value: string): SafeScript;
@ -128,8 +171,12 @@ export abstract class DomSanitizer implements Sanitizer {
* Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used
* in hyperlinks or `<img src>`.
*
* URL `<img src>`
*
* **WARNING:** calling this method with untrusted user data exposes your application to XSS
* security risks!
*
* **** 使 XSS
*/
abstract bypassSecurityTrustUrl(value: string): SafeUrl;
@ -137,8 +184,12 @@ export abstract class DomSanitizer implements Sanitizer {
* Bypass security and trust the given value to be a safe resource URL, i.e. a location that may
* be used to load executable code from, like `<script src>`, or `<iframe src>`.
*
* URL `<script src>` `<iframe src>`
*
* **WARNING:** calling this method with untrusted user data exposes your application to XSS
* security risks!
*
* **** 使 XSS
*/
abstract bypassSecurityTrustResourceUrl(value: string): SafeResourceUrl;
}