From b23fe28c422b71c6ba3eeb1c3bc576594fd7361f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Thu, 17 Jan 2019 18:33:19 +0100 Subject: [PATCH] fix bug that lowercases userInfo part --- gradle.properties | 2 +- net-url/src/main/java/org/xbib/net/URL.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7fc1ee4..3a575d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = net -version = 1.2.0 +version = 1.2.1 jackson.version = 2.8.11 junit.version = 4.12 diff --git a/net-url/src/main/java/org/xbib/net/URL.java b/net-url/src/main/java/org/xbib/net/URL.java index 88161f3..39fe543 100755 --- a/net-url/src/main/java/org/xbib/net/URL.java +++ b/net-url/src/main/java/org/xbib/net/URL.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; @@ -785,13 +786,17 @@ public class URL implements Comparable { } public Builder host(String host) { - this.host = host; + if (host != null) { + this.host = host.toLowerCase(Locale.ROOT); + } this.protocolVersion = ProtocolVersion.NONE; return this; } public Builder host(String host, ProtocolVersion protocolVersion) { - this.host = host; + if (host != null) { + this.host = host.toLowerCase(Locale.ROOT); + } this.protocolVersion = protocolVersion; return this; } @@ -1003,7 +1008,7 @@ public class URL implements Comparable { int i = remaining.indexOf(SEPARATOR_CHAR); int j = remaining.indexOf(QUESTION_CHAR); int pos = i >= 0 && j >= 0 ? Math.min(i, j) : i >= 0 ? i : j >= 0 ? j : -1; - String host = (pos >= 0 ? remaining.substring(0, pos) : remaining).toLowerCase(); + String host = (pos >= 0 ? remaining.substring(0, pos) : remaining); parseHostAndPort(builder, parseUserInfo(builder, host), resolve); if (builder.host == null) { return INVALID; @@ -1045,8 +1050,9 @@ public class URL implements Comparable { return remaining; } - private void parseHostAndPort(Builder builder, String host, boolean resolve) + private void parseHostAndPort(Builder builder, String rawHost, boolean resolve) throws URLSyntaxException { + String host = rawHost; if (host.indexOf('[') == 0) { int i = host.lastIndexOf(']'); if (i >= 0) {