Repository navigation
[patch] Anchor IBAN, UUID and ULID patterns at the true end, and strip all whitespace from an IBAN - #405
Merged
Conversation
…p all whitespace from an IBAN In .NET, $ also matches before a final "\n", so [IsIban], [IsUuid] and [IsUlid] accepted a value with a trailing newline. Iban only stripped spaces, so the newline reached the mod-97 check as if it were a letter: "GB67WEST12345698765432\n" (wrong check digits) validated, and the valid "GB82WEST12345698765432\n" was rejected as a checksum failure. The patterns now end in \z, and Iban strips every whitespace character, as its documentation says it does. Fixes #311 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Co2rZq6e7TjwF2FMUzNoXu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Co2rZq6e7TjwF2FMUzNoXu
|
This was referenced Oct 9, 2026
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 #311
What was wrong
$withoutRegexOptions.Multilinealso matches just before a final\n.[IsIban],[IsUuid]and[IsUlid]all ended their patterns with$, so a value with a trailing newline passed the structural check.Iban.MakeCanonicalstripped only' ', so a newline reachedPassesMod97and was scored as a letter ('\n' - 'A' + 10). As a result,GB67WEST12345698765432\n, which has the wrong check digits, validated, while the validGB82WEST12345698765432\nwas rejected as "mod-97 checksum failed".Change (
Semantics.Strings.Identifiers)IsIbanAttribute,IsUuidAttribute,IsUlidAttribute: patterns now end in\zinstead of$.Iban.MakeCanonicalstrips everychar.IsWhiteSpacecharacter (spaces, tabs, CR/LF, NBSP) and uppercases. That's what the type's summary and the identifiers spec already said it did.Semantics.*projects for$-anchored validation patterns, as the triage suggested. These three were the only ones.Tests
IbanTests.Create_InvalidChecksumWithTrailingNewline_Throws:GB67…\nandGB67…\r\nare rejected.IbanTests.Create_ValidIbanWithWhitespace_StripsItAndValidates: trailing\nand\t, a leading tab with trailing CRLF, the spaced form plus\n, and NBSP separators all canonicalize toGB82WEST12345698765432.UuidTests/UlidTests: a private type that applies[IsUuid]/[IsUlid]without trimming rejects a trailing\n, and still accepts the bare value.\r\nrows already passed and are kept as guards. With the fix, the fullSemantics.Testsuite passes: 1491 passed, 0 failed, 8 skipped.Semantics.Strings.Identifiersbuilds for every target framework with no warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01Co2rZq6e7TjwF2FMUzNoXu
Generated by Claude Code