Fix Kea Dhcp parser
This commit is contained in:
parent
1f51a65f35
commit
3ce0297682
1 changed files with 17 additions and 9 deletions
|
|
@ -28,20 +28,28 @@ public static class KeaDhcpLease
|
|||
{
|
||||
writer.Write(reader.Read(esc_pos));
|
||||
reader.Advance(EscapeTag.Length);
|
||||
if (EscapeTag.Length <= reader.RemainingCount - 2)
|
||||
|
||||
bool converted = false;
|
||||
char escapedChar = default;
|
||||
if (reader.RemainingCount >= 2)
|
||||
{
|
||||
var digits = reader.Read(2);
|
||||
if (byte.TryParse(digits, NumberStyles.AllowHexSpecifier, null, out var escaped_char))
|
||||
if (byte.TryParse(reader.RemainingSpan[..2], NumberStyles.AllowHexSpecifier, null, out var b))
|
||||
{
|
||||
writer.Write((char)escaped_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(EscapeTag);
|
||||
writer.Write(digits);
|
||||
converted = true;
|
||||
escapedChar = (char)b;
|
||||
reader.Advance(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (converted)
|
||||
{
|
||||
writer.Write(escapedChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(EscapeTag);
|
||||
}
|
||||
|
||||
esc_pos = reader.RemainingSpan.IndexOf(EscapeTag);
|
||||
if (esc_pos == -1)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue