Skip to content

Commit b0d9dd0

Browse files
committed
reg-name actually cannot contain ':'
1 parent 9ddc632 commit b0d9dd0

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

lib/src/main/java/dev/harrel/jsonschema/FormatEvaluatorFactory.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.sanctionco.jmail.net.InternetProtocolAddress;
55

66
import java.net.URI;
7+
import java.net.URISyntaxException;
78
import java.time.format.DateTimeFormatter;
89
import java.util.*;
910
import java.util.function.Consumer;
@@ -225,10 +226,18 @@ private static void uriOperator(String value) throws FormatException {
225226

226227
private static void iriOperator(String value) throws FormatException {
227228
try {
228-
if (!URI.create(value).isAbsolute()) {
229+
URI uri = URI.create(value);
230+
if (!uri.isAbsolute()) {
229231
throw new FormatException(String.format("\"%s\" is relative", value));
230232
}
231-
} catch (RuntimeException e) {
233+
/*
234+
* https://www.rfc-editor.org/rfc/rfc3986.html#appendix-A
235+
* reg-name cannot contain unescaped ':', thus treating it as a server authority
236+
*/
237+
if (uri.getRawSchemeSpecificPart().contains(":")) {
238+
uri.parseServerAuthority();
239+
}
240+
} catch (URISyntaxException | RuntimeException e) {
232241
throw new FormatException(e.getMessage());
233242
}
234243
}

0 commit comments

Comments
 (0)