Commit 7dc07bda authored by Michael Gratton's avatar Michael Gratton 🤞

Fix NetworkAddressValidator not updating port number

Ensure the validated address is updated even if we know it is valid,
since the port number may have changed.

Fixes #294
parent b86c28a3
Pipeline #65683 passed with stages
in 31 minutes and 55 seconds
......@@ -453,30 +453,35 @@ public class Components.NetworkAddressValidator : Validator {
debug("Error parsing host name \"%s\": %s", value, err.message);
}
// Only re-validate if previously invalid or the host has
// changed
if (address != null && (
this.validated_address == null ||
this.validated_address.hostname != address.hostname)) {
this.cancellable = new GLib.Cancellable();
this.resolver.lookup_by_name_async.begin(
address.hostname, this.cancellable,
(obj, res) => {
try {
this.resolver.lookup_by_name_async.end(res);
this.validated_address = address;
update_state(Validator.Validity.VALID, reason);
} catch (GLib.IOError.CANCELLED err) {
this.validated_address = null;
} catch (GLib.Error err) {
this.validated_address = null;
update_state(Validator.Validity.INVALID, reason);
if (address != null) {
// Re-validate if previously invalid or the host has
// changed
if (this.validated_address == null ||
this.validated_address.hostname != address.hostname) {
this.cancellable = new GLib.Cancellable();
this.resolver.lookup_by_name_async.begin(
address.hostname, this.cancellable,
(obj, res) => {
try {
this.resolver.lookup_by_name_async.end(res);
this.validated_address = address;
update_state(Validator.Validity.VALID, reason);
} catch (GLib.IOError.CANCELLED err) {
this.validated_address = null;
} catch (GLib.Error err) {
this.validated_address = null;
update_state(Validator.Validity.INVALID, reason);
}
this.cancellable = null;
}
this.cancellable = null;
}
);
ret = Validator.Validity.IN_PROGRESS;
);
ret = Validator.Validity.IN_PROGRESS;
} else {
// Update the validated address in case the port
// number is being edited and has changed
this.validated_address = address;
ret = Validator.Validity.VALID;
}
}
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment