-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
Milestone
Description
For example:
IPAddress.Parse([.. "::A%"u8, 255]); // Does not throwNow that IPAddress accepts parsing bytes (new in .NET 10 - #102144), we seem to also be accepting invalid UTF-8 here:
runtime/src/libraries/Common/src/System/Net/IPv6AddressHelper.Common.cs
Lines 159 to 175 in f1c94c4
| case '%': | |
| // An IPv6 address is separated from its scope by a '%' character. The scope | |
| // is terminated by the natural end of the address, the address end character (']') | |
| // or the start of the prefix ('/'). | |
| while (i + 1 < end) | |
| { | |
| i++; | |
| if (name[i] == TChar.CreateTruncating(']')) | |
| { | |
| goto case ']'; | |
| } | |
| else if (name[i] == TChar.CreateTruncating('/')) | |
| { | |
| goto case '/'; | |
| } | |
| } | |
| break; |
Not sure this is a real issue, but given that the parameters are explicitly named as utf8 (bool TryParse(ReadOnlySpan<byte> utf8Text, ...)) the user may be expecting that a parsed value is also valid UTF-8.