Skip to content

fix(store): keep SPDX element ids case-sensitive - #464

Open
soimkim wants to merge 1 commit into
spdx:masterfrom
soimkim:fix/spdx-element-id-case
Open

soimkim wants to merge 1 commit into
spdx:masterfrom
soimkim:fix/spdx-element-id-case

Conversation

@soimkim

@soimkim soimkim commented Nov 19, 2026

Copy link
Copy Markdown

Summary

Fixes #463.

InMemSpdxStore stored every object URI under a lowercased key, so two SPDX element ids that differ only by case were rejected as duplicates. SPDX 2.3.1 treats those ids as different elements.

  • An SPDXRef- fragment keeps its original case. SPDXRef-Arcturus.ogg and SPDXRef-arcturus.ogg can both be stored.
  • License identifiers stay case-insensitive. LicenseRef-Name and LicenseRef-name are still the same id, matching SPDX license expression case rules.
  • The part of the URI before # is still lowercased, so only the element id case changes.

Spec:

Test plan

  • mvn -Dtest=InMemSpdxStoreTest test (25 tests, 0 failures)
  • New test stores SPDXRef-Arcturus.ogg and SPDXRef-arcturus.ogg as two elements, and deleting one leaves the other
  • New test still rejects LicenseRef-Name and LicenseRef-name as a duplicate and resolves the original case

SPDX 2.3.1 treats SPDXRef- ids that differ only by case as different
elements. License identifiers stay case-insensitive.
@goneall

goneall commented Dec 3, 2026

Copy link
Copy Markdown
Member

Thanks @soimkim for the PR. This works fine for the SPDX 2.X spec, but doesn't cover all cases for the SPDX 3.X specification.

For SPDX 3.X:

  • Any listed license which has a prefix "http://spdx.org/licenses" should be case insensitive
  • Any LicenseRef should be case insensitive (you already have this one covered)
  • Any other object URI should be case sensitive - in SPDX 3, the SPDX ID no longer requires the SpdxConstantsCompatV2.SPDX_ELEMENT_REF_PRENUM format
  • Any IDs which are of type anonymous (which will not be a URI format) isn't specified as to case, but we could leave it case insensitive to reduce the risk of the changes

You can use the function getIdType(String objectUri) to check if the type needs to be case sensitive or not.

This branch has not been deployed

No deployments
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.

SPDX IDs that differ only by case are treated as duplicates

2 participants