|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-01-08 09:07 UTC] valli at icsurselva dot ch
Description:
------------
The last byte of a TXT record returned by dns_get_record
is garbage.
Reproduce code:
---------------
$rt = dns_get_record('82.19.186.195.countries.blackholes.us', DNS_TXT);
$txt = $rt[0]['txt'];
print $txt." (".strlen($txt).")\n";
foreach(str_split($txt) as $char) {
print "$char\t".ord($char)."\n";
}
Expected result:
----------------
ch (2)
c 99
h 104
Actual result:
--------------
ch (3)
c 99
h 104
128
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
Hello again, I just dicovered that the garbage chars not only appear at the end of a TXT record. Example: nslookup -type=TXT 82.19.186.195.aspath.routeviews.org Returns: text = "13237 3303 44038" "195.186.0.0" "17" This DNS request returns 3 Strings. If I do this with dns_get_record the strings are concatenated (containing a garbage char between the strings) BTW: Is it really a good idea to concatenate this strings? Wouldn't it better to return a array containing this strings? Example: the anwers from routeviews.org are really hard (if not impossible) to parse in this way: "13237 3303 44038195.186.0.017" it would be better in this way: array("13237 3303 44038","195.186.0.0","17")Sure, it's right to do. We add a new entry in the array returned, on 5.3+ we get: array(6) { ["host"]=> string(35) "82.19.186.195.aspath.routeviews.org" ["type"]=> string(3) "TXT" ["txt"]=> string(31) "13237 3303 44038195.186.0.017" ["entries"]=> array(3) { [0]=> string(16) "13237 3303 44038" [1]=> string(11) "195.186.0.0" [2]=> string(2) "17" } ["class"]=> string(2) "IN" ["ttl"]=> int(592) }