Fix #4609: Handle file-type license references in NuGet packages #4689
+174
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4609
Problem
When scanning NuGet packages that reference license files (like
[email protected]), the parser was dumping the raw XML dict instead of extracting the actual file path. This made the output pretty useless for anyone trying to find the license.Before:
After:
What changed?
The parser now checks if the license element has
type="file"and extracts the path properly:Pretty straightforward - just needed to handle the dict structure that xmltodict returns when parsing
<license type="file">path</license>.Testing
Ran all the NuGet tests - 10/10 passing. Also verified:
[email protected]now shows "See file at tools\LICENSE.txt" ✓The "unknown" declared license is expected here since we can't actually determine the license type without reading the file itself.
Files changed
src/packagedcode/nuget.py- the actual fixChecklist:
Signed-off-by: NullPointer-cell
[email protected]