mchibouni / owasp-esapi-php

Automatically exported from code.google.com/p/owasp-esapi-php
Other
0 stars 0 forks source link

Fatal Error calling attributes() on SimpleXMLElement instances on PHP 5.2.0 and PHP 5.2.0-8+etch16. #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following error on PHP 5.2.0-8+etch16 on Apache on Debian Etch:

Fatal error: Call to a member function attributes() on a non-object in
/var/www/vhosts/user.name/httpdocs/esapi-php/src/reference/DefaultSecurityConfig
uration.php
on line 166

The code that causes this is:

{{{
$_events = $this->_xml->xpath('/esapi-properties/IntrusionDetector/event');

foreach ($_events as $event) {

    $name = (string) $event[0]->attributes()->name;
    $count = (int) $event[0]->attributes()->count;
    $interval = (int) $event[0]->attributes()->interval;
}}}

`$_events` is an array of `SimpleXMLElement` and the error happens when we do:

`SimpleXMLElement[0]->attributes()`

This works:

`SimpleXMLElement->attributes()`

I've tested this on PHP 5.2.0-8+etch16 and PHP 5.2.9 on windows and propose
the attached patch as a fix.
It's worth noting that PHP 5.2.0-8+etch16 is the latest stable package of
PHP 5 for Debian Etch http://packages.debian.org/etch/php5 and seems to be
a popular platform for web hosting companies.

Original issue reported on code.google.com by jahboite@gmail.com on 14 Apr 2010 at 8:07

Attachments:

GoogleCodeExporter commented 9 years ago
I've committed a fix for this in r736

Original comment by jahboite@gmail.com on 20 Apr 2010 at 9:54