Skip to content

Commit

Permalink
Don't decode OBJECT URIs
Browse files Browse the repository at this point in the history
Fixes a bug where invalid URIs are created due to decodeing
  • Loading branch information
goneall committed Nov 13, 2024
1 parent 7ae1304 commit 90c809e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/java/org/spdx/spdxRdfStore/RdfSpdxModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ private Optional<Object> 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
Expand All @@ -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");
Expand Down

0 comments on commit 90c809e

Please sign in to comment.