[Git][java-team/jsonld-java][master] 4 commits: New upstream version 0.13.3
Andrius Merkys (@merkys)
gitlab at salsa.debian.org
Sun Sep 5 06:56:02 BST 2021
Andrius Merkys pushed to branch master at Debian Java Maintainers / jsonld-java
Commits:
ae7c6ff1 by Andrius Merkys at 2021-09-05T01:26:40-04:00
New upstream version 0.13.3
- - - - -
536d6b40 by Andrius Merkys at 2021-09-05T01:26:41-04:00
Update upstream source from tag 'upstream/0.13.3'
Update to upstream version '0.13.3'
with Debian dir e24070c4e6ad37deb5e888116cbf666b6a456efe
- - - - -
812c7688 by Andrius Merkys at 2021-09-05T01:27:49-04:00
Refreshing patches.
- - - - -
df5dfb53 by Andrius Merkys at 2021-09-05T01:28:09-04:00
Update changelog for 0.13.3-1 release
- - - - -
11 changed files:
- .travis.yml
- README.md
- core/pom.xml
- core/src/main/java/com/github/jsonldjava/core/Context.java
- core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java
- + core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java
- core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java
- + core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java
- debian/changelog
- debian/patches/skip-network-tests.patch
- pom.xml
Changes:
=====================================
.travis.yml
=====================================
@@ -6,3 +6,6 @@ notifications:
email: false
after_success:
- mvn clean test jacoco:report coveralls:report
+arch:
+ - amd64
+ - ppc64le
=====================================
README.md
=====================================
@@ -16,7 +16,7 @@ From Maven
<dependency>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java</artifactId>
- <version>0.13.2</version>
+ <version>0.13.3</version>
</dependency>
Code example
@@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like
<parent>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java-parent</artifactId>
- <version>0.13.2</version>
+ <version>0.13.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsonld-java-{your module}</artifactId>
- <version>0.13.2-SNAPSHOT</version>
+ <version>0.13.3-SNAPSHOT</version>
<name>JSONLD Java :: {your module name}</name>
<description>JSON-LD Java integration module for {RDF Library your module integrates}</description>
<packaging>jar</packaging>
@@ -449,6 +449,11 @@ Alternatively, we can also host your repository in the jsonld-java organisation
CHANGELOG
=========
+### 2021-03-06
+* Release 0.13.3
+* Fix @type when subject and object are the same (Reported by @barthanssens, Patch by @umbreak)
+* Ignore @base if remote context is not relative (Reported by @whikloj, Patch by @dr0i)
+* Fix throwing recursive context inclusion (Patch by @umbreak)
### 2020-09-24
* Release 0.13.2
=====================================
core/pom.xml
=====================================
@@ -4,7 +4,7 @@
<parent>
<artifactId>jsonld-java-parent</artifactId>
<groupId>com.github.jsonld-java</groupId>
- <version>0.13.2</version>
+ <version>0.13.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jsonld-java</artifactId>
=====================================
core/src/main/java/com/github/jsonldjava/core/Context.java
=====================================
@@ -9,6 +9,7 @@ import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Pattern;
import com.github.jsonldjava.core.JsonLdError.Error;
import com.github.jsonldjava.utils.JsonLdUrl;
@@ -25,6 +26,7 @@ public class Context extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = 2894534897574805571L;
+ private static final Pattern URL_PATTERN = Pattern.compile("^https?://.*$", Pattern.CASE_INSENSITIVE);
private JsonLdOptions options;
private Map<String, Object> termDefinitions;
public Map<String, Object> inverse = null;
@@ -141,8 +143,10 @@ public class Context extends LinkedHashMap<String, Object> {
* @throws JsonLdError
* If there is an error parsing the contexts.
*/
- @SuppressWarnings("unchecked")
public Context parse(Object localContext, List<String> remoteContexts) throws JsonLdError {
+ if (remoteContexts == null) {
+ remoteContexts = new ArrayList<String>();
+ }
return parse(localContext, remoteContexts, false);
}
@@ -163,11 +167,8 @@ public class Context extends LinkedHashMap<String, Object> {
* @throws JsonLdError
* If there is an error parsing the contexts.
*/
- private Context parse(Object localContext, List<String> remoteContexts,
+ private Context parse(Object localContext, final List<String> remoteContexts,
boolean parsingARemoteContext) throws JsonLdError {
- if (remoteContexts == null) {
- remoteContexts = new ArrayList<String>();
- }
// 1. Initialize result to the result of cloning active context.
Context result = this.clone(); // TODO: clone?
// 2)
@@ -187,13 +188,18 @@ public class Context extends LinkedHashMap<String, Object> {
}
// 3.2)
else if (context instanceof String) {
- String uri = (String) result.get(JsonLdConsts.BASE);
+ String uri = null;
+ // @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304
+ if (!URL_PATTERN.matcher(context.toString()).matches()) {
+ uri = (String) result.get(JsonLdConsts.BASE);
+ }
uri = JsonLdUrl.resolve(uri, (String) context);
// 3.2.2
if (remoteContexts.contains(uri)) {
throw new JsonLdError(Error.RECURSIVE_CONTEXT_INCLUSION, uri);
}
- remoteContexts.add(uri);
+ List<String> nextRemoteContexts = new ArrayList<>(remoteContexts);
+ nextRemoteContexts.add(uri);
// 3.2.3: Dereference context
final RemoteDocument rd = this.options.getDocumentLoader().loadDocument(uri);
@@ -208,7 +214,7 @@ public class Context extends LinkedHashMap<String, Object> {
.get(JsonLdConsts.CONTEXT);
// 3.2.4
- result = result.parse(tempContext, remoteContexts, true);
+ result = result.parse(tempContext, nextRemoteContexts, true);
// 3.2.5
continue;
} else if (!(context instanceof Map)) {
=====================================
core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java
=====================================
@@ -2001,7 +2001,8 @@ public class JsonLdApi {
// 3.5.4)
if (RDF_TYPE.equals(predicate) && (object.isIRI() || object.isBlankNode())
- && !opts.getUseRdfType() && !nodes.containsKey(object.getValue())) {
+ && !opts.getUseRdfType() &&
+ (!nodes.containsKey(object.getValue()) || subject.equals(object.getValue()))) {
JsonLdUtils.mergeValue(node, JsonLdConsts.TYPE, object.getValue());
continue;
}
=====================================
core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java
=====================================
@@ -0,0 +1,75 @@
+package com.github.jsonldjava.core;
+
+import com.github.jsonldjava.utils.JsonUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+
+public class ContextRecursionTest {
+
+ @BeforeClass
+ public static void setup() {
+ System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "true");
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "false");
+ }
+
+ @Test
+ public void testIssue302_allowedRecursion() throws IOException {
+
+ final String contextB = "{\"@context\": [\"http://localhost/d\", {\"b\": \"http://localhost/b\"} ] }";
+ final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }";
+ final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }";
+ final String contextE = "{\"@context\": {\"e\": \"http://localhost/e\"} }";
+
+ final DocumentLoader dl = new DocumentLoader();
+ dl.addInjectedDoc("http://localhost/b", contextB);
+ dl.addInjectedDoc("http://localhost/c", contextC);
+ dl.addInjectedDoc("http://localhost/d", contextD);
+ dl.addInjectedDoc("http://localhost/e", contextE);
+ final JsonLdOptions options = new JsonLdOptions();
+ options.setDocumentLoader(dl);
+
+ final String jsonString = "{\"@context\": [\"http://localhost/d\", \"http://localhost/b\", \"http://localhost/c\", {\"a\": \"http://localhost/a\"} ], \"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\"}";
+ final Object json = JsonUtils.fromString(jsonString);
+ final Object expanded = JsonLdProcessor.expand(json, options);
+ assertEquals(
+ "[{http://localhost/a=[{@value=A}], http://localhost/b=[{@value=B}], http://localhost/c=[{@value=C}], http://localhost/d=[{@value=D}]}]",
+ expanded.toString());
+ }
+
+ @Test
+ public void testCyclicRecursion() throws IOException {
+
+ final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }";
+ final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }";
+ final String contextE = "{\"@context\": [\"http://localhost/c\", {\"e\": \"http://localhost/e\"} ] }";
+
+ final DocumentLoader dl = new DocumentLoader();
+ dl.addInjectedDoc("http://localhost/c", contextC);
+ dl.addInjectedDoc("http://localhost/d", contextD);
+ dl.addInjectedDoc("http://localhost/e", contextE);
+ final JsonLdOptions options = new JsonLdOptions();
+ options.setDocumentLoader(dl);
+
+ final String jsonString = "{\"@context\": [\"http://localhost/c\", {\"a\": \"http://localhost/a\"} ]}";
+ final Object json = JsonUtils.fromString(jsonString);
+ try {
+ JsonLdProcessor.expand(json, options);
+ fail("it should throw");
+ } catch(JsonLdError err) {
+ assertEquals(JsonLdError.Error.RECURSIVE_CONTEXT_INCLUSION, err.getType());
+ assertEquals("recursive context inclusion: http://localhost/c", err.getMessage());
+ }
+ }
+
+}
=====================================
core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java
=====================================
@@ -381,11 +381,19 @@ public class DocumentLoaderTest {
}
@Test
- public void injectContext() throws Exception {
+ public void testInjectContext() throws Exception {
+ injectContext(new JsonLdOptions());
+ }
+
+ @Test
+ public void testIssue304_remoteContextAndBaseIri() throws Exception {
+ injectContext(new JsonLdOptions("testing:baseIri"));
+ }
+
+ private void injectContext(final JsonLdOptions options) throws Exception {
final Object jsonObject = JsonUtils.fromString(
"{ \"@context\":\"http://nonexisting.example.com/thing\", \"pony\":5 }");
- final JsonLdOptions options = new JsonLdOptions();
// Verify fails to find context by default
try {
=====================================
core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java
=====================================
@@ -0,0 +1,31 @@
+package com.github.jsonldjava.core;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class JsonLdToRdfTest {
+
+ @Test
+ public void testIssue301() throws JsonLdError {
+ final RDFDataset rdf = new RDFDataset();
+ rdf.addTriple(
+ "http://www.w3.org/2002/07/owl#Class",
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
+ "http://www.w3.org/2002/07/owl#Class");
+ final JsonLdOptions opts = new JsonLdOptions();
+ opts.setUseRdfType(Boolean.FALSE);
+ opts.setProcessingMode(JsonLdOptions.JSON_LD_1_0);
+
+ final Object out = new JsonLdApi(opts).fromRDF(rdf, true);
+ assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, @type=[http://www.w3.org/2002/07/owl#Class]}]",
+ out.toString());
+
+ opts.setUseRdfType(Boolean.TRUE);
+
+ final Object out2 = new JsonLdApi(opts).fromRDF(rdf, true);
+ assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, http://www.w3.org/1999/02/22-rdf-syntax-ns#type=[{@id=http://www.w3.org/2002/07/owl#Class}]}]",
+ out2.toString());
+ }
+
+}
=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+jsonld-java (0.13.3-1) unstable; urgency=medium
+
+ * New upstream version 0.13.3
+ * Refreshing patches.
+
+ -- Andrius Merkys <merkys at debian.org> Sun, 05 Sep 2021 01:28:04 -0400
+
jsonld-java (0.13.2-2) unstable; urgency=medium
* Team upload.
=====================================
debian/patches/skip-network-tests.patch
=====================================
@@ -74,7 +74,7 @@ Author: Andrius Merkys <merkys at debian.org>
@Test
public void testDisallowRemoteContexts() throws Exception {
final String testUrl = "http://json-ld.org/contexts/person.jsonld";
-@@ -410,6 +416,7 @@
+@@ -418,6 +424,7 @@
assertEquals(5, v);
}
=====================================
pom.xml
=====================================
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.jsonld-java</groupId>
<artifactId>jsonld-java-parent</artifactId>
- <version>0.13.2</version>
+ <version>0.13.3</version>
<name>JSONLD Java :: Parent</name>
<description>Json-LD Java Parent POM</description>
<packaging>pom</packaging>
@@ -39,10 +39,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <httpclient.version>4.5.12</httpclient.version>
- <httpcore.version>4.4.13</httpcore.version>
- <jackson.version>2.11.2</jackson.version>
- <junit.version>4.13</junit.version>
+ <httpclient.version>4.5.13</httpclient.version>
+ <httpcore.version>4.4.14</httpcore.version>
+ <jackson.version>2.11.4</jackson.version>
+ <junit.version>4.13.2</junit.version>
<slf4j.version>1.7.30</slf4j.version>
<last-compare-version>0.11.0</last-compare-version>
@@ -351,7 +351,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>3.2.0</version>
+ <version>3.2.1</version>
<executions>
<execution>
<id>attach-source</id>
@@ -401,7 +401,7 @@
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
- <version>0.14.2</version>
+ <version>0.14.4</version>
<configuration>
<oldVersion>
<dependency>
@@ -448,7 +448,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>0.8.5</version>
+ <version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
View it on GitLab: https://salsa.debian.org/java-team/jsonld-java/-/compare/98aafb485caed1b79e78f38d9c1b1f97b6c6a754...df5dfb53f61b810a8d124c08f9cc22b723edd05f
--
View it on GitLab: https://salsa.debian.org/java-team/jsonld-java/-/compare/98aafb485caed1b79e78f38d9c1b1f97b6c6a754...df5dfb53f61b810a8d124c08f9cc22b723edd05f
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210905/5aa246cc/attachment.htm>
More information about the pkg-java-commits
mailing list