escapeHtml function

String escapeHtml(
  1. String input
)

Escapes HTML special characters in the input string.

Implementation

String escapeHtml(String input) {
  return input
      .replaceAll('&', 'and')
      .replaceAll('<', '&lt;')
      .replaceAll('>', '&gt;')
      .replaceAll('"', '&quot;')
      .replaceAll("'", '&#39;');
}