Sorry for my silly question.
When I print out something as HTTP response to the client, the content
which has special chars included shch as < and > has been resolved as
HTML tags. How to escape these special chars automatically?
Thanks
Sorry for my silly question.
When I print out something as HTTP response to the client, the content
which has special chars included shch as < and > has been resolved as
HTML tags. How to escape these special chars automatically?
Thanks
Higher-level frameworks can offer more, but there is a basic html_escape method in Ruby's CGI module:
CGI.escapeHTML('Usage: foo "bar" <baz>')
# => "Usage: foo "bar" <baz>"
https://docs.ruby-lang.org/en/3.0/CGI/Util.html#method-i-escapeHTML
Rails ActiveSupport:
https://api.rubyonrails.org/classes/ERB/Util.html#method-i-html_escape
Hanami:
https://www.rubydoc.info/gems/hanami-utils/Hanami%2FUtils%2FEscape.html
On April 21, 2022 2:17:09 PM UTC, alice@coakmail.com wrote:
When I print out something as HTTP response to the client, the content
which has special chars included shch as < and > has been resolved as
HTML tags. How to escape these special chars automatically?