Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7673 closed (fixed)

ImageField validation problem

Reported by: lucalenardi Owned by: jacob
Component: Forms Version: master
Severity: Keywords: 2070-fix
Cc: boobsd@…, justin.driscoll@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

form.cleaned_data[image_field].read() seems to be empty when validating with custom validation using newforms.

...
if hasattr(data, 'temporary_file_path'):
    file = data.temporary_file_path()
else:
    if hasattr(data, 'read'):
        file = StringIO(data.read())
    else:
        file = StringIO(data['content'])
...

data.read() in the clean() method of ImageField becomes empty after the first read making the file unreadable in next custom validation.

Attachments (1)

newforms_imagefix.diff (522 bytes) - added by axiak 6 years ago.
Fix for this...thanks apollo13!

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by lucalenardi

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

With custom validation, I mean implementing the clean_fieldname() method in a form using newforms.

comment:2 Changed 6 years ago by anonymous

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by Boo

  • Cc boobsd@… added

comment:4 Changed 6 years ago by axiak

  • Has patch set
  • Keywords 2070-fix added
  • Owner changed from anonymous to axiak
  • Status changed from assigned to new
  • Triage Stage changed from Accepted to Ready for checkin

Uploading a patch to fix this.

Changed 6 years ago by axiak

Fix for this...thanks apollo13!

comment:5 Changed 6 years ago by jacob

  • Owner changed from axiak to jacob
  • Status changed from new to assigned

comment:6 Changed 6 years ago by anonymous

  • Cc justin.driscoll@… added

comment:7 Changed 6 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7907]) Fixed #7673: make sure to rewind uploaded image data when validating ImageFields. Thanks, Mike Axiak.

comment:8 Changed 3 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.