EmbarkStudios / EmbarkStudios/spdx

Case insensitivity of license identifiers

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
58
Forks
28
PR merge metrics
No merged PRs in 30d

Description

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

The SPDX Specification 3.0.1 (and also 2.x) explains that license identifiers in SPDX documents should be matched case-insensitively:

> License identifiers (including license exception identifiers) used in SPDX documents or source code files should be matched in a case-insensitive manner. In other words, MIT, Mit and mIt should all be treated as the same identifier and referring to the same license.
>
> However, please be aware that it is often important to match with the case of the canonical identifier on the SPDX License List. This is because the canonical identifier's case is used in the URL of the license's or exception's entry on the List, and because the canonical identifier is translated to a URI in RDF documents.

In contrast, currently `spdx::Expression::parse("mIt")` will fail with `ParseError { original: "mIt", span: 0..3, reason: UnknownTerm }`.

**Describe the solution you'd like**
Do you plan to support case insensitivity when parsing license identifiers (by default, or as an optional parse mode)?

**Describe alternatives you've considered**
* Parse license identifiers case-insensitively be default
* Parse license identifiers case-insensitively as a configurable "case_insensitive" `ParseMode`
* Parse license identifiers case-sensitively (not following the "should" in the specification)

**Additional context**

The SPDX Specification v3.1-RC1 makes this even clearer and more liberal:

> In SPDX 3, license expressions are completely case-insensitive. That includes the operators ("AND", "OR", "WITH"), the special identifiers ("NONE" and "NOASSERTION"), as well as the license identifiers, including the user-defined ones.
> For example, the expressions `MIT AND NOASSERTION AND (BSD-3-Clause OR LicenseRef-Name)` and `mit aNd NoaSSerTion AnD (bSd-3-clausE OR licenseref-NAME)` are equivalent.

(Though it's unclear if this change will make it into 3.1 like that, or be modified or reverted before the final stable release.)

Contributor guide

Open the contributing guide

Research direction

Start at the Expression::parse entry point and trace how license identifiers, operators, special identifiers, and user-defined identifiers are recognized and matched. Compare the proposed default and configurable parse-mode behaviors, then define completion as consistent mixed-case parsing with coverage for the examples in the issue and preservation of canonical identifier casing where required.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.