Skip to content

XmlParser: case-insensitive accept for nuget.config#7317

Merged
timtebeek merged 2 commits intomainfrom
fix/xml-parser-case-insensitive-nuget-config
Apr 8, 2026
Merged

XmlParser: case-insensitive accept for nuget.config#7317
timtebeek merged 2 commits intomainfrom
fix/xml-parser-case-insensitive-nuget-config

Conversation

@steve-aom-elliott
Copy link
Copy Markdown
Contributor

@steve-aom-elliott steve-aom-elliott commented Apr 8, 2026

XmlParser.accept() had two case-sensitivity issues:

  1. File extensions: The extension check used a case-sensitive Set.contains(), so files like foo.XML or proj.Csproj were not recognized as XML. Added toLowerCase() on the extracted extension before lookup.

  2. Config file names: The nuget.config and packages.config checks used Path.endsWith() which is case-sensitive, so NuGet.config or Packages.config fell through to PlainTextParser. Switched to String.equalsIgnoreCase() on the file name.

Added test cases for mixed-case extensions and config file names.

…in XmlParser

The XmlParser.accept() method used Path.endsWith() which is case-sensitive,
so files like NuGet.config or Packages.config were not recognized as XML and
fell through to the PlainTextParser. Switch to equalsIgnoreCase on the file
name to handle all casing variants.
Apply toLowerCase() to the extracted extension before checking against the
accepted set, so files like foo.XML or proj.Csproj are correctly recognized.
@steve-aom-elliott steve-aom-elliott added enhancement New feature or request test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail xml labels Apr 8, 2026
@steve-aom-elliott steve-aom-elliott moved this from In Progress to Ready to Review in OpenRewrite Apr 8, 2026
@timtebeek
Copy link
Copy Markdown
Member

I'd be shouting too if I had to use Windows.

@timtebeek timtebeek merged commit 5559bfc into main Apr 8, 2026
1 check passed
@timtebeek timtebeek deleted the fix/xml-parser-case-insensitive-nuget-config branch April 8, 2026 17:22
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request test provided Already replicated with a unit test, using JUnit pioneer's ExpectedToFail xml

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants