mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00
Fix some minor issues in escape documentation.
This commit is contained in:
parent
1b18bab91b
commit
40b6f348d9
@ -59,11 +59,14 @@ where
|
|||||||
Ok(MarkupDisplay::new_safe(v, e))
|
Ok(MarkupDisplay::new_safe(v, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Escapes `&`, `<` and `>` in strings
|
/// Escapes strings according to the escape mode.
|
||||||
///
|
///
|
||||||
/// Askama will automatically insert the first (`Escaper`) argument,
|
/// Askama will automatically insert the first (`Escaper`) argument,
|
||||||
/// so this filter only takes a single argument of any type that implements
|
/// so this filter only takes a single argument of any type that implements
|
||||||
/// `Display`.
|
/// `Display`.
|
||||||
|
///
|
||||||
|
/// It is possible to optionally specify an escaper other than the default for
|
||||||
|
/// the template's extension, like `{{ val|escape("txt") }}`.
|
||||||
pub fn escape<E, T>(e: E, v: T) -> Result<MarkupDisplay<E, T>>
|
pub fn escape<E, T>(e: E, v: T) -> Result<MarkupDisplay<E, T>>
|
||||||
where
|
where
|
||||||
E: Escaper,
|
E: Escaper,
|
||||||
|
@ -155,12 +155,12 @@ or `xml`. When specifying a template as `source` in an attribute, the
|
|||||||
you can specify an escape mode explicitly for your template by setting
|
you can specify an escape mode explicitly for your template by setting
|
||||||
the `escape` attribute parameter value (to `none` or `html`).
|
the `escape` attribute parameter value (to `none` or `html`).
|
||||||
|
|
||||||
Askama escapes `<`, `>`, `&`, `"`, `'`, `\` and `/`, according to the
|
Askama escapes `<`, `>`, `&`, `"`, and `'`, according to the
|
||||||
[OWASP escaping recommendations][owasp]. Use the `safe` filter to
|
[OWASP escaping recommendations][owasp]. Use the `safe` filter to
|
||||||
prevent escaping for a single expression, or the `escape` (or `e`)
|
prevent escaping for a single expression, or the `escape` (or `e`)
|
||||||
filter to escape a single expression in an unescaped context.
|
filter to escape a single expression in an unescaped context.
|
||||||
|
|
||||||
[owasp]: https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
|
[owasp]: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#output-encoding-for-html-contexts
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user