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:


PLNIPField from [source:django/trunk/django/contrib/localflavor/pl/] 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/ 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

comment:1 Changed 7 years ago by Alex

  • milestone 1.0.3 deleted
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Not a 1.0.3 ticket.

comment:2 Changed 7 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

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 follow-up: Changed 5 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 5 years ago by lrekucki

  • 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

  • Severity set to Normal
  • Type set to Bug

comment:7 Changed 5 years ago by claudep

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed

Apparently fixed by changeset:14949

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