Added support for empty salt ( aka dash )
When using \Badcow\DNS\Parser\Parser::parse, and the zone file contains and empty salt in the NSEC3PARAM, it throws an error:
Could not extract Rdata from resource record " 0 NSEC3PARAM 1 0 0 -"."
This is because the setSalt function in Rdata/NSEC3PARAM.php is as follows:
public function setSalt(string $salt): void
{
if (false === $bin = @hex2bin($salt)) {
throw new \InvalidArgumentException('Salt must be a hexadecimal string.');
}
$this->salt = $bin;
}
This is a problem, because the salt can be empty ( dash ) but this is not support in this function. Adding a simple check to see if its a dash, and just return, resolves this issue.
I dont know if you guys want it written differently, let me know.
This is also a issue in getSalt and fromWire
Im not a wire guy so i hope you will check that function
@MartinTerp Thank you for the PR. Could you please write a test case? I'm happy to work on the fromWire method, but a test case helps alot.
Sure, do you want it in the "public function testFactory(): void" function, or its own?