Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ReaderFactory.newXmlReader() instead of ISR in MavenHelper #152

Merged
merged 2 commits into from May 29, 2022

Conversation

fgunbin
Copy link
Contributor

@fgunbin fgunbin commented May 25, 2022

plexus-utils's MXParser obtains encoding from XmlReader (see codehaus-plexus/plexus-utils#163) or from ISR.
In our case MavenHelper creates ISR, and it then reports "default" encoding, which most probably will be UTF-8.

When the pom file contains encoding declaration with something else, like ISO-8859-1 in https://repo1.maven.org/maven2/org/apache/commons/commons-parent/48/commons-parent-48.pom, this results in the error:

An error occurred attempting to read POM
org.codehaus.plexus.util.xml.pull.XmlPullParserException: UTF-8 BOM plus xml decl of iso-8859-1 is incompatible (position: START_DOCUMENT seen <?xml version="1.0" encoding="iso-8859-1"... @1:41)
	at org.codehaus.plexus.util.xml.pull.MXParser.parseXmlDeclWithVersion(MXParser.java:3366)
	at org.codehaus.plexus.util.xml.pull.MXParser.parseXmlDecl(MXParser.java:3288)

This PR switches to using plexus-utils's ReaderFactory, which "knows better". This eliminates the above error.

@fgunbin
Copy link
Contributor Author

fgunbin commented May 25, 2022

Should fix #107

@glefloch
Copy link
Member

Thanks for this @fgunbin. Could you add a test that assert no more exceptions are present in logs?

@fgunbin
Copy link
Contributor Author

fgunbin commented May 27, 2022

@glefloch Added, it fails without my patch, and passes with it.
Thanks.

Copy link
Member

@glefloch glefloch left a comment

Choose a reason for hiding this comment

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

Great thanks!

@glefloch glefloch merged commit e5954c6 into CycloneDX:master May 29, 2022
@fgunbin
Copy link
Contributor Author

fgunbin commented May 29, 2022

@glefloch Thank you!

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.

None yet

2 participants