From 2c8133a7b4267ba570f473abe4b08b01a0c8238a Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Wed, 10 Jan 2018 17:26:11 +0100 Subject: [PATCH] Allow empty domain names to be decoded This is a rather long standing issue. LibDNS didn't allow to decode empty domain names. Empty domain names were previously only observed with PTR records, but were now also observed in regular queries in authoritative records that include the root nameservers. LibDNS 2.0 mainly adds scalar types has just a few breaking changes. We don't expose it anywhere, so an upgrade is perfectly fine. Fixes #53. --- composer.json | 2 +- lib/Internal/Socket.php | 2 +- test/DecodeTest.php | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/DecodeTest.php diff --git a/composer.json b/composer.json index db074ff..77ced0c 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "amphp/parser": "^1", "amphp/uri": "^0.1", "amphp/windows-registry": "^0.3", - "daverandom/libdns": "^1" + "daverandom/libdns": "^2.0.1" }, "require-dev": { "amphp/phpunit-util": "^1", diff --git a/lib/Internal/Socket.php b/lib/Internal/Socket.php index dc5e7cd..f17ce52 100644 --- a/lib/Internal/Socket.php +++ b/lib/Internal/Socket.php @@ -237,7 +237,7 @@ abstract class Socket { return false; } - $questionRecord = $questionRecords->current(); + $questionRecord = $questionRecords->getIterator()->current(); if ($questionRecord->getClass() !== $question->getClass()) { return false; diff --git a/test/DecodeTest.php b/test/DecodeTest.php new file mode 100644 index 0000000..05ffe14 --- /dev/null +++ b/test/DecodeTest.php @@ -0,0 +1,21 @@ +create(); + $response = $decoder->decode($message); + + $this->assertInstanceOf(Message::class, $response); + } +}