Skip to content

Commit 96cb95b

Browse files
committed
Change validation for file to only exclude absolute file paths
Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
1 parent f9b3441 commit 96cb95b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/org/spdx/library/model/SpdxFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
269269
Optional<String> myName = this.getName();
270270
if (myName.isPresent()) {
271271
fileName = myName.get();
272-
if (!fileName.startsWith("./")) {
273-
retval.add("File name name must be relative - starting with './'. Found "+fileName);
272+
if (fileName.startsWith("/")) {
273+
retval.add("File name name must be relative - the name must not start with a '/'. Found "+fileName);
274274
}
275275
} else {
276276
retval.add("Missing required file name");

src/test/java/org/spdx/library/model/SpdxFileTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,5 +501,10 @@ public void testVerifyNonLocalFileName() throws InvalidSPDXAnalysisException {
501501
.build();
502502
result = file2.verify();
503503
assertTrue(result.isEmpty());
504+
SpdxFile file3 = gmo.createSpdxFile(gmo.getModelStore().getNextId(IdType.SpdxId, gmo.getDocumentUri()),
505+
"filename", COMPLEX_LICENSE, Arrays.asList(CONJUNCTIVE_LICENSES), SpdxConstants.NOASSERTION_VALUE, SHA1)
506+
.build();
507+
result = file3.verify();
508+
assertTrue(result.isEmpty());
504509
}
505510
}

0 commit comments

Comments
 (0)