Search Results for

    Show / Hide Table of Contents

    Class HeaderSanitizer

    Provides a helper to remove sensitive or dangerous data from message headers. This is particularly useful before logging or persisting headers.

    Inheritance
    object
    HeaderSanitizer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Chapar.Core.Utilities
    Assembly: Chapar.Core.dll
    Syntax
    public static class HeaderSanitizer

    Fields

    | Edit this page View Source

    DangerousChars

    Declaration
    public static readonly char[] DangerousChars
    Field Value
    Type Description
    char[]

    Methods

    | Edit this page View Source

    Sanitize(IDictionary<string, object?>?, IEnumerable<string>?, IEnumerable<string>?)

    Sanitizes a dictionary of headers by:

    1. Replacing the value of any key in the built‑in set of sensitive headers set with "[REDACTED]".
    2. Removing carriage return, line feed, and null characters from all header values.
    3. Optionally restricting headers to a pre‑defined set of allowed keys.

    The original dictionary is not modified.

    Declaration
    public static IDictionary<string, object?> Sanitize(IDictionary<string, object?>? headers, IEnumerable<string>? additionalSensitiveKeys = null, IEnumerable<string>? allowedKeys = null)
    Parameters
    Type Name Description
    IDictionary<string, object> headers

    The headers to sanitize. Can be null.

    IEnumerable<string> additionalSensitiveKeys

    Additional sensitive keys to redact (on top of the built‑in set).

    IEnumerable<string> allowedKeys

    If provided, only headers whose keys are in this set will be included in the result. If null or empty, all non‑redacted headers are kept.

    Returns
    Type Description
    IDictionary<string, object>

    A new, safe dictionary. Never returns null.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2026