@maschinenlesbar.org/oparl-cli
    Preparing search index...

    Function sanitizeServerText

    • Make a string that originates in an attacker-controlled response body safe to put into an error message printed raw to stderr by run.ts — an error detail snippet, an object type, a link, a Content-Type. Three things happen:

      • Control characters are dropped (all C0/C1 plus DEL). Without this, a hostile or spoofed server could drive ANSI/OSC escape sequences (display spoofing, terminal title changes) into the user's terminal.
      • Every run of whitespace — newlines and Unicode line separators included — becomes a single space, so the result is one line and a server cannot forge a second Error: line of its own next to ours.
      • The result is capped at maxLength characters, so a 3 KB "message" cannot bury the diagnostic the CLI printed.

      Every server-supplied string that reaches a message goes through here. The CLI's JSON output is escaped separately (escapeControlChars in cli/shared.ts): JSON.stringify alone leaves DEL and the C1 range raw.

      Written as a char-code filter so no raw control byte ever appears in this source.

      Parameters

      • text: string
      • maxLength: number = MAX_SERVER_TEXT_LENGTH

      Returns string