You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I invoke IPNetwork.TryParse with a CIDR string that contains additional trailing characters after a space character, the parse succeeds:
[Test]
public void Should_return_false_when_parsing_a_cidr_with_extra_characters()
{
var result = IPNetwork.TryParse("20.42.65.64/29 !%!!!!!", sanitanize: false, out _);
// This assert fails.
Assert.That(result, Is.False);
}
This is unexpected, since sanitanize: false leaves the trailing characters where they are.
The problem is caused by the space character; in InternalParse a space character is included in the split character array, but there is no check for there not being more than 2 components to the resulting split.
I guess the issue here is that the use of sanitanize: false implies that the method should fail, but instead due to the bug it is inadvertently removing (sanitizing) the garbage instead of returning null (TryParse) or throwing an exception (Parse).
In addition, it would be good to have a clearer definition of the intention of the sanitanize parameter. Also to introduce a new function that deprecates the typo in the parameter name 😉
If I invoke IPNetwork.TryParse with a CIDR string that contains additional trailing characters after a space character, the parse succeeds:
This is unexpected, since
sanitanize: false
leaves the trailing characters where they are.The problem is caused by the space character; in
InternalParse
a space character is included in the split character array, but there is no check for there not being more than 2 components to the resulting split.ipnetwork/src/System.Net.IPNetwork/IPNetwork.cs
Line 624 in 28a599e
The text was updated successfully, but these errors were encountered: