Closed chaosben closed 1 year ago
The use of Net_DNS2_Names::unpack for TXT-Records cripples the content of TXT-records if a part ends with a dot ".".
https://github.com/mikepultz/netdns2/blob/dc8053772132a855b8bb6193422a959995f3a773/Net/DNS2/RR/TXT.php#L96
This is because the function Net_DNS2_Names::unpack function trims the dot:
https://github.com/mikepultz/netdns2/blob/dc8053772132a855b8bb6193422a959995f3a773/Net/DNS2/Names.php#L72
Code to reproduce in version 1.5.3:
<?php require 'vendor/autoload.php'; $resolver = new Net_DNS2_Resolver(['nameservers' => ['8.8.8.8'], ]); $result = $resolver->query('spf-0.secureserver.net', 'TXT'); foreach($result->answer as $record) { if ($record instanceof Net_DNS2_RR_TXT) { echo "rdata: " . $record->rdata . PHP_EOL . PHP_EOL; foreach($record->text as $idx => $textPart) { echo "part {$idx}: {$textPart}" . PHP_EOL; } } }
Output:
rdata: �v=spf1 ip4:97.74.135.0/24 ip4:72.167.238.0/24 ip4:72.167.234.0/24 ip4:72.167.218.0/24 ip4:68.178.252.0/24 ip4:68.178.213.0/24 ip4:216.69.139.0/24 ip4:208.109.80.0/24 ip4:92.204.81.0/24 ip4:198.71.224.0/19 ip4:184.168.224.0/24 ip4:184.168.200.0/24 ip4:184.�168.131.0/24 ip4:184.168.128.0/24 ip4:92.204.65.0/28 ip4:182.50.132.0/24 ip4:173.201.192.0/23 ip4:72.167.168.0/24 ip4:92.204.71.0/24 ip4:132.148.124.0/24 ip4:72.167.172.0/24 ip4:188.121.52.0/24 ip4:188.121.53.0/24 ip4:52.89.65.132 ip4:54.214.222.76 ip4:54h.184.82.65 ip4:52.26.164.15 ip4:68.178.181.0/24 ip4:50.63.8.0/22 include:spf.protection.outlook.com -all part 0: v=spf1 ip4:97.74.135.0/24 ip4:72.167.238.0/24 ip4:72.167.234.0/24 ip4:72.167.218.0/24 ip4:68.178.252.0/24 ip4:68.178.213.0/24 ip4:216.69.139.0/24 ip4:208.109.80.0/24 ip4:92.204.81.0/24 ip4:198.71.224.0/19 ip4:184.168.224.0/24 ip4:184.168.200.0/24 ip4:184 part 1: 168.131.0/24 ip4:184.168.128.0/24 ip4:92.204.65.0/28 ip4:182.50.132.0/24 ip4:173.201.192.0/23 ip4:72.167.168.0/24 ip4:92.204.71.0/24 ip4:132.148.124.0/24 ip4:72.167.172.0/24 ip4:188.121.52.0/24 ip4:188.121.53.0/24 ip4:52.89.65.132 ip4:54.214.222.76 ip4:54 part 2: 184.82.65 ip4:52.26.164.15 ip4:68.178.181.0/24 ip4:50.63.8.0/22 include:spf.protection.outlook.com -all
As you can see, part 0 and part 1 are missing the trailing dot.
Thanks @chaosben - this fix will be included in v1.5.4.
Mike
Thank you very much! 👍
The use of Net_DNS2_Names::unpack for TXT-Records cripples the content of TXT-records if a part ends with a dot ".".
https://github.com/mikepultz/netdns2/blob/dc8053772132a855b8bb6193422a959995f3a773/Net/DNS2/RR/TXT.php#L96
This is because the function Net_DNS2_Names::unpack function trims the dot:
https://github.com/mikepultz/netdns2/blob/dc8053772132a855b8bb6193422a959995f3a773/Net/DNS2/Names.php#L72
Code to reproduce in version 1.5.3:
Output:
As you can see, part 0 and part 1 are missing the trailing dot.