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));
|
writer.Write(reader.Read(esc_pos));
|
||||||
reader.Advance(EscapeTag.Length);
|
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(reader.RemainingSpan[..2], NumberStyles.AllowHexSpecifier, null, out var b))
|
||||||
if (byte.TryParse(digits, NumberStyles.AllowHexSpecifier, null, out var escaped_char))
|
|
||||||
{
|
{
|
||||||
writer.Write((char)escaped_char);
|
converted = true;
|
||||||
}
|
escapedChar = (char)b;
|
||||||
else
|
reader.Advance(2);
|
||||||
{
|
|
||||||
writer.Write(EscapeTag);
|
|
||||||
writer.Write(digits);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (converted)
|
||||||
|
{
|
||||||
|
writer.Write(escapedChar);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.Write(EscapeTag);
|
||||||
|
}
|
||||||
|
|
||||||
esc_pos = reader.RemainingSpan.IndexOf(EscapeTag);
|
esc_pos = reader.RemainingSpan.IndexOf(EscapeTag);
|
||||||
if (esc_pos == -1)
|
if (esc_pos == -1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue