import re


def munge_filename(name, mode='strict'):
    """Remove characters that might not be safe in a filename."""
    if mode == 'strict':
        non_alphabetic = re.compile('[^A-Za-z0-9_.]')
    else:
        non_alphabetic = re.compile('[^A-Za-z0-9_\\-.=,:]')
    return non_alphabetic.sub('_', name)