[Hosts]Ignore default ACME sample entries (#28163)

This commit is contained in:
Davide Giacometti 2023-09-05 13:13:41 +02:00 committed by GitHub
parent 83f0625427
commit 298a5eba2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -76,6 +76,8 @@ namespace Hosts.Tests
[DataRow("host 10.1.1.1")]
[DataRow("# comment 10.1.1.1 host # comment")]
[DataRow("10.1.1.1 host01 host02 host03 host04 host05 host06 host07 host08 host09 host10")]
[DataRow("102.54.94.97 rhino.acme.com # source server")]
[DataRow("38.25.63.10 x.acme.com # x client host")]
public void Not_Valid_Entry(string line)
{
var entry = new Entry(0, line);

View File

@ -448,7 +448,7 @@
ScrollViewer.IsVerticalRailEnabled="True"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
Text="{Binding Comment, Mode=TwoWay}" />
Text="{Binding Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<ToggleSwitch
x:Uid="Active"
IsOn="{Binding Active, Mode=TwoWay}"

View File

@ -44,6 +44,7 @@ namespace Hosts.Models
}
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(Valid))]
private string _comment;
[ObservableProperty]
@ -153,7 +154,19 @@ namespace Hosts.Models
public bool Validate(bool validateHostsLength)
{
if (Equals("102.54.94.97", "rhino.acme.com", "source server") || Equals("38.25.63.10", "x.acme.com", "x client host"))
{
return false;
}
return Type != AddressType.Invalid && ValidationHelper.ValidHosts(Hosts, validateHostsLength);
}
private bool Equals(string address, string hosts, string comment)
{
return string.Equals(Address, address, StringComparison.Ordinal)
&& string.Equals(Hosts, hosts, StringComparison.Ordinal)
&& string.Equals(Comment, comment, StringComparison.Ordinal);
}
}
}