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
This commit is contained in:
parent
b86c28a32d
commit
7dc07bdad6
1 changed files with 28 additions and 23 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue