Skip to content

Commit

Permalink
be more lenient with URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
acstroe committed Apr 18, 2022
1 parent 2d45ff4 commit 0ac1986
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/org/wikibase/WikibaseClaimFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ private static Snak parseSnakFromNode(Node snakNode) throws WikibaseException {
String urlValue = datavalueNode.getAttributes().getNamedItem("value").getNodeValue();
String decUrlValue = URLDecoder.decode(urlValue, StandardCharsets.UTF_8.name());
URL decUrl = new URL(decUrlValue);
URI uri = decUrlValue.contains("/") ? new URI(decUrl.getProtocol(), decUrl.getUserInfo(), decUrl.getHost(), decUrl.getPort(), decUrl.getPath(), decUrl.getQuery(), decUrl.getRef()) : decUrl.toURI();
URI uri = null;
try {
uri = decUrlValue.contains("/") ? new URI(decUrl.getProtocol(), decUrl.getUserInfo(), decUrl.getHost(), decUrl.getPort(), decUrl.getPath(), decUrl.getQuery(), decUrl.getRef()) : decUrl.toURI();
} catch (RuntimeException e) {
uri = decUrl.toURI();
}

snak.setData(new URLData(uri));
} catch (Exception e) {
throw new WikibaseException(e);
Expand Down

0 comments on commit 0ac1986

Please sign in to comment.