Skip to content

[3.x] Fix parsing a UTF-8 file without BOM that declares ISO-8859-1 - #384

Merged
slachiewicz merged 1 commit into
plexus-utils-3.xfrom
agent/port-xml-encoding-fix-3x
Dec 1, 2026
Merged

slachiewicz merged 1 commit into
plexus-utils-3.xfrom
agent/port-xml-encoding-fix-3x

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Fixes the error from #242 on the 3.x line: a UTF-8 file without a BOM that declares ISO-8859-1 failed with "UTF-8 BOM plus xml decl of ISO-8859-1 is incompatible" when the parser was given a Reader. The fix went into plexus-xml (codehaus-plexus/plexus-xml#1) when the XML classes moved there; 3.x bundles its own copy and never received it.

The commit is @gnodet's and @belingueres's, cherry-picked as authored; the conflicts were the ReaderFactory package and test formatting. Please merge with "Rebase and merge" so their authorship is kept.

As in plexus-xml, setInput(InputStream, null) now reads the stream strictly: a BOM that contradicts the XML declaration is rejected instead of tolerated.

Verified: mvn clean verify → 482 tests, 0 failures; with the unpatched MXParser and XmlReader the ported tests fail (5 failures, two with the message above).

* do not try to discover the encoding used when the input is given a Reader
* simplified test-encoding-ISO-8859-1.xml test file
* fixed tests exercising encoding checks. Unsupported tests were skipped

---------

Co-authored-by: Gabriel Belingueres <belingueres@gmail.com>
(cherry picked from commit 300a4e4)
(cherry picked from commit 809231ce3963db1bf5ae3cd6bf1da509c622d5ea)
@slachiewicz slachiewicz added the bug Something isn't working label Dec 1, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review December 1, 2026 12:29
@slachiewicz
slachiewicz merged commit 6e01cc2 into plexus-utils-3.x Dec 1, 2026
15 checks passed
@slachiewicz
slachiewicz deleted the agent/port-xml-encoding-fix-3x branch December 1, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants