Normalize line endings in one pass, so Mac keeps every break - #141
Merged
Merged
Conversation
NormalizeLineEndings(Mac) first turned each CRLF into CR, which left an LF that followed a CRLF directly after the new CR. The LF pass skips an LF preceded by CR, so "a\r\n\nb" came out as "a\r\nb": a line break was lost and the Mac output held a Windows ending. Every style now replaces \r\n, \r or \n in a single regex pass, so no intermediate string can form a new sequence. The results for inputs that did not hit the bug are unchanged. Fixes #137 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LasidbyRZfyxgW8Z9wQu9M
SonarCloud flags a Regex built without a timeout (S6444), which failed the quality gate on its security rating. The pattern is a plain alternation that cannot backtrack, so one second is far more than any match needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LasidbyRZfyxgW8Z9wQu9M
|
This was referenced Sep 28, 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 #137
What changed
NormalizeLineEndings(Mac)ran two regex passes. The first turned each CRLF into CR. That left any LF that came right after a CRLF sitting directly after the new CR. The second pass's(?<!\r)\nlookbehind then skipped that LF. So"a\r\n\nb"became"a\r\nb": one line break was lost, and the Mac output contained a Windows ending.Every style now does a single
\r\n|\r|\nreplacement (AnyLineEndingRegex), so no intermediate string can form a new sequence.DetermineLineEndingsstill uses the three existing regexes. Output only changes for inputs that hit the bug. The existingNormalizeLineEndingsTo*tests pass unchanged.Tests
NormalizeLineEndingsKeepsEveryBreakOfAdjacentMixedEndingscovers CRLF followed by LF, and CR followed by CRLF, for everyLineEndingStyle.NormalizeLineEndingsOfAdjacentMixedEndingsIsDetectedAsTheTargetStylechecks that Unix, Windows and Mac output is detected as that style.dotnet test Extensions.Testpasses 155/155.🤖 Generated with Claude Code
https://claude.ai/code/session_01LasidbyRZfyxgW8Z9wQu9M
Generated by Claude Code