~ubuntu-branches/ubuntu/oneiric/moin/oneiric-security

« back to all changes in this revision

Viewing changes to MoinMoin/action/Load.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-03-30 12:55:34 UTC
  • mfrom: (0.1.17 sid)
  • Revision ID: james.westby@ubuntu.com-20100330125534-4c2ufc1rok24447l
Tags: 1.9.2-2ubuntu1
* Merge from Debian testing (LP: #521834). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason for us
   to pull this in by default currently. Note: This isn't necessary anymore
   but needs a MIR for fckeditor, so postpone dropping this change until
   lucid+1
* debian/rules:
  - Replace hardcoded python2.5 with python* and hardcore python2.6 for ln
* debian/control.in: drop versioned depends on cdbs

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        if not TextCha(request).check_answer_from_form():
42
42
            return status, _('TextCha: Wrong answer! Go back and try again...')
43
43
 
44
 
        comment = form.get('comment', [u''])[0]
 
44
        comment = form.get('comment', u'')
45
45
        comment = wikiutil.clean_input(comment)
46
46
 
47
 
        filename = form.get('file__filename__')
48
 
        rename = form.get('rename', [''])[0].strip()
 
47
        file_upload = request.files.get('file')
 
48
        if not file_upload:
 
49
            # This might happen when trying to upload file names
 
50
            # with non-ascii characters on Safari.
 
51
            return False, _("No file content. Delete non ASCII characters from the file name and try again.")
 
52
 
 
53
        filename = file_upload.filename
 
54
        rename = form.get('rename', '').strip()
49
55
        if rename:
50
56
            target = rename
51
57
        else:
52
58
            target = filename
53
59
 
54
 
        target = AttachFile.preprocess_filename(target)
55
60
        target = wikiutil.clean_input(target)
56
61
 
57
62
        if target:
58
 
            filecontent = form['file'][0]
59
 
            if hasattr(filecontent, 'read'): # a file-like object
60
 
                filecontent = filecontent.read() # XXX reads complete file into memory!
 
63
            filecontent = file_upload.stream.read() # XXX reads complete file into memory!
61
64
            filecontent = wikiutil.decodeUnknownInput(filecontent)
62
65
 
63
66
            self.pagename = target
107
110
                     "If the page name is empty, we derive the page name from the file name."),
108
111
    'upload_label_file': _('File to load page content from'),
109
112
    'upload_label_comment': _('Comment'),
110
 
    'upload_label_rename': _('Page Name'),
 
113
    'upload_label_rename': _('Page name'),
111
114
    'pagename': self.pagename,
112
115
    'buttons_html': buttons_html,
113
116
    'action_name': self.form_trigger,