Skip to content

Commit bf09fe8

Browse files
roxspringCapstan
authored andcommitted
Allow redirects to schemas with jar:file: URI
1 parent 904afbb commit bf09fe8

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: src/main/java/com/github/fge/jsonschema/core/util/URIUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void check(final URI argument)
188188
final JsonRef ref = JsonRef.fromURI(argument);
189189
BUNDLE.checkArgumentPrintf(ref.isAbsolute(),
190190
"uriChecks.notAbsoluteRef", argument);
191-
BUNDLE.checkArgumentPrintf(!argument.getPath().endsWith("/"),
191+
BUNDLE.checkArgumentPrintf(argument.getPath() == null || !argument.getPath().endsWith("/"),
192192
"uriChecks.endingSlash", argument);
193193
}
194194
};

Diff for: src/test/java/com/github/fge/jsonschema/core/util/URIUtilsTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ public void invalidPathURIsAreRejected(final String uri, final String key)
179179
}
180180
}
181181

182+
@DataProvider
183+
public Iterator<Object[]> validSchemaURIs()
184+
{
185+
final List<Object[]> list = Lists.newArrayList();
186+
187+
String uri;
188+
189+
uri = "http://example.com/schema";
190+
list.add(new Object[] { uri });
191+
192+
uri = "file:/path/to/schema.json";
193+
list.add(new Object[] { uri });
194+
195+
uri = "jar:file:/path/to/container.jar!/internal/path/to/schema.json";
196+
list.add(new Object[] { uri });
197+
198+
return list.iterator();
199+
}
200+
201+
@Test(dataProvider = "validSchemaURIs")
202+
public void validSchemaURIsAreAccepted(final String uri)
203+
{
204+
URIUtils.checkSchemaURI(URI.create(uri));
205+
}
206+
182207
@DataProvider
183208
public Iterator<Object[]> invalidSchemaURIs()
184209
{

0 commit comments

Comments
 (0)