From 90c809e335e1da5ce09e29aae8466646872774e2 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Tue, 12 Nov 2024 16:46:44 -0800 Subject: [PATCH] Don't decode OBJECT URIs Fixes a bug where invalid URIs are created due to decodeing --- .../java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java b/src/main/java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java index 965ca25..18dc2ad 100644 --- a/src/main/java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java +++ b/src/main/java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java @@ -824,7 +824,7 @@ private Optional literalNodeToObject(Object literalValue, Property prope } /** - * Obtain an ID from a resource + * Obtain an ObjectUri from a resource * @param resource * @return ID formatted appropriately for use outside the RdfStore * @throws SpdxRdfException @@ -834,12 +834,7 @@ private String resourceToObjectUri(Resource resource) throws SpdxRdfException { if (resource.isAnon()) { return RdfStore.ANON_PREFIX + resource.getId(); } else if (resource.isURIResource()) { - try { - return URLDecoder.decode(resource.getURI(), StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - logger.error("Unexpected URL decoding error for: "+resource.toString()); - return resource.getURI(); - } + return resource.getURI(); } else { logger.error("Attempting to convert unsupported resource type to an ID: "+resource.toString()); throw new SpdxRdfException("Only anonymous and URI resources can be converted to an ID");