Class HtmlEscapeUtils

java.lang.Object
org.a2aproject.sdk.util.HtmlEscapeUtils

public final class HtmlEscapeUtils extends Object
Utilities for removing HTML escaping applied by Gson's JsonWriter when htmlSafe is enabled (the default).
  • Method Details

    • removeHtmlEscaping

      public static String removeHtmlEscaping(String json)
      Removes HTML escaping applied by Gson's JsonWriter when htmlSafe is enabled (the default). Restores literal <, >, &, =, and '.

      Both lowercase (<) and uppercase (<) hex digits are handled, as the JSON specification permits either case for unicode escapes.

      Gson also escapes U+2028 (line separator) and U+2029 (paragraph separator) in HTML-safe mode, but those are left as-is because they are valid JSON encodings that preserve the original characters without data corruption.

      Parameters:
      json - the JSON string potentially containing HTML-escaped sequences
      Returns:
      the JSON string with literal characters restored