Class LogSafe

java.lang.Object
com.scroogexhtml.converter.LogSafe

public final class LogSafe extends Object
Makes a value from the RTF input safe to put into a log message.

A value with CR / LF would split the log line, so that the rest of it shows up as a separate, attacker-chosen entry on line-oriented log sinks (log forging); other control characters can carry terminal escape sequences. escape(String) writes them as visible escapes, escapes the backslash itself so the result stays unambiguous, and truncates long values.

  • Field Details

    • MAX_LOGGED

      public static final int MAX_LOGGED
      Maximum number of characters of the value that are logged.
      See Also:
  • Method Details

    • escape

      public static String escape(String value)
      Parameters:
      value - a value from the RTF input, or null
      Returns:
      the value, truncated to MAX_LOGGED characters, with \ as \\, CR / LF / TAB as \r / \n / \t, and every other control character (C0, DEL, C1) and the Unicode line / paragraph separators as \uXXXX