Skip to content

Reject under-length codes in SedolCheckDigit - #435

Merged
garydgregory merged 1 commit into
apache:masterfrom
sahvx655-wq:sedol-under-length
Aug 26, 2026
Merged

Reject under-length codes in SedolCheckDigit#435
garydgregory merged 1 commit into
apache:masterfrom
sahvx655-wq:sedol-under-length

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

SedolCheckDigit.SEDOL_CHECK_DIGIT.isValid is a public CheckDigit entry point with no wrapping validator, yet its calculateModulus override only rejects codes longer than the seven-character weight table. A shorter string whose weighted digits happen to sum to a multiple of ten therefore validates: isValid("55"), isValid("550"), isValid("5500") and isValid("0055") all return true, though a SEDOL is defined as exactly seven characters. I traced it back from the weight loop after noticing the base-class isValid does no length check of its own, so this one-sided > comparison is the only thing standing between a short input and a false positive.

The guard now also requires the validated form (the code passed with its check digit) to be exactly seven characters, while the calculate path still receives the six-character base and so keeps only the over-length check. Holding the length rule inside calculateModulus, next to the weight table it depends on, keeps the validate and calculate callers consistent without either repeating it. Left as it was, a caller relying on SEDOL_CHECK_DIGIT to screen out malformed identifiers would accept a two-character string as a valid security identifier.

isValid only rejected over-length codes, so a short string with a chance
modulus 10 check digit validated. Require the validated seven-character
form exactly; the calculate path keeps the base-length handling.
@garydgregory garydgregory changed the title reject under-length codes in SedolCheckDigit Reject under-length codes in SedolCheckDigit Aug 26, 2026
@garydgregory
garydgregory merged commit 1f1b6a2 into apache:master Aug 26, 2026
10 checks passed
@garydgregory

Copy link
Copy Markdown
Member

Thank you @sahvx655-wq , merged 🚀
What does the spec about lengths of 6 and below? How do we do there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants