Ticket #3018: patch-db-models-fields-filefield.patch

File patch-db-models-fields-filefield.patch, 850 bytes (added by ido, 18 years ago)

patch for ticket #3018

  • __init__.py

     
    584584
    585585        # If the raw path is passed in, validate it's under the MEDIA_ROOT.
    586586        def isWithinMediaRoot(field_data, all_data):
    587             f = os.path.abspath(os.path.join(settings.MEDIA_ROOT, field_data))
    588             if not f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))):
     587            f = os.path.abspath(os.path.join(self.upload_to or settings.MEDIA_ROOT, field_data))
     588            if not f.startswith(os.path.abspath(os.path.normpath(self.upload_to or settings.MEDIA_ROOT))):
    589589                raise validators.ValidationError, _("Enter a valid filename.")
    590590        field_list[1].validator_list.append(isWithinMediaRoot)
    591591        return field_list
Back to Top