Skip to content

Add missing EOF checks in MultiDelimiterInterpolatorFilterReaderLineEnding.read()#348

Open
elharo wants to merge 2 commits into
masterfrom
fix/missing-eof-checks
Open

Add missing EOF checks in MultiDelimiterInterpolatorFilterReaderLineEnding.read()#348
elharo wants to merge 2 commits into
masterfrom
fix/missing-eof-checks

Conversation

@elharo

@elharo elharo commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

The escape-detection loop (line 223) and delimiter-detection loop (line 246)
were missing ch == -1 checks. When EOF is reached mid-token, (char) -1
produces 0xFFFF which gets appended to the key StringBuilder as garbage.
The equivalent single-delimiter class InterpolatorFilterReaderLineEnding
already has these checks.

fixes #349

…nding.read()

The escape-detection loop (line 223) and delimiter-detection loop (line 246)
were missing ch == -1 checks. When EOF is reached mid-token, (char) -1
produces 0xFFFF which gets appended to the key StringBuilder as garbage.
The equivalent single-delimiter class InterpolatorFilterReaderLineEnding
already has these checks.
@elharo elharo marked this pull request as draft June 30, 2026 20:33
@elharo elharo marked this pull request as ready for review July 1, 2026 11:19
@elharo elharo requested review from Copilot and cstamas July 1, 2026 11:19

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 pull request fixes EOF handling in MultiDelimiterInterpolatorFilterReaderLineEnding.read() so that reaching end-of-stream while matching an escape string or delimiter begin token no longer results in 0xFFFF being appended to the output.

Changes:

  • Add explicit ch == -1 checks in the escape-string and begin-token matching loops.
  • Prevent appending (char) -1 to the output buffer during escape handling.
  • Add a regression test covering EOF immediately after an escape character.

Reviewed changes

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

File Description
src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java Adds EOF guards during token detection and avoids appending (char)-1 when EOF occurs while processing an escape sequence.
src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java Adds a regression test ensuring EOF after an escape char does not emit a garbage 0xFFFF character.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1. Missing EOF checks in MultiDelimiterInterpolatorFilterReaderLineEnding.read()

2 participants