I was wrong, html escape filter is appended even if an html escape filter is already there.
This commit is contained in:
parent
e22bffd2ba
commit
f3fef17d4b
@ -4,5 +4,5 @@ HTML Escaping
|
||||
Dust automatically applies the `|h` filter to html escape unless `|s` is applied to disable automatic html escaping. It seems that if you manually specify `|h` and `|s` in the same filter, then it still html escapes, so my theory on the logic is:
|
||||
|
||||
Iterate over all filters
|
||||
If `|s` or `|h` is not present append `|h`, otherwise, leave filters as-in
|
||||
If `|s` is not present append `|h`, otherwise, leave filters as-in
|
||||
During render, `|s` does nothing, so we can just remove it on the dust side to prevent confusion.
|
||||
|
@ -2,6 +2,7 @@ Special characters: {special_characters}{~n}
|
||||
Special characters html escaping disabled: {special_characters|s}{~n}
|
||||
Special characters html escaping disabled and enabled: {special_characters|s|h}{~n}
|
||||
Special characters html escaping enabled and disabled: {special_characters|h|s}{~n}
|
||||
Special characters html escaped once: {special_characters|h}{~n}
|
||||
Special characters html escaped twice: {special_characters|h|h}{~n}
|
||||
|
||||
|
||||
|
@ -510,10 +510,7 @@ impl<'a> DustRenderer<'a> {
|
||||
|
||||
// If the user has not specified any escaping filter (|s or
|
||||
// |h), automatically add an html escape filter
|
||||
if !filters
|
||||
.iter()
|
||||
.any(|f| f == &Filter::DisableHtmlEncode || f == &Filter::HtmlEncode)
|
||||
{
|
||||
if !filters.iter().any(|f| f == &Filter::DisableHtmlEncode) {
|
||||
final_filters.push(Filter::HtmlEncode);
|
||||
}
|
||||
final_filters
|
||||
|
Loading…
x
Reference in New Issue
Block a user