accept a proxy port given with the host, and keep the saved proxy when the host is invalid, in the desktop and terminal settings
What changed, and why it matters
This commit fixes a small user-experience bug in Sparrow Wallet's proxy settings. Previously, if a user typed a proxy address that included a port (like '127.0.0.1:9050') into the host field, the app rejected it as invalid and could also wipe out the previously saved proxy. The change now accepts host:port combinations and keeps the saved proxy when the host entry is invalid, matching how invalid ports were already handled.
No urgent security action required. Treat as a normal bug-fix release. Users relying on Tor/proxy settings should verify their saved proxy persists after updating.
Security signals we found
Input validation logic changed for proxy host/port fields
Behavioral fix prevents accidental clearing of saved proxy configuration on invalid host input
No cryptographic, authentication, or network-layer changes observed
Evidence from the diff
The patch updates ServerSettingsController.java and ServerProxyDialog.java. It adds a getHostWithPort() helper using Guava’s HostAndPort.fromString() so that proxyHost text such as ‘host:port’ is accepted when the standalone port field is blank. It also preserves the existing config.getProxyServer() when hostAsString is null but proxyHost is non-blank, preventing an invalid host from clearing the saved proxy. Validation is relaxed to allow either getHost() or getHostWithPort() to succeed.
Changed components
src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.javasrc/main/java/com/sparrowwallet/sparrow/terminal/settings/ServerProxyDialog.javaInspect captured patch +43 / −1
### src/main/java/com/sparrowwallet/sparrow/settings/ServerSettingsController.java
@@ -790,7 +790,7 @@ private void setupValidation() {
validationSupport.registerValidator(proxyHost, Validator.combine(
(Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Proxy host required", useProxy.isSelected() && newValue.isBlank()),
- (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid host name", getHost(newValue) == null)
+ (Control c, String newValue) -> ValidationResult.fromErrorIf( c, "Invalid host name", getHost(newValue) == null && getHostWithPort(newValue) == null)
));
validationSupport.registerValidator(proxyPort, Validator.combine(
@@ -994,6 +994,14 @@ private ChangeListener<String> getProxyListener(Config config) {
private void setProxyConfig(Config config) {
String hostAsString = getHost(proxyHost.getText());
Integer portAsInteger = getPort(proxyPort.getText());
+ HostAndPort hostWithPort = hostAsString == null ? getHostWithPort(proxyHost.getText()) : null;
+ if(hostWithPort != null) {
+ hostAsString = hostWithPort.getHost();
+ if(proxyPort.getText().isBlank()) {
+ portAsInteger = hostWithPort.getPort();
+ }
+ }
+
String proxyServer = null;
if(hostAsString != null && !hostAsString.isBlank() && portAsInteger != null && isValidPort(portAsInteger)) {
proxyServer = HostAndPort.fromParts(hostAsString, portAsInteger).toString();
@@ -1003,6 +1011,9 @@ private void setProxyConfig(Config config) {
proxyServer = config.getProxyServer() != null ? config.getProxyServer() : HostAndPort.fromHost(hostAsString).toString();
} else if(hostAsString != null && !hostAsString.isBlank()) {
proxyServer = HostAndPort.fromHost(hostAsString).toString();
+ } else if(hostAsString == null && !proxyHost.getText().isBlank()) {
+ //An invalid host leaves the proxy as it was, as an invalid port does
+ proxyServer = config.getProxyServer();
}
config.setProxyServer(proxyServer);
@@ -1021,6 +1032,16 @@ private String getHost(String text) {
}
}
+ //A port given with the proxy host is taken as the port where the port field is empty, the port field otherwise taking precedence
+ private HostAndPort getHostWithPort(String text) {
+ try {
+ HostAndPort hostAndPort = HostAndPort.fromString(text.trim());
+ return hostAndPort.hasPort() ? hostAndPort : null;
+ } catch(IllegalArgumentException e) {
+ return null;
+ }
+ }
+
private Integer getPort(String text) {
try {
return Integer.parseInt(text);
### src/main/java/com/sparrowwallet/sparrow/terminal/settings/ServerProxyDialog.java
@@ -80,6 +80,14 @@ protected void addProxyComponents(Panel mainPanel) {
private void setProxyConfig(boolean useProxySelected) {
String hostAsString = getHost(proxyHost.getText());
Integer portAsInteger = getPort(proxyPort.getText());
+ HostAndPort hostWithPort = hostAsString == null ? getHostWithPort(proxyHost.getText()) : null;
+ if(hostWithPort != null) {
+ hostAsString = hostWithPort.getHost();
+ if(proxyPort.getText().isBlank()) {
+ portAsInteger = hostWithPort.getPort();
+ }
+ }
+
String proxyServer = null;
if(hostAsString != null && !hostAsString.isBlank() && portAsInteger != null && isValidPort(portAsInteger)) {
proxyServer = HostAndPort.fromParts(hostAsString, portAsInteger).toString();
@@ -89,6 +97,9 @@ private void setProxyConfig(boolean useProxySelected) {
proxyServer = Config.get().getProxyServer() != null ? Config.get().getProxyServer() : HostAndPort.fromHost(hostAsString).toString();
} else if(hostAsString != null && !hostAsString.isBlank()) {
proxyServer = HostAndPort.fromHost(hostAsString).toString();
+ } else if(hostAsString == null && !proxyHost.getText().isBlank()) {
+ //An invalid host leaves the proxy as it was, as an invalid port does
+ proxyServer = Config.get().getProxyServer();
}
Config.get().setProxyServer(proxyServer);
@@ -103,6 +114,16 @@ protected String getHost(String text) {
}
}
+ //A port given with the proxy host is taken as the port where the port field is empty, the port field otherwise taking precedence
+ private HostAndPort getHostWithPort(String text) {
+ try {
+ HostAndPort hostAndPort = HostAndPort.fromString(text.trim());
+ return hostAndPort.hasPort() ? hostAndPort : null;
+ } catch(IllegalArgumentException e) {
+ return null;
+ }
+ }
+
protected Integer getPort(String text) {
try {
return Integer.parseInt(text);Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.