Skip to content

Provide a way to render lax-parsed SPDX expressions as valid SPDX #56

@amy-keibler

Description

@amy-keibler

Is your feature request related to a problem? Please describe.

Thank you for creating such a useful library. We're using it in the CycloneDX SBOM Rust implementation. One rough edge we've come across is that we want to be able to accept mostly-correct SPDX identifiers (e.g. the "MIT/Apache-2.0" convention that's present in several crates), but we want to ensure that we're only producing valid SPDX expressions in our output, to maximize ecosystem tooling compatibility.

Describe the solution you'd like

It would be useful for the Expression type that is generated via parse_mode with ParseMode::LAX to be able to output as a valid SPDX identifier. Currently, it stores the original string and just outputs that when to_string is called. Changing the output to_string would be a breaking change, so maybe there could be an additional function named render or something similar?

Describe alternatives you've considered

Currently, we have a temporary solution that replaces / with OR, but a proper solution would be more robust.

Additional context

If this change is welcome, I might have time to implement this myself and submit a PR over the next few weeks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions