I'm running Rails 4.2.x and I have the following problem.
The <title>
of some pages are generated from user content. So I have to use the sanitize
Rails helpers to properly clean it up.
But if the user writes something like "A & B", the title shown in browser is A & B
which is wrong.
What's the correct way of escaping user content on the <title>
tag using Rails? At least some special characters should be included...
<%= title.html_safe %>
should help. And see api.rubyonrails.org/classes/ActionView/Helpers/… - devanandsanitize
works great when we inject user input in the middle of the HTML. However in this case, the<title>
tag is sensitive to HTML entities, so I don't want some of them to be escaped. - rubenfonsecastrip_tags
in that case. or did I misunderstood? - devanand