Skip to content

fix: encode paths when loading XML schemas - #1028

Merged
jkowalleck merged 1 commit into
CycloneDX:mainfrom
CAOShurong:codex/fix-xml-schema-paths
Aug 12, 2026
Merged

fix: encode paths when loading XML schemas#1028
jkowalleck merged 1 commit into
CycloneDX:mainfrom
CAOShurong:codex/fix-xml-schema-paths

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Description

lxml 5.x treats the path passed to XMLSchema(file=...) as a URL. When the local package path contains #, the fragment handling changes the base URL and the relative spdx.SNAPSHOT.xsd import 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

  • Regression test reproduced the XMLSchemaParseError with lxml 5.3.2/libxml2 2.12.10 before the fix and passes after it.
  • The same test passes with lxml 4.9.4, 5.3.2, and 6.1.1 on Windows or WSL as available.
  • Full suite: 6,962 tests passed on Python 3.13.
  • poetry run tox run -e py313-allExtras,py313-noExtras,flake8,mypy-current,mypy-lowest,bandit,deptry
  • poetry build produced both wheel and sdist.
  • The built wheel was installed into a clean WSL environment whose site-packages path contains #; generated CycloneDX 1.6 XML passed XmlValidator with lxml 5.3.2.

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: OpenAI Codex
    • LLMs and versions: GPT-5
    • Prompts: Research 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

Signed-off-by: Shurong Cao <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong
CAOShurong requested a review from a team as a code owner August 12, 2026 06:22
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

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.

@jkowalleck jkowalleck added the bug Something isn't working label Aug 12, 2026
@jkowalleck jkowalleck linked an issue Aug 12, 2026 that may be closed by this pull request
@jkowalleck
jkowalleck merged commit 17a0136 into CycloneDX:main Aug 12, 2026
47 checks passed
@jkowalleck

Copy link
Copy Markdown
Member

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.

tests: test suite break when path contains #

2 participants