Trac is being migrated to new services! Issues can be found in our new YouTrack instance and WIKI pages can be found on our website.

LocalTracChanges: attachment_filename_restrict.patch

File attachment_filename_restrict.patch, 542 bytes (added by datallah, 15 years ago)

Hack to restrict filenames so that they don't need to be URL-escaped

  • trac/attachment.py

    old new  
    572572                                                        'utf-8'))
    573573        filename = filename.replace('\\', '/').replace(':', '/')
    574574        filename = os.path.basename(filename)
     575        p = re.compile("[^0-9a-zA-Z.,\-_]")
     576        filename = p.sub('_', filename)
    575577        if not filename:
    576578            raise TracError(_('No file uploaded'))
    577579        # Now the filename is known, update the attachment resource
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!