Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.8

Bug #516 XML_Parser should set allow_url_fopen to "On" before parsing remote XML files
Submitted: 2004-01-04 10:49 UTC
From: mj Assigned: schst
Status: Closed Package: XML_Parser
PHP Version: Irrelevant OS: %
Roadmaps: (Not assigned)    
Subscription  


 [2004-01-04 10:49 UTC] mj
Description: ------------ When parsing XML files on a remote host with XML_Parser, it has to be ensured that allow_url_fopen is set to On. Otherwise the parsing will fail. Thus the following patch sets the configuration directive to On, when one has passed an URL to setInput(). The patch is probably not finished yet, because the check should happen in setInputFile(), but you should get an idea about the problem. (I can commit the [improved] fix myself, but I'd like to get an OK from you.) Index: Parser.php =================================================================== RCS file: /repository/pear/XML_Parser/Parser.php,v retrieving revision 1.8 diff -u -r1.8 Parser.php --- Parser.php 5 Oct 2003 15:48:57 -0000 1.8 +++ Parser.php 4 Jan 2004 10:52:39 -0000 @@ -243,6 +243,7 @@ } // see if it's an absolute URL (has a scheme at the beginning) elseif (eregi('^[a-z]+://', substr($fp, 0, 10))) { + ini_set('allow_url_fopen', 1); return $this->setInputFile($fp); } // see if it's a local file

Comments

 [2004-01-10 11:44 UTC] pajoye
Hello, I'm not sure this is a correct way to fix. What happens in safe_mode with allow_url_fopen disabled? Maybe a test of the option and raises an error if not set is a bit cleaner. pierre
 [2004-03-10 10:56 UTC] mj
Actually fopen() can only work with local files with safe mode activated. The following patch circumvents this problem by checking if safe mode is active and raising an error when necessary. Index: XML_Parser/Parser.php =================================================================== RCS file: /repository/pear/XML_Parser/Parser.php,v retrieving revision 1.8 diff -u -r1.8 Parser.php --- XML_Parser/Parser.php 5 Oct 2003 15:48:57 -0000 1.8 +++ XML_Parser/Parser.php 10 Mar 2004 11:03:25 -0000 @@ -243,6 +243,11 @@ } // see if it's an absolute URL (has a scheme at the beginning) elseif (eregi('^[a-z]+://', substr($fp, 0, 10))) { + if (!ini_get('safe_mode')) { + ini_set('allow_url_fopen', 1); + } else { + return $this->raiseError('Cannot open URL in Safe Mode'); + } return $this->setInputFile($fp); } // see if it's a local file
 [2004-04-13 19:04 UTC] schst
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.
 [2004-11-23 07:20 UTC] ip_fresh at yahoo dot com
Nice comment. It has helped me. Dan http://www.marketingtops.com