Subject: php-xml-parser uses deprecated eregi and reference of new object Package: php-xml-parser Version: 1.3.0-1 Severity: important
Hi, As per subject and: http://pear.php.net/bugs/bug.php?id=16567 I have written a small patch for replacing the eregi calls, and as the author didn't want to break php4 compatibility, I did some version checkings. As I'm also proposing to the upstream author to use the patch, I have sent him as copy of this entry. Note that the attached patch will fix the eregi calls, but NOT the return by reference of a new object line 616 (on the 1.3.2) or 633 (on version 1.3.0 that is currently packaged in Debian). This issue must be solved too, I'll let the maintainer or the upstream find a solution. Best would be that the upstream author fix his PEAR package and release an 1.3.3, so that we could package it into Debian. But if this is not done upstream, please have this fixed for Squeeze (at least the eregi stuffs, the rest is just when there's errors, so it's less of an issue). Thomas -- System Information: Debian Release: 5.0.4 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-4-xen-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash
--- Parser.php.orig 2010-05-05 23:48:46.000000000 +0800 +++ Parser.php 2010-05-06 00:10:04.000000000 +0800 @@ -417,7 +417,15 @@ /** * check, if file is a remote file */ - if (eregi('^(http|ftp)://', substr($file, 0, 10))) { + $regexp = '^(http|ftp)://'; + $file_start = substr($file, 0, 10); + if (version_compare( phpversion(), '5.3.0') >= 0){ + $check_result = prereg_match( "/" . $regexp . "/i" , $file_start); + }else{ + $check_result = eregi( $regexp , $file_start); + } + + if ( $check_result ) { if (!ini_get('allow_url_fopen')) { return $this-> raiseError('Remote files cannot be parsed, as safe mode is enabled.', @@ -474,16 +482,25 @@ if (is_resource($fp)) { $this->fp = $fp; return true; - } elseif (eregi('^[a-z]+://', substr($fp, 0, 10))) { - // see if it's an absolute URL (has a scheme at the beginning) - return $this->setInputFile($fp); - } elseif (file_exists($fp)) { - // see if it's a local file - return $this->setInputFile($fp); - } else { - // it must be a string - $this->fp = $fp; - return true; + }else{ + $regexp = '^[a-z]+://'; + $check_string = substr($fp, 0, 10); + if (version_compare( phpversion(), '5.3.0') >= 0){ + $check_result = prereg_match( "/" . $regexp . "/i" , $check_string); + }else{ + $check_result = eregi( $regexp , $check_string); + } + if ($check_result) { + // see if it's an absolute URL (has a scheme at the beginning) + return $this->setInputFile($fp); + } elseif (file_exists($fp)) { + // see if it's a local file + return $this->setInputFile($fp); + } else { + // it must be a string + $this->fp = $fp; + return true; + } } return $this->raiseError('Illegal input format',