From: RQuadling at GMail dot com Operating system: Windows XP SP2 PHP version: 5CVS-2006-11-13 (snap) PHP Bug Type: SimpleXML related Bug description: simplexml_load_file does not obey default stream context
Description: ------------ I'm behind a MS ISA server using NTLM Authentication which is unsupported by PHP. To allow PHP through, I use Python and the NTLM Authentication Proxy Server (further details for this at http://rquadling.php1h.com). I then use an auto_prepend_file entry to include a default context assignment to route http traffic to my the proxy. This works fine for both CLI and ISAPI operations. The simplexml_load_file() function does not have a context facility. It also does not use the same mechanism to get data OR it is ignoring the default context setup. The example code is just to show the error. If you are NOT using contexts or you are have direct access to the outside world, then you will not see the problem. My NTLM APS logs do not show 2 requests to the external data. Only 1 - the file_get_contents() call. Reproduce code: --------------- <?php // Define the default, system-wide context. - COPIED FROM auto_prepended_file.php $r_default_context = stream_context_get_default ( array ( 'http' => array ( // All HTTP requests are passed through the local NTLM proxy server on port 8080. 'proxy' => 'tcp://127.0.0.1:8080', 'request_fulluri' => True, ), ) ); echo file_get_contents('http://www.people.com.cn/rss/politics.xml'); $xml = simplexml_load_file('http://www.people.com.cn/rss/politics.xml'); ?> Expected result: ---------------- <?xml version="1.0" encoding="GB2312"?> <rss version="2.0"> <channel> <title>╣·─┌ð┬╬┼</title> <link>http://politics.people.com.cn</link> <language>zh_CN</language> <copyright>Copyright ? 1997-2006 by www.people.com.cn. all rights reserved</copyright> <pubDate>2006-11-13 16:40:00</pubDate> [SNIP] <pubDate>2006-11-13 16:43:03</pubDate> </item> </channel> </rss> Actual result: -------------- <?xml version="1.0" encoding="GB2312"?> <rss version="2.0"> <channel> <title>╣·─┌ð┬╬┼</title> <link>http://politics.people.com.cn</link> <language>zh_CN</language> <copyright>Copyright ? 1997-2006 by www.people.com.cn. all rights reserved</copyright> <pubDate>2006-11-13 16:40:00</pubDate> [SNIP] <pubDate>2006-11-13 16:43:03</pubDate> </item> </channel> </rss> Warning: simplexml_load_file(http://www.people.com.cn/rss/politics.xml): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden ( The ISA Server denies the specified Uniform Resource Locator (URL). ) in C:\noCX.php on line 16 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://www.people.com.cn/rss/politics.xml" in C:\noCX.php on line 16 -- Edit bug report at http://bugs.php.net/?id=39493&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39493&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39493&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39493&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39493&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39493&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39493&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39493&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39493&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39493&r=support Expected behavior: http://bugs.php.net/fix.php?id=39493&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39493&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39493&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39493&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39493&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39493&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39493&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39493&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39493&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39493&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39493&r=mysqlcfg