Skip to content

fix: normalize every CRLF when parsing a RELEASES manifest - #73

Merged
dopry merged 3 commits into
nextfrom
claude/fix-parse-releases-crlf
Jul 22, 2026
Merged

fix: normalize every CRLF when parsing a RELEASES manifest#73
dopry merged 3 commits into
nextfrom
claude/fix-parse-releases-crlf

Conversation

@dopry

@dopry dopry commented Jul 22, 2026

Copy link
Copy Markdown
Owner

parseRELEASES normalized line endings with String.replace("\r\n", "\n"), which only replaces the first occurrence — every subsequent line of a CRLF manifest kept its trailing \r. The line regex's [\r]*$ tolerance made this harmless in practice, but the normalization now actually does what it says via replaceAll (string pattern, so the exec-spying edge-case test is unaffected).

Adds a multi-line CRLF parsing test.

From the 2.0 release review pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM


Generated by Claude Code

String.replace with a string pattern only replaces the first occurrence,
so all but the first line of a CRLF manifest kept their trailing \r. The
line regex tolerated the stray \r (making this harmless in practice),
but the normalization now does what it says via replaceAll.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves parseRELEASES (Windows Squirrel RELEASES manifest parsing) by ensuring CRLF normalization is applied to all line endings, and adds a regression test intended to cover multi-line CRLF input.

Changes:

  • Replace single-occurrence CRLF normalization (replace) with full normalization (replaceAll) in parseRELEASES.
  • Add a unit test covering parsing of a multi-line CRLF manifest.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/utils/win-releases.ts Uses replaceAll("\r\n", "\n") to fully normalize CRLF before splitting into lines.
test/unit/win-releases.spec.ts Adds a CRLF multi-line parsing test (needs strengthening to actually validate “all CRLFs normalized”).

Comment thread src/utils/win-releases.ts Outdated
Comment thread test/unit/win-releases.spec.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/utils/win-releases.ts:76

  • The comment above this line is factually inverted: it’s String.prototype.replace("\r\n", "\n") that only replaces the first occurrence; replaceAll is the fix. As written, this is misleading for future readers.
  // replaceAll: replace with a string pattern only replaces the first CRLF
  const normalizedEOL = stripped.replaceAll("\r\n", "\n");

Copilot review follow-up: the line regex tolerates a trailing CR, so the
CRLF test now captures the lines handed to the regex and asserts none
still carries one (it fails against first-only String#replace), and the
comment no longer reads as if replaceAll were the single-replacement
variant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/utils/win-releases.ts:76

  • The comment says “replaceAll normalizes every line ending”, but this code only targets CRLF (not standalone \r). To avoid misleading future readers, consider wording this as normalizing “all CRLF occurrences”.
  // String#replace with a string pattern would only replace the first
  // CRLF; replaceAll normalizes every line ending

Comment thread test/unit/win-releases.spec.ts Outdated
Comment thread test/unit/win-releases.spec.ts Outdated
Copilot review follow-up: the RegExp.prototype.exec spy now restores in
a finally block so a throwing parseRELEASES can't leak it into later
tests; the comments now say only the second (CRLF-terminated) line
retains a CR under first-only replacement and that replaceAll targets
CRLF occurrences, not every line-ending flavor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AtqCsX7ptP36t5rdyaJJhM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@dopry
dopry merged commit a55636b into next Jul 22, 2026
3 checks passed
@dopry
dopry deleted the claude/fix-parse-releases-crlf branch July 22, 2026 03:17
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.

3 participants