Opened 15 years ago

Closed 13 years ago

#11577 closed Bug (fixed)

PLNIPField validation error when empty

Reported by: amz Owned by: nobody
Component: contrib.localflavor Version: 1.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

PLNIPField from [source:django/trunk/django/contrib/localflavor/pl/forms.py] doesn't validate when not required:

Exception Type:	IndexError
Exception Value:	string index out of range
Exception Location:	/usr/lib/python2.5/site-packages/django/contrib/localflavor/pl/forms.py in has_valid_checksum, line 96

Re create:

class Client(models.Model):
    name = models.CharField(max_length=200, blank=True)
    nip = models.CharField(max_length=13, blank=True)

class ClientForm(forms.ModelForm):
    nip = PLNIPField(required=False)

Suggestion: Don't validate if submited date is empty (patch attached)


Attachments (1)

plnipfield.patch (727 bytes ) - added by amz 15 years ago.

Download all attachments as: .zip

Change History (8)

by amz, 15 years ago

Attachment: plnipfield.patch added

comment:1 by Alex Gaynor, 15 years ago

milestone: 1.0.3

Not a 1.0.3 ticket.

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by anonymous, 14 years ago

This ticket is sitting for over a year, maybe it will be good to accept it? ;)

comment:4 by anonymous, 14 years ago

Ding dong, someone is really (try to) using it. Can you accept this ticket?

in reply to:  4 comment:5 by Łukasz Rekucki, 14 years ago

Needs tests: set
Patch needs improvement: set

Replying to anonymous:

Ding dong, someone is really (try to) using it. Can you accept this ticket?

It is accepted, but not ready for inclusion. First, it needs tests. Second, it doesn't fix the problem entirely. A string like "---" will pass the length check, then get stripped and an empty string will be passed to has_checksum_valid.

comment:6 by Julien Phalip, 13 years ago

Severity: Normal
Type: Bug

comment:7 by Claude Paroz, 13 years ago

Easy pickings: unset
Resolution: fixed
Status: newclosed

Apparently fixed by changeset:14949

Note: See TracTickets for help on using tickets.
Back to Top