Changeset: 547eca89fc5e for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/547eca89fc5e
Modified Files:
src/main/java/org/monetdb/mcl/net/MonetUrlParser.java
src/main/java/org/monetdb/mcl/net/Target.java
tests/tests.md
Branch: monetdbs
Log Message:
Adjustments after applying changes to libmapi
diffs (128 lines):
diff --git a/src/main/java/org/monetdb/mcl/net/MonetUrlParser.java
b/src/main/java/org/monetdb/mcl/net/MonetUrlParser.java
--- a/src/main/java/org/monetdb/mcl/net/MonetUrlParser.java
+++ b/src/main/java/org/monetdb/mcl/net/MonetUrlParser.java
@@ -16,6 +16,16 @@ public class MonetUrlParser {
public MonetUrlParser(Properties props, String url) throws
URISyntaxException {
this.props = props;
this.urlText = url;
+ // we want to accept monetdb:// but the Java URI parser rejects that.
+ switch (url) {
+ case "monetdb:-":
+ case "monetdbs:-":
+ throw new URISyntaxException(url, "invalid MonetDB URL");
+ case "monetdb://":
+ case "monetdbs://":
+ url += "-";
+ break;
+ }
this.url = new URI(url);
}
@@ -124,31 +134,27 @@ public class MonetUrlParser {
}
host = "";
remainder = "";
- } else if (authority.startsWith("[")) {
- // IPv6
- pos = authority.indexOf(']');
- if (pos < 0)
- throw new URISyntaxException(urlText, "unmatched '['");
- host = authority.substring(1, pos);
- remainder = authority.substring(pos + 1);
- } else if ((pos = authority.indexOf(':')) >= 0){
- host = authority.substring(0, pos);
- remainder = authority.substring(pos);
- } else {
- host = authority;
+ } else if (authority.equals("-")) {
+ host = "";
remainder = "";
+ } else {
+ if (authority.startsWith("[")) {
+ // IPv6
+ pos = authority.indexOf(']');
+ if (pos < 0)
+ throw new URISyntaxException(urlText, "unmatched '['");
+ host = authority.substring(1, pos);
+ remainder = authority.substring(pos + 1);
+ } else if ((pos = authority.indexOf(':')) >= 0) {
+ host = authority.substring(0, pos);
+ remainder = authority.substring(pos);
+ } else {
+ host = authority;
+ remainder = "";
+ }
}
- switch (host) {
- case "localhost":
- set(Parameter.HOST, "");
- break;
- case "localhost.":
- set(Parameter.HOST, "localhost");
- break;
- default:
- set(Parameter.HOST, host);
- break;
- }
+ host = unwrapLocalhost(host);
+ set(Parameter.HOST, host);
if (remainder.isEmpty()) {
// do nothing
@@ -206,6 +212,30 @@ public class MonetUrlParser {
}
}
+ public static String wrapLocalhost(String host) {
+ switch (host) {
+ case "localhost":
+ host = "localhost.";
+ break;
+ case "":
+ host = "localhost";
+ break;
+ }
+ return host;
+ }
+
+ public static String unwrapLocalhost(String host) {
+ switch (host) {
+ case "localhost":
+ host = "";
+ break;
+ case "localhost.":
+ host = "localhost";
+ break;
+ }
+ return host;
+ }
+
private void parseClassic() throws URISyntaxException {
String scheme = url.getScheme();
diff --git a/src/main/java/org/monetdb/mcl/net/Target.java
b/src/main/java/org/monetdb/mcl/net/Target.java
--- a/src/main/java/org/monetdb/mcl/net/Target.java
+++ b/src/main/java/org/monetdb/mcl/net/Target.java
@@ -5,7 +5,7 @@ import java.util.Properties;
import java.util.regex.Pattern;
public class Target {
- private static Pattern namePattern =
Pattern.compile("^[a-zA-Z_][-a-zA-Z0-9_.]*$");
+ private static Pattern namePattern =
Pattern.compile("^[a-zzA-Z_][-a-zA-Z0-9_.]*$");
private static Pattern hashPattern =
Pattern.compile("^sha256:[0-9a-fA-F:]*$");
private final boolean tls;
private final String host;
diff --git a/tests/tests.md b/tests/tests.md
--- a/tests/tests.md
+++ b/tests/tests.md
@@ -672,8 +672,8 @@ REJECT monetdb:
REJECT monetdbs:
REJECT monetdb:/
REJECT monetdbs:/
-REJECT monetdb://
-REJECT monetdbs://
+ACCEPT monetdb://
+ACCEPT monetdbs://
ACCEPT monetdb:///
ACCEPT monetdbs:///
```
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]