Opened 7 years ago

Closed 5 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:

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 7 years ago.

Download all attachments as: .zip

Change History (8)

Changed 7 years ago by amz

Attachment: plnipfield.patch added

comment:1 Changed 7 years ago by Alex Gaynor

milestone: 1.0.3
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Not a 1.0.3 ticket.

comment:2 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by anonymous

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

comment:4 Changed 6 years ago by anonymous

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

comment:5 in reply to:  4 Changed 6 years ago by Łukasz Rekucki

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 Changed 5 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:7 Changed 5 years ago by Claude Paroz

Easy pickings: unset
Resolution: fixed
Status: newclosed

Apparently fixed by changeset:14949

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