Opened 12 years ago

Closed 12 years ago

#17544 closed Bug (invalid)

PL localflavor field PLNIPfield allows improper values

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

Description

One such value is "1112025170":

>>> from django.contrib.localflavor.pl import forms
>>> form = forms.PLNIPField()
>>> bool(form.has_valid_checksum("1112025170"))
True

whereas it is not a valid NIP (tax id number) as the checksum for it is equal 10. All such numbers are not valid formally.

Attaching the simplest possible patch.

Attachments (2)

forms.patch (417 bytes ) - added by Jerzy Ludwichowski 12 years ago.
Patch for django/contrib/localflavor/pl/forms (#17544)
ticket17544.diff (1.1 KB ) - added by Jerzy Ludwichowski 12 years ago.
Patch and regression test for #17544

Download all attachments as: .zip

Change History (4)

by Jerzy Ludwichowski, 12 years ago

Attachment: forms.patch added

Patch for django/contrib/localflavor/pl/forms (#17544)

comment:1 by Claude Paroz, 12 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Thanks for reporting. Please could you improve your patch with a test? See changeset:17346 for tips to how the test should be written.

by Jerzy Ludwichowski, 12 years ago

Attachment: ticket17544.diff added

Patch and regression test for #17544

comment:2 by Jerzy Ludwichowski, 12 years ago

Has patch: unset
Needs tests: unset
Resolution: invalid
Status: newclosed

I am sorry. The validation is correct: NIP numbers with checksum = 10 are properly recognized as invalid. My example in the initial report has the checksum = 0 which is correct. Sorry for the noise. NB the prompt for a test case made me realize my error -- many thanks.

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