提交 9ab420f0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use Utils.parseBoolean() in more places with user-supplied strings

上级 469a69ea
......@@ -345,8 +345,7 @@ public class ConnectionInfo implements Cloneable {
* @return the value
*/
public boolean removeProperty(String key, boolean defaultValue) {
String x = removeProperty(key, null);
return x == null ? defaultValue : Boolean.parseBoolean(x);
return Utils.parseBoolean(removeProperty(key, null), defaultValue, false);
}
/**
......
......@@ -351,12 +351,10 @@ public class WebApp {
int port = Integer.decode((String) attributes.get("port"));
prop.setProperty("webPort", String.valueOf(port));
server.setPort(port);
boolean allowOthers = Boolean.parseBoolean(
(String) attributes.get("allowOthers"));
boolean allowOthers = Utils.parseBoolean((String) attributes.get("allowOthers"), false, false);
prop.setProperty("webAllowOthers", String.valueOf(allowOthers));
server.setAllowOthers(allowOthers);
boolean ssl = Boolean.parseBoolean(
(String) attributes.get("ssl"));
boolean ssl = Utils.parseBoolean((String) attributes.get("ssl"), false, false);
prop.setProperty("webSSL", String.valueOf(ssl));
server.setSSL(ssl);
server.saveProperties(prop);
......
......@@ -32,6 +32,7 @@ import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
* A facility to read from and write to CSV (comma separated values) files. When
......@@ -857,11 +858,11 @@ public class Csv implements SimpleRowSource {
} else if (isParam(key, "charset", "characterSet")) {
charset = value;
} else if (isParam(key, "preserveWhitespace")) {
setPreserveWhitespace(Boolean.parseBoolean(value));
setPreserveWhitespace(Utils.parseBoolean(value, false, false));
} else if (isParam(key, "writeColumnHeader")) {
setWriteColumnHeader(Boolean.parseBoolean(value));
setWriteColumnHeader(Utils.parseBoolean(value, true, false));
} else if (isParam(key, "caseSensitiveColumnNames")) {
setCaseSensitiveColumnNames(Boolean.parseBoolean(value));
setCaseSensitiveColumnNames(Utils.parseBoolean(value, false, false));
} else {
throw DbException.getUnsupportedException(key);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论