Reject over-length codes in ISSNCheckDigit#426
Merged
Conversation
Member
|
@sahvx655-wq |
Member
|
Thank you @sahvx655-wq , merged 🚀 Please check for other length issues in this package. |
garydgregory
added a commit
that referenced
this pull request
Jul 17, 2026
Contributor
Author
|
Will do. From a quick look the mirror form exists in the rightPos-weighted routines: ISBN10CheckDigit and ABANumberCheckDigit have no length check either, and there a prepended zero is the character that lands on a no-op weight, so a leading-zero-padded code keeps the same sum. I'll work through the package and put up fixes for the ones reachable outside their wrapper validators. Thanks for merging this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed while exercising the check digit routines directly rather than through their wrapper validators.
ISSNCheckDigit.ISSN_CHECK_DIGIT.isValidis a public entry point andModulusCheckDigitnever checks the code length, so an over-length string reaches the modulus test unchecked.weightedValueweights each position by9 - leftPos, so a ninth character lands on weight zero and contributes nothing; appending any character to a valid numeric ISSN (031784710..031784719,0317847100) still returns true, though only the eight-character03178471is a real ISSN.isValidto require the fixed eight-character length before the check digit test, the same shape as the existingIBANCheckDigitlength guard; theISSNValidator/CodeValidatorpath already enforces length, so valid input is unaffected.Regression test
testOverLengthRejectedadded, which fails on the current code and passes with the guard.