Escapes special HTML characters in a string to their corresponding HTML entities.
This prevents HTML injection by replacing characters like <, >, &, ", and '
with their safe HTML entity equivalents, so the string can be safely inserted into HTML
without being interpreted as markup.
Parameters
html: string
The input string that may contain HTML special characters.
Escapes special HTML characters in a string to their corresponding HTML entities.
This prevents HTML injection by replacing characters like
<
,>
,&
,"
, and'
with their safe HTML entity equivalents, so the string can be safely inserted into HTML without being interpreted as markup.