Visitar URL original
Handle relative Windows paths when escaping by efegokdemir · Pull Request #393 · apache/maven-filtering · GitHub
Skip to content

Handle relative Windows paths when escaping - #393

Merged
gnodet merged 1 commit into
apache:masterfrom
efegokdemir:codex/issue-355-windows-path
Sep 24, 2026
Merged

gnodet merged 1 commit into
apache:masterfrom
efegokdemir:codex/issue-355-windows-path

Conversation

@efegokdemir

Copy link
Copy Markdown
Contributor

Rationale for this change

escapeWindowsPath() only recognized drive-qualified paths and collapsed repeated backslashes, so relative Windows paths were left unescaped and distinct input paths could produce the same output.

What changes are included in this PR?

  • Recognize relative Windows paths while retaining existing drive-qualified and embedded-path handling.
  • Escape every backslash without collapsing repeated separators.
  • Add regression coverage for relative and repeated-backslash paths.

Are these changes tested?

  • mvn -Dspotless.skip=true -Dtest=FilteringUtilsTest test — passed (9 tests)
  • git diff --check — passed

Are there any user-facing changes?

Yes. Relative Windows paths are now escaped consistently.

Closes #355

@gnodet-bot gnodet-bot 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.

The regex change is correct and the escaping logic is sound — [^:]+\\ cleanly distinguishes relative paths (no colon before the first backslash) from arbitrary values like a:b\\c. Three leftover artifacts from the pre-fix era need to be cleaned up before this merges.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot 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.

Both findings from the previous review are addressed:

  • ✅ Stale TODO/comments (// TODO: Correct to handle relative windows paths and the accompanying question) removed from FilteringUtils.java
  • ✅ Both commented-out tests now enabled as proper @Test methods (escapeWindowsPathStartingWithDrivelessAbsolutePath, escapeWindowsPathStartingWithExpression), plus two new tests covering the relative-path and idempotency cases

Regex logic and escaping function verified correct for all path types.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added bug Something isn't working java Pull requests that update Java code labels Sep 24, 2026
- Detect relative Windows paths (e.g. ..\ or relative\path) and skip
  drive-letter normalization that only applies to absolute paths
- Ensure backslash-to-forward-slash conversion works for both absolute
  and relative Windows paths before escape processing
- Add test coverage for relative Windows path escaping
@gnodet
gnodet force-pushed the codex/issue-355-windows-path branch from 3947f59 to a43174a Compare September 24, 2026 16:37
@gnodet
gnodet merged commit fb9a8cf into apache:master Sep 24, 2026
@github-actions github-actions Bot added this to the 4.0.0-beta-2 milestone Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

escapeWindowsPath() can produce ambiguous output and misses relative paths

3 participants