Code

Opened 2 years ago

Closed 2 years ago

#17544 closed Bug (invalid)

PL localflavor field PLNIPfield allows improper values

Reported by: jbl1 Owned by: nobody
Component: contrib.localflavor Version: master
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 jbl1 2 years ago.
Patch for django/contrib/localflavor/pl/forms (#17544)
ticket17544.diff (1.1 KB) - added by jbl1 2 years ago.
Patch and regression test for #17544

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by jbl1

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

comment:1 Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 2 years ago by jbl1

Patch and regression test for #17544

comment:2 Changed 2 years ago by jbl1

  • Has patch unset
  • Needs tests unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

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.