encodeReviewJsonForHtml function

String encodeReviewJsonForHtml(
  1. Object? value
)

Encodes value as JSON safe for embedding inside an HTML <script> tag.

Escapes </ as <\/ and <!-- as \u003c!-- so untrusted or arbitrary titles, URLs, or metadata can never break out of <script>.

Implementation

String encodeReviewJsonForHtml(Object? value) =>
    jsonEncode(value).replaceAll('</', r'<\/').replaceAll('<!--', r'\u003c!--');