Skip to content

Commit 59e6c55

Browse files
committed
1 parent 03122a7 commit 59e6c55

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/com/github/packageurl/internal/StringUtil.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
package com.github.packageurl.internal;
2323

2424
import static java.lang.Byte.toUnsignedInt;
25-
26-
import com.github.packageurl.ValidationException;
2725
import java.nio.charset.StandardCharsets;
26+
2827
import org.jspecify.annotations.NonNull;
2928

29+
import com.github.packageurl.ValidationException;
30+
3031
/**
3132
* String utility for validation and encoding.
3233
*
@@ -52,6 +53,13 @@ public final class StringUtil {
5253
UNRESERVED_CHARS['.'] = true;
5354
UNRESERVED_CHARS['_'] = true;
5455
UNRESERVED_CHARS['~'] = true;
56+
57+
/*
58+
According to purl-spec https://github.com/package-url/purl-spec/blob/0c3bc118ac5c001e067ba42fba8501405514f1a9/docs/standard/characters-and-encoding.md
59+
> The following characters must not be percent-encoded:
60+
> - the colon ':', whether used as a Separator Character or otherwise
61+
*/
62+
UNRESERVED_CHARS[':'] = true;
5563
}
5664

5765
private StringUtil() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
{
8787
"description": "docker uses qualifiers and hash image id as versions",
8888
"purl": "pkg:docker/customer/dockerimage@sha256:244fd47e07d1004f0aed9c?repository_url=gcr.io",
89-
"canonical_purl": "pkg:docker/customer/dockerimage@sha256%3A244fd47e07d1004f0aed9c?repository_url=gcr.io",
89+
"canonical_purl": "pkg:docker/customer/dockerimage@sha256:244fd47e07d1004f0aed9c?repository_url=gcr.io",
9090
"type": "docker",
9191
"namespace": "customer",
9292
"name": "dockerimage",

0 commit comments

Comments
 (0)