-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filters: proper escaping for |linebreaks
and friends
#77
filters: proper escaping for |linebreaks
and friends
#77
Conversation
Fix copy-and-paste mishap.
The generator often takes references to the values it wants to display. A bare `(Maybe)Safe<T>` won't likely be encountered.
@@ -254,8 +254,7 @@ fn filter_block_include() { | |||
{% endif -%} | |||
{% endfilter -%} | |||
"#, | |||
ext = "html", | |||
print = "code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woups. :-.
@@ -311,9 +311,6 @@ const BUILT_IN_FILTERS: &[&str] = &[ | |||
"into_f64", | |||
"into_isize", | |||
"join", | |||
"linebreaks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it still a function in generator.rs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yes, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sorted the list while re-adding the items. Looks nicer this way. :)
The filters `|linebreaks`, `|linebreaksbr` and `|paragraphbreaks` generate HTML code to be embedded in a page. Having to specify that the output of these filters is `|safe` is cumbersome. Also, these filters need to operate on already escaped HTML data. This could be done by writing `{{ s|escape|linebreaks|safe }}`. This PR does the input and output formatting escaping for the user. The input gets escaped for HTML (invariant of the selected escaper), and the output gets marked as HTML safe.
cd54624
to
5163e38
Compare
"urlencode_strict", | ||
"urlencode", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You failed the sorting for this one. ;)
(0 is smaller than _
hehe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say the same all the time! But somehow the sort function in VS code, geany, etc. always give precedence to the longer word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wut. Oh well.
Looks all good to me, thanks! |
And thank your for preventing me from introducing an bug in the built-in filters list! :D |
Sometimes my reviews are useful. :) |
The filters
|linebreaks
,|linebreaksbr
and|paragraphbreaks
generate HTML code to be embedded in a page. Having to specify that the output of these filters is|safe
is cumbersome. Also, these filters need to operate on already escaped HTML data. This could be done by writing{{ s|escape|linebreaks|safe }}
.This PR does the input and output formatting escaping for the user. The input gets escaped for HTML (invariant of the selected escaper), and the output gets marked as HTML safe.
Resolves #74.