ID:               47035
 Updated by:       fel...@php.net
 Reported By:      valli at icsurselva dot ch
 Status:           Open
 Bug Type:         Network related
 Operating System: gentoo
 PHP Version:      5.2.8
 Assigned To:      felipe
 New Comment:

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)
}



Previous Comments:
------------------------------------------------------------------------

[2009-01-09 12:52:12] paj...@php.net

I agree, it would be more logical to return an array of strings.

Comments?

------------------------------------------------------------------------

[2009-01-09 11:36:01] valli at icsurselva dot ch

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")

------------------------------------------------------------------------

[2009-01-08 17:20:39] fel...@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks.

------------------------------------------------------------------------

[2009-01-08 10:45:05] paj...@php.net

Felipe, can you give it a try please?

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.70.2.7&r2=1.70.2.7.2.7&pathrev=PHP_5_2



------------------------------------------------------------------------

[2009-01-08 09:31:41] valli at icsurselva dot ch

Here's my current workaround:

$rt = @dns_get_record($lookuphost, DNS_ANY);
// workaround for http://bugs.php.net/bug.php?id=47035
if (substr(PHP_VERSION,0,strpos(PHP_VERSION, '-')) == '5.2.8') {
    for($i = 0, $rts = sizeof($rt); $i < $rts; ++$i) {
        if ($rt[$i]['type'] == 'TXT') {
            // remove last byte
            $rt[$i]['txt'] = substr($rt[$i]['txt'], 0, -1);
        }
    }
}

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/47035

-- 
Edit this bug report at http://bugs.php.net/?id=47035&edit=1

Reply via email to