Skip to content

fix: preserve whitespace in XML text content - #198

Open
sueun-dev wants to merge 1 commit into
madpah:mainfrom
sueun-dev:fix-xml-node-text-whitespace-20260911
Open

fix: preserve whitespace in XML text content#198
sueun-dev wants to merge 1 commit into
madpah:mainfrom
sueun-dev:fix-xml-node-text-whitespace-20260911

Conversation

@sueun-dev

Copy link
Copy Markdown

from_xml() strips leading and trailing whitespace from properties mapped to the node text with xml_name('.'), before applying the configured XML string handling. For example, a normalized-string value of " hello " is read as "hello", and a value containing only spaces becomes empty. This also changes Property.value when roundtripping a BOM through CycloneDX Python Library's XML output.

Remove the unconditional strip() and let the configured string handler decide normalization. TOKEN still collapses whitespace; plain strings and NORMALIZED_STRING retain surrounding spaces. The tests cover both affected types, whitespace-only text, and token/tab/plain-text controls.

Checked on Python 3.12/Linux arm64:

  • Three regression failures before the change; all six regression/control tests pass after it.
  • Serializer suite: 97 tests pass; flake8, isort, pyupgrade, and mypy (default and Python 3.8 target) pass.
  • CycloneDX Python Library at 52cb3c94f023df887ac65a6125bce4d63ab7857e: 6,984 tests pass with the patched dependency, plus 120 generated JSON/XML BOM roundtrips checking component fields and dependency edges.

The other Python/OS CI combinations were not run locally. AI assistance: OpenAI Codex produced the investigation, patch, tests, and this description; no human review is claimed.

Signed-off-by: Sueun Cho <sueun.dev@gmail.com>
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.

1 participant