Skip to content

Commit 5353baa

Browse files
committed
* bugfix: fixed #177 - the "NULL" resource record has an issue because the name conflicts with the PHP reserved word "null", so I
had originally named it "NUL" instead, but apparently this causes a problem for NTFS in Windows. I've changed it now to be "RR_NULL", which is dumb looking, but shouldn't conflict with anything. It can still be created in the way using "NULL", just the class name is named inconsistently. * bugfix: fixed #178 - I was trimming periods from names in the new Data class- which is correct for Domains and Mailboxes, but not Text objects, as it can break when you have a domain that happens to line up just right. This fix only trims() the period when it's a Domain or Mailbox class.
1 parent c36de20 commit 5353baa

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

CHANGES

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ NetDNS2 - PHP DNS Resolver and Updater
55
v2.0.7
66
------
77
* changed the hashing algorithm used for cache storage from sha256 -> xxh128; the xxHash algorithms are faster
8-
8+
* bugfix: fixed #177 - the "NULL" resource record has an issue because the name conflicts with the PHP reserved word "null", so I
9+
had originally named it "NUL" instead, but apparently this causes a problem for NTFS in Windows. I've changed it now to be
10+
"RR_NULL", which is dumb looking, but shouldn't conflict with anything. It can still be created in the way using "NULL", just the
11+
class name is named inconsistently.
12+
* bugfix: fixed #178 - I was trimming periods from names in the new Data class- which is correct for Domains and Mailboxes, but
13+
not Text objects, as it can break when you have a domain that happens to line up just right. This fix only trims() the period
14+
when it's a Domain or Mailbox class.
915

1016
v2.0.6
1117
------

src/NetDNS2/Data.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,23 @@ public function __construct(int $_type, mixed $_data = null, int &$_offset = -1)
7676
//
7777
} elseif ( (is_null($_data) == false) && (gettype($_data) == 'string') )
7878
{
79-
$value = trim($_data, '".');
79+
$value = $_data;
80+
81+
//
82+
// it's important that we trim off the trailing periods for domains and mailboxes, but we shouldn't
83+
// do this for text strings
84+
//
85+
if ( (($this instanceof \NetDNS2\Data\Domain) == true) || (($this instanceof \NetDNS2\Data\Mailbox) == true) )
86+
{
87+
$value = rtrim($value, '.');
88+
89+
//
90+
// but we should remove leading / trailing quotes from text entries
91+
//
92+
} else if (($this instanceof \NetDNS2\Data\Text) == true)
93+
{
94+
$value = trim($value, '"');
95+
}
8096

8197
if (strlen($value) > 0)
8298
{

src/NetDNS2/ENUM/RR/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function class(): string
145145
self::NS => 'NetDNS2\RR\NS',
146146
self::CNAME => 'NetDNS2\RR\CNAME',
147147
self::SOA => 'NetDNS2\RR\SOA',
148-
self::NULL => 'NetDNS2\RR\NULL',
148+
self::NULL => 'NetDNS2\RR\RR_NULL',
149149
self::WKS => 'NetDNS2\RR\WKS',
150150
self::PTR => 'NetDNS2\RR\PTR',
151151
self::HINFO => 'NetDNS2\RR\HINFO',

src/NetDNS2/RR.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function __construct(?\NetDNS2\Packet &$_packet = null)
134134

135135
} else
136136
{
137-
$this->type = \NetDNS2\ENUM\RR\Type::set(str_replace('NetDNS2\\RR\\', '', get_class($this)));
137+
$this->type = \NetDNS2\ENUM\RR\Type::set(str_replace([ 'NetDNS2\\RR\\RR_', 'NetDNS2\\RR\\' ], '', get_class($this)));
138138
$this->class = \NetDNS2\ENUM\RR\Classes::set('IN');
139139
$this->ttl = 86400;
140140
}

src/NetDNS2/RR/EID.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
* EID Resource Record - undefined; the rdata is simply used as-is in it's binary format, so not process has to be done.
1717
*
1818
*/
19-
final class EID extends \NetDNS2\RR\NUL
19+
final class EID extends \NetDNS2\RR\RR_NULL
2020
{
2121
}

src/NetDNS2/RR/NIMLOC.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
* NIMLOC Resource Record - undefined; the rdata is simply used as-is in it's binary format, so not process has to be done.
1717
*
1818
*/
19-
final class NIMLOC extends \NetDNS2\RR\NUL
19+
final class NIMLOC extends \NetDNS2\RR\RR_NULL
2020
{
2121
}

src/NetDNS2/RR/NUL.php renamed to src/NetDNS2/RR/RR_NULL.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
/**
1616
* NULL Resource Record - undefined; the rdata is simply used as-is in it's binary format, so not process has to be done.
1717
*
18-
* TODO: this is named "NUL" and not "NULL" because "NULL" is a reserved word in PHP!
18+
* This class is named "RR_NULL" because "NULL" is a reserved word in php.
19+
*
20+
* I had originally called this class "NUL", but that causes a problem in Windows, as it's a reserved word in NTFS.
21+
*
1922
*/
20-
class NUL extends \NetDNS2\RR
23+
class RR_NULL extends \NetDNS2\RR
2124
{
2225
/**
2326
* @see \NetDNS2\RR::rrToString()
@@ -48,6 +51,6 @@ protected function rrSet(\NetDNS2\Packet &$_packet): bool
4851
*/
4952
protected function rrGet(\NetDNS2\Packet &$_packet): string
5053
{
51-
return $this->rdata;
54+
return '';
5255
}
5356
}

tests/NetDNS2/parser/ParserTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public function testParser()
124124
'example.com. 300 IN DSYNC CSYNC NOTIFY 5555 another.endpoint.example.com.',
125125
'example.com. 300 IN DSYNC CSYNC NOTIFY 5555 bücher.de.'
126126
],
127+
'EID' => 'example.com. 300 IN EID ',
127128
'EUI48' => 'example.com. 300 IN EUI48 00-00-5e-00-53-2a',
128129
'EUI64' => 'example.com. 300 IN EUI64 00-00-5e-ef-10-00-00-2a',
129130
'GPOS' => 'example.com. 300 IN GPOS -32.6882 116.8652 10.0',
@@ -148,6 +149,7 @@ public function testParser()
148149
],
149150
'NAPTR' => 'example.com. 300 IN NAPTR 100 10 "S" "SIP+D2U" "!^.*$!sip:customer-service@example.com!" _sip._udp.example.com.',
150151
'NID' => 'example.com. 300 IN NID 10 14:4fff:ff20:ee64',
152+
'NIMLOC' => 'example.com. 300 IN NIMLOC ',
151153
'NSEC3PARAM' => 'example.com. 300 IN NSEC3PARAM 1 0 1 D399EAAB',
152154
'NSEC3' => 'example.com. 300 IN NSEC3 1 1 12 AABBCCDD b4um86eghhds6nea196smvmlo4ors995 NS DS RRSIG',
153155
'NSEC' => 'example.com. 300 IN NSEC test.host.com. A MX RRSIG NSEC TYPE123',
@@ -175,7 +177,10 @@ public function testParser()
175177
'TA' => 'example.com. 300 IN TA 21366 7 2 96eeb2ffd9b00cd4694e78278b5efdab0a80446567b69f634da078f0d90f01ba',
176178
'TKEY' => 'example.com. 300 IN TKEY gss.microsoft.com. 3 123456.',
177179
'TLSA' => '_443._tcp.www.example.com. 300 IN TLSA 1 1 2 92003ba34942dc74152e2f2c408d29eca5a520e7f2e06bb944f4dca346baf63c1b177615d466f6c4b71c216a50292bd58c9ebdd2f74e38fe51ffd48c43326cbc',
178-
'TXT' => 'example.com. 300 IN TXT "first record" "another records" "a third"',
180+
'TXT' => [
181+
'example.com. 300 IN TXT "first record" "another records" "a third"',
182+
'example.com. 300 IN TXT "example with broken domain example" ".com; and another example." "com with the perio in the first block"'
183+
],
179184
'URI' => 'example.com. 300 IN URI 10 1 "https://netdns2.com/about"',
180185
'WKS' => 'example.com. 300 IN WKS 128.8.1.14 6 21 25',
181186
'X25' => 'example.com. 300 IN X25 "311 06 17 0 09 56"',

0 commit comments

Comments
 (0)