Skip to content

Commit ac62676

Browse files
committed
Add test data
1 parent 00c46dd commit ac62676

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/main/java/com/github/packageurl/PackageURL.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private String validatePath(final String value, final boolean isSubpath) throws
344344
return validatePath(value.split("/"), isSubpath);
345345
}
346346

347-
private static boolean isValidSegment(String segment, boolean isSubpath) {
347+
private static boolean isValidSegment(String segment, final boolean isSubpath) {
348348
return (!isSubpath || (!segment.isEmpty() && !".".equals(segment) && !"..".equals(segment)));
349349
}
350350

@@ -641,7 +641,7 @@ private static String[] parsePath(final String value, final boolean isSubpath) {
641641
}
642642

643643
return Arrays.stream(percentDecode(value).split("/"))
644-
.filter(segment ->isValidSegment(segment, isSubpath))
644+
.filter(segment -> isValidSegment(segment, isSubpath))
645645
.toArray(String[]::new);
646646
}
647647

src/test/resources/test-suite-data.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,30 @@
4747
"subpath": "googleapis/api/annotations",
4848
"is_invalid": false
4949
},
50+
{
51+
"description": "invalid subpath - unencoded subpath cannot contain '..'",
52+
"purl": "pkg:GOLANG/google.golang.org/genproto@abcdedf#/googleapis/%2E%2E/api/annotations/",
53+
"canonical_purl": "pkg:golang/google.golang.org/genproto@abcdedf#googleapis/api/annotations",
54+
"type": "golang",
55+
"namespace": "google.golang.org",
56+
"name": "genproto",
57+
"version": "abcdedf",
58+
"qualifiers": null,
59+
"subpath": "googleapis/api/annotations",
60+
"is_invalid": false
61+
},
62+
{
63+
"description": "invalid subpath - unencoded subpath cannot contain '.'",
64+
"purl": "pkg:GOLANG/google.golang.org/genproto@abcdedf#/googleapis/%2E/api/annotations/",
65+
"canonical_purl": "pkg:golang/google.golang.org/genproto@abcdedf#googleapis/api/annotations",
66+
"type": "golang",
67+
"namespace": "google.golang.org",
68+
"name": "genproto",
69+
"version": "abcdedf",
70+
"qualifiers": null,
71+
"subpath": "googleapis/api/annotations",
72+
"is_invalid": false
73+
},
5074
{
5175
"description": "bitbucket namespace and name should be lowercased",
5276
"purl": "pkg:bitbucket/birKenfeld/pyGments-main@244fd47e07d1014f0aed9c",

0 commit comments

Comments
 (0)