Repository navigation
Strip all whitespace from a pasted card number or ISBN [patch] - #477
Merged
Merged
Conversation
CreditCardNumber and Isbn removed only the ASCII space and `-`, so a valid value carrying a trailing newline, a tab or a non-breaking space was rejected, while Iban in the same package already stripped every char.IsWhiteSpace character. Both now go through one shared IdentifierCanonicalization helper so the two cannot drift apart again, and the README table and XML docs say "whitespace". Fixes #476 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VhcNHmVUqSbyA94vJQRrc5
|
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.



Fixes #476
What changed
CreditCardNumberandIsbnstripped only the ASCII space and-. A valid value with a trailing newline, a tab or a non-breaking space was therefore rejected withArgumentException, even thoughIbanin the same package already strips everychar.IsWhiteSpacecharacter (#311).IdentifierCanonicalization.StripWhitespaceAndHyphensis now the single place that decides what a separator is. Both types call it, so they can't drift apart again.Ibankeeps its own loop because it doesn't strip hyphens.Ibanrow, which said "spaces", is corrected as well.Tests
CreditCardNumberTests.Create_WithWhitespace_StripsItAndValidatesandIsbnTests.Create_WithWhitespace_StripsItAndValidatescover\n,\r\n, tab, NBSP, and mixed leading/trailing whitespace. The ISBN cases include a lowercasexcheck digit.mainand pass with the change. I checked this by reverting the two source files and re-running.dotnet teston net10.0: 1793 passed, 12 skipped, 0 failed. The net8/net9 legs can't run here because those runtimes aren't installed; CI covers them.dotnet build Semantics.Strings.Identifierswith.sonarlint/sonar-local.props: 0 warnings, 0 errors.Generated by Claude Code