diff options
author | Steve Winslow <steve@swinslow.net> | 2021-05-02 17:34:43 -0400 |
---|---|---|
committer | Steve Winslow <steve@swinslow.net> | 2021-05-02 17:34:43 -0400 |
commit | 0e918ca7c85a9a4f865b59445ecf46abbb8d3feb (patch) | |
tree | b5565aa245495205aed6206c95a38796ebb919d1 /tvloader/parser2v2/util.go | |
parent | cb47219353548d6fdb55034422dc4e7fbee19058 (diff) | |
parent | 6234aa66fed08ee03a2be31ec177152cefeedfd2 (diff) | |
download | spdx-tools-0e918ca7c85a9a4f865b59445ecf46abbb8d3feb.tar.gz |
Merge branch 'issue-59' into issue-59-to-master
Diffstat (limited to 'tvloader/parser2v2/util.go')
-rw-r--r-- | tvloader/parser2v2/util.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tvloader/parser2v2/util.go b/tvloader/parser2v2/util.go index 691fe4e..6676846 100644 --- a/tvloader/parser2v2/util.go +++ b/tvloader/parser2v2/util.go @@ -73,6 +73,23 @@ func extractDocElementID(value string) (spdx.DocElementID, error) { return spdx.DocElementID{DocumentRefID: docRefID, ElementRefID: spdx.ElementID(eltRefID)}, nil } +// used to extract SPDXRef values from an SPDX Identifier, OR "special" strings +// from a specified set of permitted values. The primary use case for this is +// the right-hand side of Relationships, where beginning in SPDX 2.2 the values +// "NONE" and "NOASSERTION" are permitted. If the value does not match one of +// the specified permitted values, it will fall back to the ordinary +// DocElementID extractor. +func extractDocElementSpecial(value string, permittedSpecial []string) (spdx.DocElementID, error) { + // check value against special set first + for _, sp := range permittedSpecial { + if sp == value { + return spdx.DocElementID{SpecialID: sp}, nil + } + } + // not found, fall back to regular search + return extractDocElementID(value) +} + // used to extract SPDXRef values only from an SPDX Identifier which can point // to this document only. Use extractDocElementID for parsing IDs that can // refer either to this document or a different one. |