def safe_format(fmt, **kwargs):
    """
    Function that safely formats strings with arbitrary potentially user-supplied format strings
    Looks for interpolation placeholders like {target} or {{ target }}
    """
    # TODO: CTFd 4.0 - This function should probably be renamed to `safe_text_format`
    return re.sub(
        r"\{?\{([^{}]*)\}\}?", lambda m: kwargs.get(m.group(1).strip(), m.group(0)), fmt
    )

    Function that safely formats strings with arbitrary potentially user-supplied format strings
    Looks for interpolation placeholders like {target} or {{ target }}
    
CTFd/utils/formatters/__init__.py