Remove disallowed characters from potential filename. Currently only guaranteed on Linux and
    OS X.

def sanitize(filename: str, platform: str=None) -> str:
    """
    Remove disallowed characters from potential filename. Currently only guaranteed on Linux and
    OS X.
    """
    win_map = {
        # taken from samba Catia module.
        # https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html
        "\"": "¨",
        "*": "¤",
        "/": "ÿ",
        ":": "÷",
        "<": "«",
        ">": "»",
        "?": "¿",
        "\\": "ÿ",
        "|": "¦",
    }

    posix_map = {
        "/": "-",
    }

    if platform is None:
        platform = sys.platform

    if platform.startswith("win32"):
        replace_map = win_map
    else:
        replace_map = posix_map

    for key, entry in replace_map.items():
        filename = filename.replace(key, entry)

    return filename