Company register number: the first two letters of anything typed are taken for a country and split off #636
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#636
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, running register numbers as registers print them throughjobs.identifiers.clean.Checked again on 2026-10-01 against
mainat0a5cad587: still present.A register number typed without its country code is not refused. Its first two letters are split off as if they were the country, and the altered value is saved with no message.
Where:
plugins/identifiers/schemes.py:87-92(_country_then_number) andplugins/identifiers/schemes.py:205-214(theregisterscheme and its pattern).What happens:
_country_then_numberinserts a space after the first two characters whenever they are letters and the third is not a space:It is meant for
PT501234567, and it does the same to any value that starts with a word. The pattern,^[A-Z]{2} [A-Z0-9][A-Z0-9 .\-/]{1,38}$, then accepts the result, because it asks only for two capital letters, a space and more characters; the two letters are not checked against any list of countries. Run against the snapshot:HRB 12345HR B 12345SIRET 552 081 317 00013SI RET 552 081 317 00013NIF 501234567NI F 501234567KVK 12345678KV K 12345678Companies House 01234567CO MPANIES HOUSE 01234567XX 12andZZ-99are accepted asXX 12andZZ 99. A bare number such as501234567is refused with the example, as intended.Why it matters: a German number typed as it is printed is stored as one that reads as Croatian, and the person is not told. Identifiers are how two records are recognised as the same employer, so a value stored under the wrong prefix does not match the same number entered correctly elsewhere. The module's docstring says these are validated "beyond a country prefix" only; here the prefix itself is invented.
Fix: split only when the two letters are directly followed by a digit, or by
-or:(thePT501234567andPT-501234567cases), and leave anything else as typed so that the pattern refuses it with the example (DE HRB 12345). Check that the first two letters are a code in the country table (phones.COUNTRIES, or an ISO 3166-1 list kept with the plugin), with a message of its own ("Start with the country's two-letter code").Done when
tests/test_identifier_registry.py:HRB 12345is refused with the example,DE HRB 12345,PT501234567andPT-501234567are kept asDE HRB 12345andPT 501234567, andXX 12is refused. The first and the last fail today.