From 76e8500cecd7a715b3effc984ae051cdbff2d3d3 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 19 Jul 2026 16:40:58 +0900 Subject: feat(spdx-licenses): implement is_valid_license_string SPDX expression parser PHP matches the SPDX license-expression grammar with a single recursive PCRE pattern ((?(DEFINE) subpatterns plus (?&name) recursion), which the regex crate cannot express, so port it as a hand-written recursive-descent parser instead. licenseid/licenseexceptionid dictionary lookups use longest-match-first, guarded against accepting a short entry that is only a coincidental prefix of a longer identifier run (e.g. "DOC" prefixing "DocumentRef-..."), which a length-sorted greedy match alone would misparse. Un-ignores the two validating_array_loader tests that were blocked on this todo!(). --- crates/shirabe/tests/package/loader/validating_array_loader_test.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'crates/shirabe/tests/package/loader') diff --git a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs index 419f703c..07f3e4a6 100644 --- a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs +++ b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs @@ -959,7 +959,6 @@ fn warning_provider() -> Vec<( } /// ref: ValidatingArrayLoaderTest::testLoadWarnings -#[ignore = "license warning cases need the SPDX license-expression grammar (recursive PCRE), not yet ported: spdx_licenses todo!()"] #[test] fn test_load_warnings() { for (cfg, mut expected_warnings, _must_check, _expected_array) in warning_provider() { @@ -981,7 +980,6 @@ fn test_load_warnings() { } /// ref: ValidatingArrayLoaderTest::testLoadSkipsWarningDataWhenIgnoringErrors -#[ignore = "must_check license cases need the SPDX license-expression grammar (recursive PCRE), not yet ported: spdx_licenses todo!()"] #[test] fn test_load_skips_warning_data_when_ignoring_errors() { for (mut cfg, _expected_warnings, must_check, expected_array) in warning_provider() { -- cgit v1.3.1