这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 8bd2293

Browse files
Fixed: Fix bool extras parsing for SocketListener
1 parent 83c62b3 commit 8bd2293

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

app/src/main/java/com/termux/api/SocketListener.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,30 @@ public static void createSocketListener(Application app) {
8787

8888
m = EXTRA_BOOLEAN.matcher(cmdline);
8989
while (m.find()) {
90-
booleanExtras.put(m.group(1), Boolean.parseBoolean(m.group(2)));
90+
String value = m.group(2);
91+
value = value != null ? value.toLowerCase() : null;
92+
Boolean arg = null;
93+
94+
if ("true".equals(value) || "t".equals(value)) {
95+
arg = true;
96+
} else if ("false".equals(value) || "f".equals(value)) {
97+
arg = false;
98+
} else {
99+
try {
100+
if (value != null)
101+
arg = Integer.decode(value) != 0;
102+
} catch (NumberFormatException ex) {
103+
// Ignore
104+
}
105+
}
106+
if (arg == null) {
107+
String msg = "Invalid boolean extra: " + m.group(0) + "\n";
108+
Logger.logInfo(LOG_TAG, msg);
109+
out.write(msg);
110+
err = true;
111+
break;
112+
}
113+
booleanExtras.put(m.group(1), arg);
91114
}
92115
cmdline = m.replaceAll("");
93116

0 commit comments

Comments
 (0)