def _safe_filename(filename):
    """
    Sanitize output filenames, to remove any potentially unsafe characters.
    """
    filename = os.path.basename(filename)

    keepcharacters = (" ", ".", "_", "-")
    filename = (
        "".join(char for char in filename if char.isalnum() or char in keepcharacters)
        .strip()
        .strip(".")
    )

    return filename

    Sanitize output filenames, to remove any potentially unsafe characters.
    
apistar/client/decoders.py