Skip to content

Commit

Permalink
Convert host names to lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
katzyn committed Jan 16, 2022
1 parent c5f11a5 commit 0f83f48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions h2/src/main/org/h2/server/web/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void init(String... args) {
"webSSL", false);
allowOthers = SortedProperties.getBooleanProperty(prop,
"webAllowOthers", false);
externalNames = SortedProperties.getStringProperty(prop, "webExternalNames", null);
setExternalNames(SortedProperties.getStringProperty(prop, "webExternalNames", null));
setAdminPassword(SortedProperties.getStringProperty(prop, "webAdminPassword", null));
commandHistoryString = prop.getProperty(COMMAND_HISTORY);
for (int i = 0; args != null && i < args.length; i++) {
Expand All @@ -333,7 +333,7 @@ public void init(String... args) {
} else if (Tool.isOption(a, "-webAllowOthers")) {
allowOthers = true;
} else if (Tool.isOption(a, "-webExternalNames")) {
externalNames = args[++i];
setExternalNames(args[++i]);
} else if (Tool.isOption(a, "-webDaemon")) {
isDaemon = true;
} else if (Tool.isOption(a, "-baseDir")) {
Expand Down Expand Up @@ -392,7 +392,7 @@ public String getHost() {

private void updateURL() {
try {
host = NetUtils.getLocalAddress();
host = StringUtils.toLowerEnglish(NetUtils.getLocalAddress());
StringBuilder builder = new StringBuilder(ssl ? "https" : "http").append("://")
.append(host).append(':').append(port);
if (key != null && serverSocket != null) {
Expand Down Expand Up @@ -568,7 +568,7 @@ public boolean getAllowOthers() {
}

void setExternalNames(String externalNames) {
this.externalNames = externalNames;
this.externalNames = externalNames != null ? StringUtils.toLowerEnglish(externalNames) : null;
}

String getExternalNames() {
Expand Down
1 change: 1 addition & 0 deletions h2/src/main/org/h2/server/web/WebThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ private boolean checkHost(String host) throws IOException {
if (host.isEmpty()) {
return false;
}
host = StringUtils.toLowerEnglish(host);
if (host.equals(server.getHost()) || host.equals("localhost") || host.equals("127.0.0.1")) {
return true;
}
Expand Down

0 comments on commit 0f83f48

Please sign in to comment.