Escape HTML

Escape HTML special characters to prevent XSS attacks and ensure safe rendering.

Code

Utilities
require 'cgi'
return CGI.escapeHTML(str)

Parameters

The string containing HTML to escape.

Server

More Ruby Snippets