Ignore:
Timestamp:
2 Feb 2013, 16:53:16 (12 years ago)
Author:
Henrik Bettermann
Message:

Temporary solution to prevent users from uploading non-ascii files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r9857 r9930  
    10381038                return
    10391039            target = os.path.join(self.context.storage, normalized_filename)
    1040             open(target, 'wb').write(uploadfile.read())
     1040            filecontent = uploadfile.read()
     1041
     1042            # XXX: temporary solution to prevent users from
     1043            # uploading non-ascii files.
     1044            for element in filecontent:
     1045                try:
     1046                    if ord(element) > 128:
     1047                      self.flash(_(
     1048                          "Only ASCII files are allowed. "
     1049                          "Your file contains non-ascii characters."))
     1050                      return
     1051                except TypeError:
     1052                    self.flash(_(
     1053                        "Only ASCII files are allowed. "
     1054                        "Your file contains non-ASCII characters."))
     1055                    return
     1056
     1057            open(target, 'wb').write(filecontent)
    10411058            os.chmod(target, 0664)
    10421059            logger = self.context.logger
Note: See TracChangeset for help on using the changeset viewer.