fix: encode paths when loading XML schemas - #1028
Merged
Merged
Conversation
Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
lxml5.x treats the path passed toXMLSchema(file=...)as a URL. When the local package path contains#, the fragment handling changes the base URL and the relativespdx.SNAPSHOT.xsdimport is not resolved.This change converts the absolute local schema path to an encoded
file:URI before loading it. It also adds a regression test that copies the bundled schemas beneath a path containing#and validates a minimal CycloneDX 1.6 document.Resolves or fixes issue: #551
Validation
XMLSchemaParseErrorwith lxml 5.3.2/libxml2 2.12.10 before the fix and passes after it.poetry run tox run -e py313-allExtras,py313-noExtras,flake8,mypy-current,mypy-lowest,bandit,deptrypoetry buildproduced both wheel and sdist.#; generated CycloneDX 1.6 XML passedXmlValidatorwith lxml 5.3.2.AI Tool Disclosure
OpenAI CodexGPT-5Research maintainer-confirmed issue #551, reproduce it with supported lxml versions, implement the smallest local-file URI compatibility fix, add a regression test, and run the repository's complete checks and package smoke test.Affirmation